Or maybe a solution like this? :
Add an ESP with a relay that control poweron/off of the MAIN valve with an internal countdown
when HA execute the script to open valve n1 for 30 minutes (example) , the script also set the ESP to poweron to ensure main valve is open. And ESP start with an internal countdown from 35 minutes (30minutes for irrigation set before and 5minutes - for example - for safetly purpose)…then HA close the valve n1 and open another valve n2. The script to open the new valve n2 reset the ESP countdown to 35mins again…in the case HA stop working at this point, ESP countdown until get to 0…if this appened, the system is in “fault mode” so ESP can poweroff master valve!
I think it can be a good solution to stay on HA… adding only an independent hardware to control the power of main valve with a internal countdown that reset on every mqtt command from HA. If the mqtt command to close a valve is not sent before countdown go to 0, ESP can poweroff the system by it self
So @klogg code, can be only update with an input_boolean named for example ENABLE_SAFETY_ESP_POWEROFF_IRRIGATION… If true, every script that open the valve set the countdown ,passing the duration of the irrigation + some minutes (like 5). If false, set internal variable of the ESP to disable doing his job!
This is my idea to use an ESP with sonoff 4ch and HA… But i don’t know if ESP is necessary or we. An set a internal countdown inside sonoff 4ch??