Abort a running sequence

Is there a way to stop a running script or automation? For instance if I have an automation that does

  1. do A
  2. delay 10s
  3. do B

Can I stop the sequence during the delay in some easy way? I know I can do this if I move the automation to appdaemon, but I would prefer not to at the moment.

I hope that I have overlooked something, but I can only think of one way to do it but it’s not pretty…and that is keeping ‘do B’ in a second automation that uses some input_booleans for conditions and triggers, and trigger the second automation from the first.

# Pseudocode
    name: boolB
    name stopbool

  - alias: autoA
    trigger: <whatever>
      - (do stuff A)
      - delay: '00:00:10'
      - set boolB to 'on'

  - alias: autoB
    trigger: <state of boolB set to 'on'>
      <stopB is 'off'>
      - (do stuff B)

You can use homeassistant.turn_off


Ah nice, I didn’t think it would work that way with scripts. On automations it only disables the trigger without stopping the running sequence.

Guess I’ll call a script from the automation if I need to be able to stop it half-way through.

Thanks for the help!

You might try adding an Input Boolean condition to the actions and use it to shut off the automation.

No, conditions can only be used to decede wether or not the automation will run at all. You cannot stop it by changing that condition while the automation is running. But you can use the automation to run a script, and instead stop that script using homeassistant.turn_off, like @Danielhiversen described.

will it work the same for automation as well?
in my case i have a sequence running as action in automation, will i be able to stop this sequence by using the following or it will just make my automation state to off:

- service: homeassistant.turn_off
  entity_id: automation.blah

ever figured this out?
i also want to create an automation
action 1 , delay 30 sec , action 2
but for some reason, i want to stop the automation if needed in the delay timer

if i turn_off the automation, will it stop the sequence if it was actually running? if yes
then i can do turn_off and and turn_on again afterwards, so the initital state is ON again for the next automation …

make an automation firing the script/sequence. than you can stop the script itself…

1 Like

Can I make a switch to stop an automation? I had this, but the switch doesn’t appear in HA.

 - platform: template
        value_template: "{{ is_state('automation.alarm_niemand_thuis', 'on') }}"
          service: automation.turn_off
            entity_id: automation.alarm_niemand_thuis
          service: automation.turn_off
            entity_id: automation.alarm_niemand_thuis