Configuration can be used with default values

This commit is contained in:
c3ma
2020-10-16 18:40:39 +02:00
parent e95590ffd6
commit 8458912962
3 changed files with 19 additions and 13 deletions

View File

@@ -28,16 +28,16 @@ void Plant::init(void) {
this->mSetting->pSensorWet->setValidator([] (long candidate) {
return ((candidate >= 0) && (candidate <= 4095) );
});
this->mSetting->pPumpAllowedHourRangeStart->setDefaultValue(8);
this->mSetting->pPumpAllowedHourRangeStart->setDefaultValue(8); // start at 8:00
this->mSetting->pPumpAllowedHourRangeStart->setValidator([] (long candidate) {
return ((candidate >= 0) && (candidate <= 23) );
});
this->mSetting->pPumpAllowedHourRangeEnd->setDefaultValue(20);
this->mSetting->pPumpAllowedHourRangeEnd->setDefaultValue(20); // stop pumps at 20:00
this->mSetting->pPumpAllowedHourRangeEnd->setValidator([] (long candidate) {
return ((candidate >= 0) && (candidate <= 23) );
});
this->mSetting->pPumpOnlyWhenLowLight->setDefaultValue(true);
this->mSetting->pPumpCooldownInHours->setDefaultValue(20);
this->mSetting->pPumpCooldownInHours->setDefaultValue(20); // minutes
this->mSetting->pPumpCooldownInHours->setValidator([] (long candidate) {
return ((candidate >= 0) && (candidate <= 1024) );
});

View File

@@ -342,9 +342,15 @@ void setup() {
Homie.setLoopFunction(loopHandler);
mConfigured = Homie.isConfigured();
// Load the settings
deepSleepTime.setDefaultValue(0);
// Set default values
deepSleepTime.setDefaultValue(300000); /* 5 minutes in milliseconds */
deepSleepNightTime.setDefaultValue(0);
wateringDeepSleep.setDefaultValue(60000); /* 1 minute in milliseconds */
waterLevelMax.setDefaultValue(1000); /* 100cm in mm */
waterLevelMin.setDefaultValue(50); /* 5cm in mm */
waterLevelWarn.setDefaultValue(500); /* 50cm in mm */
waterLevelVol.setDefaultValue(5000); /* 5l in ml */
if (mConfigured) {
// Advertise topics