Is it possible to resume automations upon restart?

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?

Thanks!

Welcome to the community :partying_face:

Short answer: Not really.

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.

1 Like

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!

No worries.

I should have posted some links. The example in the docs for trigger ID’s is junk compared to what they put in the blog post when that feature came out.

The choose function isn’t the easiest to find in the docs either.

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.

Not necessary. A single automation with two triggers will achieve this without it becoming a ‘long running’ automation.

trigger 1- ID:sunrise
trigger 2 - ID:sunset
action: trigger was sunrise ID, turn light off, or if sunset ID turn light on

(i couldn’t be bothered writing it in proper code, you get the picture)

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 :smiley:

3 Likes