prevent light from being reenabled untill next day after low voltage trigger

This commit is contained in:
Your Name 2021-09-14 18:54:14 +02:00
parent 88e4ceea8b
commit f13a25b34d
2 changed files with 5 additions and 2 deletions

View File

@ -82,7 +82,7 @@
/** \addtogroup Configuration /** \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 #define TIMED_LIGHT_PIN CUSTOM1_PIN5

View File

@ -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 */ RTC_DATA_ATTR long lastWaterValue = 0; /**< to calculate the used water per plant */
#if defined(TIMED_LIGHT_PIN) #if defined(TIMED_LIGHT_PIN)
RTC_DATA_ATTR bool timedLightOn = false; /**< allow fast recovery after poweron */ 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 #endif // TIMED_LIGHT_PIN
@ -987,6 +988,7 @@ bool determineTimedLightState(bool lowLight){
} }
if(onlyAllowedWhenDark && !lowLight){ if(onlyAllowedWhenDark && !lowLight){
timedLightNode.setProperty("state").send(String("Off, not dark")); timedLightNode.setProperty("state").send(String("Off, not dark"));
timedLightLowVoltageTriggered = false;
return false; return false;
} }
@ -996,11 +998,12 @@ bool determineTimedLightState(bool lowLight){
((hoursStart < hoursEnd) && ((hoursStart < hoursEnd) &&
(getCurrentHour() >= hoursStart && getCurrentHour() <= 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")); timedLightNode.setProperty("state").send(String("On"));
return true; return true;
}else { }else {
timedLightNode.setProperty("state").send(String("Off, due to missing voltage")); timedLightNode.setProperty("state").send(String("Off, due to missing voltage"));
timedLightLowVoltageTriggered = true;
return false; return false;
} }