I have several long-running automations and was wondering if it’s possible to have them pick up where they left off upon a restart of the server. For instance, if an automations turns some lights on at sunset and off at sunrise, can I reboot the server overnight without interrupting this automation? Obviously, with a simple automation like this I can split it up, but I have some other more complex automations that I would like to automatically resume. Is there a secret to accomplishing this with HA?
Longer answer: You could use the HA start trigger in automations to get them to re-check a bunch of conditions and essentially get back to where they were but it’s going to get messy.
As for the example you give though, those could be two triggers of the same automation and therefore wouldn’t need to do any ‘resuming’ from a previous state anyway. They don’t need to be two automations. The old HA docs had examples of turning lights on with one automation, and off with another but it’s very easy to combine these tasks, especially with automation tools that have been introduced in recent times such as trigger ID’s and the choose: function.
Awesome, thanks for the tip about trigger IDs and the warm welcome! I’m new to HA, migrating from an ISY that I’ve been using for 10+ years. I continue to be blown away with how simple it is to get things done with HA and how many off-the-shelf integrations exist. These are exciting times!
Long running automations will also give you problems any time you edit one, since they’ll all reload then.
It’s better to not do that, and instead have multiple shorter automations. In your example, that’s one to turn them on at sunset, and another to turn them off at sunrise.
For the more complex ones if you explain your goals I’m sure people can help you.
Sure, but I also like to apply the KISS principle - there’s rarely a functional reason to merge multiple automations that do different things for different triggers.
If I’m going to merge automations it’s because either the starting point, or the ending point, is the same.
Otherwise you could just write a single automation that’s a wall of choose