Parallel, restart, queued

I noticed that when I restart HA (ex. after update of an integration) a running automation stopped.
Can this be prevented by changing the mode (single, parrarel, etc) of the automation, or is there another way ?

No all automations stop when you restart.

You should be designing state driven automations that do not linger in delays or loops.

One of these states can be a homeassistant start event if need be.

1 Like

Thanks !!!
This particular automation is a wake-up routine that is triggered by a whole day calendar event in my Google Calendar, with an off-set of 6 hours (meaning it runs at 6 am).
I assume (d) that the calendar event is State driven and but if I would change the time offset for a Time Condition, it would still stop the automation after a restart ?
Is there another way ?

Automations will always be stopped.
There are ways to start them again, but it requires some extra steps and especially if it should not just be started from the beginning.

The only way your automation won’t trigger is if HA is offline at exactly 6am.

Thanks @WallyR and @Tom_I.
I could break up the Automation in several at different times but I think is easiest for me to just not restart HA while the wake-up automation is running.

How long does your automation take to run its actions?

About one hour. It turns on several lights at different times, opens curtains and also runs Alexa announcements at different times. Then turns the lights off.

Remember when I said:

Split your automation up into separate automations that run at each time. You can use the calendar trigger with different offsets for each automation if needed.

That way you have very little chance of interrupting an automation. It triggers and runs the actions very quickly.

Yes, that would be a possibility. Alternatively (as I of course never restart HA at the trigger time, just waking up) I could have the wake-up automation trigger other automations that run after set number of minutes. The advantage being that there would be no need to change more than one automation when the wake-up time changes.

It is recommended automation design practice. Do not delay for long periods of time in the automation actions.

3 Likes

Post your automation (as formatted YAML) and we can show you how to make it more resistant to restarts.

It actually runs a script:

alias: "#   Wake-up Mini 6:44  am No TV"
description: ""
triggers:
  - event: start
    offset: "6:44:0"
    entity_id: calendar.11_mini_working
    trigger: calendar
conditions: []
actions:
  - data: {}
    action: script.and_mini_wake_up_script_no_tv
mode: single

I am about to go into a meeting and if I need to post the actual script, then I’ll do that a bit later.

Thanks for your assistance

Sorry to side-track this slightly, but is there a similar option in ESPHome when running unscheduled actions which have long delays?

  - id: heating_downstairs_1hr
    mode: restart
    then:
      - if:
          condition:
            lambda: |-
              return id(heating_global_enable) = true || id(heating_downstairs_enable) == true;
          then:
            - switch.turn_on: brb_ds_direct
            - delay: 60 min
            - switch.turn_off: brb_ds_direct

Ideally I’d like to perform a callback of some type, but is there a way to do that better in ESPHome?

Sounds like you are doing it wrong, with something like a trigger fires at 00:00 but then runs a delay for 6 hours. Replace your trigger with one that does not actually fire until 06:00 instead, probably a template trigger if you must use an all-day calendar event.

A good point, though I never have had any issue with the 6 hour delay.
I have not figured out yet how to use specific time event from my Google calendar. Only whole day events show in my HA as entities. I also have not yet figured out how to use Templates.

Unfortunately for the time being ESPHome is foreign to me. I have seen it mentioned many times, but know nothing about it (yet).