Controller is runing again
This commit is contained in:
@@ -12,63 +12,34 @@
|
||||
|
||||
#include "PlantCtrl.h"
|
||||
|
||||
Plant::Plant(int pinSensor, int pinPump,int plantId) {
|
||||
Plant::Plant(int pinSensor, int pinPump,int plantId, HomieNode *plant, PlantSettings_t* setting) {
|
||||
this->mPinSensor = pinSensor;
|
||||
this->mPinPump = pinPump;
|
||||
|
||||
this->mPlant = plant;
|
||||
/*
|
||||
{
|
||||
char* name = "moistZdry";
|
||||
name[5]= plantIdChar;
|
||||
mSensorDry = new HomieSetting<long>(name, "Moist sensor dry threshold");
|
||||
mSensorDry->setDefaultValue(4095);
|
||||
mSensorDry->setValidator([] (long candidate) {
|
||||
return ((candidate >= 0) && (candidate <= 4095) );
|
||||
});
|
||||
}
|
||||
{
|
||||
char* name = "moistZwet";
|
||||
name[6]= plantIdChar;
|
||||
mSensorWet = new HomieSetting<long>(name, "Moist sensor wet threshold");
|
||||
mSensorWet->setDefaultValue(0);
|
||||
mSensorWet->setValidator([] (long candidate) {
|
||||
return ((candidate >= 0) && (candidate <= 4095) );
|
||||
});
|
||||
}
|
||||
{
|
||||
char* name = "rangeZhourstart";
|
||||
name[6]= plantIdChar;
|
||||
mPumpAllowedHourRangeStart = new HomieSetting<long>(name, "Range pump allowed hour start");
|
||||
mPumpAllowedHourRangeStart->setDefaultValue(8);
|
||||
mPumpAllowedHourRangeStart->setValidator([] (long candidate) {
|
||||
return ((candidate >= 0) && (candidate <= 23) );
|
||||
});
|
||||
}
|
||||
{
|
||||
char* name = "rangeZhourend";
|
||||
name[6]= plantIdChar;
|
||||
mPumpAllowedHourRangeEnd = new HomieSetting<long>(name, "Range pump allowed hour end");
|
||||
mPumpAllowedHourRangeEnd->setDefaultValue(20);
|
||||
mPumpAllowedHourRangeEnd->setValidator([] (long candidate) {
|
||||
return ((candidate >= 0) && (candidate <= 23) );
|
||||
});
|
||||
}
|
||||
{
|
||||
char* name = "onlyWhenLowLightZ";
|
||||
name[16]= plantIdChar;
|
||||
mPumpOnlyWhenLowLight = new HomieSetting<bool>(name, "Enable the Pump only, when there is light but not enought to charge battery");
|
||||
mPumpOnlyWhenLowLight->setDefaultValue(true);
|
||||
}
|
||||
{
|
||||
char* name = "cooldownpumpZ";
|
||||
name[12]= plantIdChar;
|
||||
mPumpCooldownInHours = new HomieSetting<long>(name, "How long to wait until the pump is activated again");
|
||||
mPumpCooldownInHours->setDefaultValue(20);
|
||||
mPumpCooldownInHours->setValidator([] (long candidate) {
|
||||
return ((candidate >= 0) && (candidate <= 1024) );
|
||||
});
|
||||
}
|
||||
*/
|
||||
this->mSetting = mSetting;
|
||||
this->mSetting.pSensorDry->setDefaultValue(4095);
|
||||
this->mSetting.pSensorDry->setValidator([] (long candidate) {
|
||||
return ((candidate >= 0) && (candidate <= 4095) );
|
||||
});
|
||||
this->mSetting.pSensorWet->setDefaultValue(0);
|
||||
this->mSetting.pSensorWet->setValidator([] (long candidate) {
|
||||
return ((candidate >= 0) && (candidate <= 4095) );
|
||||
});
|
||||
this->mSetting.pPumpAllowedHourRangeStart->setDefaultValue(8);
|
||||
this->mSetting.pPumpAllowedHourRangeStart->setValidator([] (long candidate) {
|
||||
return ((candidate >= 0) && (candidate <= 23) );
|
||||
});
|
||||
this->mSetting.pPumpAllowedHourRangeEnd->setDefaultValue(20);
|
||||
this->mSetting.pPumpAllowedHourRangeEnd->setValidator([] (long candidate) {
|
||||
return ((candidate >= 0) && (candidate <= 23) );
|
||||
});
|
||||
this->mSetting.pPumpOnlyWhenLowLight->setDefaultValue(true);
|
||||
this->mSetting.pPumpCooldownInHours->setDefaultValue(20);
|
||||
this->mSetting.pPumpCooldownInHours->setValidator([] (long candidate) {
|
||||
return ((candidate >= 0) && (candidate <= 1024) );
|
||||
});
|
||||
*/
|
||||
}
|
||||
|
||||
void Plant::addSenseValue(int analog) {
|
||||
|
@@ -10,10 +10,10 @@
|
||||
*/
|
||||
#include "PlantCtrl.h"
|
||||
#include "ControllerConfiguration.h"
|
||||
#include "HomieConfiguration.h"
|
||||
#include "DS18B20.h"
|
||||
#include <Homie.h>
|
||||
#include "esp_sleep.h"
|
||||
#include "HomieConfiguration.h"
|
||||
|
||||
const unsigned long TEMPREADCYCLE = 30000; /**< Check temperature all half minutes */
|
||||
|
||||
@@ -46,13 +46,13 @@ RTC_DATA_ATTR int gCurrentPlant = 0; /**< Value Range: 1 ... 7 (0: no plant need
|
||||
Ds18B20 dallas(SENSOR_DS18B20);
|
||||
|
||||
Plant mPlants[MAX_PLANTS] = {
|
||||
Plant(SENSOR_PLANT0, OUTPUT_PUMP0, 0),
|
||||
Plant(SENSOR_PLANT1, OUTPUT_PUMP1, 1),
|
||||
Plant(SENSOR_PLANT2, OUTPUT_PUMP2, 2),
|
||||
Plant(SENSOR_PLANT3, OUTPUT_PUMP3, 3),
|
||||
Plant(SENSOR_PLANT4, OUTPUT_PUMP4, 4),
|
||||
Plant(SENSOR_PLANT5, OUTPUT_PUMP5, 5),
|
||||
Plant(SENSOR_PLANT6, OUTPUT_PUMP6, 6)
|
||||
Plant(SENSOR_PLANT0, OUTPUT_PUMP0, 0, &plant0, &mSetting0),
|
||||
Plant(SENSOR_PLANT1, OUTPUT_PUMP1, 1, &plant1, &mSetting1),
|
||||
Plant(SENSOR_PLANT2, OUTPUT_PUMP2, 2, &plant2, &mSetting2),
|
||||
Plant(SENSOR_PLANT3, OUTPUT_PUMP3, 3, &plant3, &mSetting3),
|
||||
Plant(SENSOR_PLANT4, OUTPUT_PUMP4, 4, &plant4, &mSetting4),
|
||||
Plant(SENSOR_PLANT5, OUTPUT_PUMP5, 5, &plant5, &mSetting5),
|
||||
Plant(SENSOR_PLANT6, OUTPUT_PUMP6, 6, &plant6, &mSetting6)
|
||||
};
|
||||
|
||||
void readAnalogValues() {
|
||||
@@ -330,7 +330,7 @@ void setup() {
|
||||
if (HomieInternals::MAX_CONFIG_SETTING_SIZE < MAX_CONFIG_SETTING_ITEMS) {
|
||||
Serial << "HOMIE | Settings: " << HomieInternals::MAX_CONFIG_SETTING_SIZE << "/" << MAX_CONFIG_SETTING_ITEMS << endl;
|
||||
Serial << " | Update Limits.hpp : MAX_CONFIG_SETTING_SIZE to " << MAX_CONFIG_SETTING_ITEMS << endl;
|
||||
Serial << " | Update Limits.hpp : MAX_JSON_CONFIG_FILE_SIZE to 3000" << endl;
|
||||
Serial << " | Update Limits.hpp : MAX_JSON_CONFIG_FILE_SIZE to 5000" << endl;
|
||||
}
|
||||
|
||||
Homie_setFirmware("PlantControl", FIRMWARE_VERSION);
|
||||
|
Reference in New Issue
Block a user