I just configured an automation which turns on the watering, then waits with a delay for 5 minutes and afterwards, turns off the water.
Everything works fine, but I’m thinking in the following, what happens if I restart homeassistant when the delay is running?? The water will remain open until the next trigger, am I right?! How can I avoid this situation? Thanks
Yes, you’re right. The same thing will happen when you Reload Automations.
Avoiding this issue requires a substitute for delay. Here’s one method using a dynamic Time Trigger:
When your automation is triggered, it sets the value of an input_datetime to “now + 5 minutes”.
The same automation employs a Time Trigger that uses the input_datetime. When triggered, it turns off the watering switch.
If Home Assistant is restarted during the 5 minute period, the Time Trigger is unaffected and will trigger at the time indicated by the input_datetime.
Let me know if you need help creating this automation.
As an alternative, you can simply use an automation to turn off the switch moments before shutdown (or on startup, it’s your choice).
I overlooked to mention that I use a timer (instead of delay) for controlling watering duration. Active timers are unaffected by Reload Automations but they are reset by restarting Home Assistant. However, I created a system that saves/restores active timers so they continue to operate after a restart.