What’s the best practice to manage a not critical operation?
I’m undecided between
Solution 1:
pseudo code
automation A:
action: start timer.my_timer
automation B:
trigger: timer.my_timer started
action: turn on light
automation C:
trigger: timer.my_timer finished
action: turn off light
and the much simpler to maintain solution 2:
pseudo code
automation A:
action: turn on light
delay
action: turn off light
Solution 1 has the pro that different automations can trigger the timer, so automation B acts like a function, and the timer can be “HA restart” persistent (i.e the timer can finish after the restar). Moreover, if you need to make sure that you turn off light in case of restart or automation reload,
you can add the triggers to automation C and manage it.
trigger:
- platform: homeassistant
event: shutdown
id: HA restart
- platform: event
event_type: automation_reloaded
id: Automation reload
Solution 2 is much simpler, but it’s not “HA restart” persistent, because delay doesn’t survive to the restart. You can still manage a “failover” creating a new automation to stop mission critical entities upon restart or automation reload.
What do you think about this? Am I missing something?
