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)?
It has default timeouts which is stored locally and can be changed with a HA service call. I have to modify it though since i do not have a display and handle the schedules with schedule card.
Btw, using Static IP in yaml decreased the “unavailable WiFi” duration from 1-2 minutes to 1 second only. That looks like a progress on my side. I also used “interlock” on the switches, so only one relay can be ON at a time out of 4 relays and that is handled locally on the esphome (That is needed because of water pressure is enough only for one zone at a time). More details on: Interlocking
I created a service in esphome to turn on the switch and run the failsafe timer. I call the service from HA instead of manipulating the switch. For interlocking, my sprinklers have NO and NC contacts with a common terminal so I interlock with the wiring. Providing the hot to the next output common from the previous output NC. Many output maybe on but only one gets power,
What a brilliant idea to handle interlocking on hardware, thanks for that solution. Is it possible for you to post yaml regarding the failsafe timer and the service? Thanks…
So, each relay has its own default max time set in “globals:” part where time1=remaining_time1 and so on.
If do not set any time and switch the relay on, it counts up to the default max time and switches itself off. If i want to change the time, in HA i use this service:
I haven’t tried it yet; i will upload this to esp and see how it goes on…
UPDATE: Works pretty well. You can either use switch off manually from HA anytime you like (Lower time than max timeout obviously), otherwise it will locally count up to the hardcoded timeout and switches itself off. If you change the set_time with HA service than this new time is permanent (up until esp reboot maybe?) Anyhow this looks like it solves my problem. The tolerance of max timeout is -+5 seconds since it counts in 5 sec intervals.