From f13a25b34da6d52559e4a66131032645293ec82e Mon Sep 17 00:00:00 2001 From: Your Name Date: Tue, 14 Sep 2021 18:54:14 +0200 Subject: [PATCH] prevent light from being reenabled untill next day after low voltage trigger --- esp32/include/ControllerConfiguration.h | 2 +- esp32/src/main.cpp | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/esp32/include/ControllerConfiguration.h b/esp32/include/ControllerConfiguration.h index f279d09..3465ba3 100644 --- a/esp32/include/ControllerConfiguration.h +++ b/esp32/include/ControllerConfiguration.h @@ -82,7 +82,7 @@ /** \addtogroup Configuration * @{ */ -#define FIRMWARE_VERSION "sw 1.3 hw 0.10" +#define FIRMWARE_VERSION "sw 1.4 hw 0.10" #define TIMED_LIGHT_PIN CUSTOM1_PIN5 diff --git a/esp32/src/main.cpp b/esp32/src/main.cpp index 2f2a4f3..42171b9 100644 --- a/esp32/src/main.cpp +++ b/esp32/src/main.cpp @@ -70,6 +70,7 @@ RTC_DATA_ATTR int lastPumpRunning = -1; /**< store last successfully waterd plan RTC_DATA_ATTR long lastWaterValue = 0; /**< to calculate the used water per plant */ #if defined(TIMED_LIGHT_PIN) RTC_DATA_ATTR bool timedLightOn = false; /**< allow fast recovery after poweron */ + RTC_DATA_ATTR bool timedLightLowVoltageTriggered = false; /**remember if it was shut down due to voltage level */ #endif // TIMED_LIGHT_PIN @@ -987,6 +988,7 @@ bool determineTimedLightState(bool lowLight){ } if(onlyAllowedWhenDark && !lowLight){ timedLightNode.setProperty("state").send(String("Off, not dark")); + timedLightLowVoltageTriggered = false; return false; } @@ -996,11 +998,12 @@ bool determineTimedLightState(bool lowLight){ ((hoursStart < hoursEnd) && (getCurrentHour() >= hoursStart && getCurrentHour() <= hoursEnd))) { - if(battery.getVoltage(BATTSENSOR_INDEX_BATTERY) >= timedLightVoltageCutoff.get() ){ + if(!timedLightLowVoltageTriggered && battery.getVoltage(BATTSENSOR_INDEX_BATTERY) >= timedLightVoltageCutoff.get() ){ timedLightNode.setProperty("state").send(String("On")); return true; }else { timedLightNode.setProperty("state").send(String("Off, due to missing voltage")); + timedLightLowVoltageTriggered = true; return false; }