I have a very simple NodeMCUv1 and 4 relays circuit to send 24v to solenoid valves for irrigation. In order to use it from HA, i used ESPHome. It works well, aside from the fact that sometimes ESPHome loses WiFi connection. The thing is, it is outside of the house in an IP67 box, and it connects to WiFi weakly. Some days it never disconnects, and some other days it disconnects and connects back again several times (every 2-3 minutes) for some hours.
Lately i realized if this WiFi loss happens in the middle of an irrigation schedule (When the valve is open and watering the garden), it doesn’t stop. I waited for some minutes but since it doesn’t reconnect in some minutes i simply pull the power plug of esphome and it shut down the valves as per “Default Off” setting. So, i have two questions:
I use HA_Scheduler or Scheduler Card for Irrigation Schedules. Let’s say it started watering starts on 10:00 and will end at 10:05. However, let’s suppose the Wifi of esphome went off on 10:03 and came back on 10:10. I know that the switch of the valve will not close down on 10:05 since it lost connection. Does that mean when the connection comes back on 10:10 the system will shut down the valve switch or because it simply missed the switch_off command on 10:05 it will continue watering?
How can i add a default max_time window for the relay switch to stay on? So, even the disconnected esphome misses to get the HA switch_off command, it can simply shut down the valve relay switch on a max of 15 minutes locally (The maximum amount of any valve switch that can stay ON is 15 minutes)?
Btw, here is my simple current esphome yaml:
esphome: name: esp_sprinkler platform: ESP8266 board: nodemcuv2 wifi: ssid: "XXXXXXXX" password: "XXXXXXX" # Enable fallback hotspot (captive portal) in case wifi connection fails ap: ssid: "Sprinkler Fallback Hotspot" password: "XXXXXXX" captive_portal: # Enable logging logger: # Enable Home Assistant API api: ota: web_server: port: 80 switch: - platform: gpio name: "Relay_1" pin: D1 inverted: True restore_mode: RESTORE_DEFAULT_OFF - platform: gpio name: "Relay_2" pin: D2 inverted: True restore_mode: RESTORE_DEFAULT_OFF - platform: gpio name: "Relay_3" pin: D6 inverted: True restore_mode: RESTORE_DEFAULT_OFF - platform: gpio name: "Relay_4" pin: D7 inverted: True restore_mode: RESTORE_DEFAULT_OFF