add timer only mode, more sane default config

This commit is contained in:
Empire 2022-05-20 01:00:04 +02:00
parent 5dedc76727
commit 662d7bc853
5 changed files with 19 additions and 9 deletions

View File

@ -45,6 +45,8 @@ static const char *SENSOR_STRING[] = {
#define MISSING_SENSOR -2
//plant uses only cooldown and duration, moisture is measured but ignored, allowedHours is ignored (eg. make a 30min on 30min off cycle)
#define HYDROPONIC_MODE -3
//plant uses cooldown and duration and workhours, moisture is measured but ignored
#define TIMER_ONLY -4
typedef struct PlantSettings_t
{

View File

@ -75,6 +75,12 @@ public:
return SENSOR_STRING[mode];
}
bool isTimerOnly()
{
long current = this->mSetting->pSensorDry->get();
return equalish(current, TIMER_ONLY);
}
bool isHydroponic()
{
long current = this->mSetting->pSensorDry->get();
@ -94,7 +100,7 @@ public:
*/
bool isPumpRequired()
{
if (isHydroponic())
if (isHydroponic() || isTimerOnly())
{
// hydroponic only uses timer based controll
return true;

View File

@ -15,11 +15,11 @@ framework = arduino
build_flags = -DPIO_FRAMEWORK_ARDUINO_LWIP2_LOW_MEMORY
-DPLANT0_SENSORTYPE=ANALOG_RESISTANCE_PROBE
-DPLANT1_SENSORTYPE=ANALOG_RESISTANCE_PROBE
-DPLANT2_SENSORTYPE=CAPACITIVE_FREQUENCY
-DPLANT3_SENSORTYPE=CAPACITIVE_FREQUENCY
-DPLANT4_SENSORTYPE=CAPACITIVE_FREQUENCY
-DPLANT5_SENSORTYPE=CAPACITIVE_FREQUENCY
-DPLANT6_SENSORTYPE=CAPACITIVE_FREQUENCY
-DPLANT2_SENSORTYPE=ANALOG_RESISTANCE_PROBE
-DPLANT3_SENSORTYPE=ANALOG_RESISTANCE_PROBE
-DPLANT4_SENSORTYPE=ANALOG_RESISTANCE_PROBE
-DPLANT5_SENSORTYPE=ANALOG_RESISTANCE_PROBE
-DPLANT6_SENSORTYPE=ANALOG_RESISTANCE_PROBE
board_build.partitions = defaultWithSmallerSpiffs.csv

View File

@ -31,7 +31,7 @@ void Plant::init(void)
/* Initialize Home Settings validator */
this->mSetting->pSensorDry->setDefaultValue(DEACTIVATED_PLANT);
this->mSetting->pSensorDry->setValidator([](long candidate)
{ return (((candidate >= 0.0) && (candidate <= 100.0)) || equalish(candidate, DEACTIVATED_PLANT) || equalish(candidate, HYDROPONIC_MODE)); });
{ return (((candidate >= 0.0) && (candidate <= 100.0)) || equalish(candidate, DEACTIVATED_PLANT) || equalish(candidate, HYDROPONIC_MODE) || equalish(candidate, TIMER_ONLY)); });
this->mSetting->pPumpAllowedHourRangeStart->setDefaultValue(8); // start at 8:00
this->mSetting->pPumpAllowedHourRangeStart->setValidator([](long candidate)

View File

@ -460,7 +460,7 @@ int determineNextPump(bool isLowLight)
log(LOG_LEVEL_DEBUG, String(String(i) + " No pump required: due to light"), LOG_DEBUG_CODE);
continue;
}
if (!plant.isHydroponic())
if (! (plant.isHydroponic() || plant.isTimerOnly()))
{
if (equalish(plant.getCurrentMoistureRaw(), MISSING_SENSOR))
{
@ -497,7 +497,7 @@ int determineNextPump(bool isLowLight)
}
}
if (!plant.isHydroponic())
if (! (plant.isHydroponic() || plant.isTimerOnly()))
{
consecutiveWateringPlant[i]++;
}
@ -1137,9 +1137,11 @@ bool determineTimedLightState(bool lowLight)
}
int curHour = getCurrentHour();
bool condition1 = ((hoursStart > hoursEnd) &&
(curHour >= hoursStart || curHour <= hoursEnd));
bool condition2 = /* Handle e.g. start = 8, end = 21 */
((hoursStart < hoursEnd) &&
(curHour >= hoursStart && curHour <= hoursEnd));
timedLightNode.setProperty("debug").send(String(curHour) + " " + String(hoursStart) + " " + String(hoursEnd) + " " + String(condition1) + " " + String(condition2));