Automation stop running instances

There is a service called automation.turn_off, that completely disable the automation. (I would have called it rather automation.disable)
Could we get a service that would just stop all running instances of a chosen automation without disabling the automation?
There are many cases when we might want to stop another running automation, based on another automation.

It is really only when you are using the delays that you have a chance to stop an automation.
Without a delay built in the automations run in milliseconds.
If you need to stop the running instances that have delays, then make a delay with that option.

Make a counter in a number helper.
Break the delay up, so it only is a fraction, then have it check for an abortion value, like a boolean helper.
If it the abortion value is not set, increase counter and then repeat delay, unless counter have reached the value where it is equal to the total delay you want.

I don’t think this is quite right. According to the docs, it “disables the automation’s triggers, and optionally stops any currently active actions”. For example:

  - if:
      - condition: numeric_state
        entity_id: automation.keypad_armed
        above: 0
        attribute: current
    then:
      - service: automation.turn_off
        data:
          stop_actions: true
        target:
          entity_id:
            - automation.keypad_armed

(If the automation is running, the attribute current will be >= 1.)

You can then turn it back on again…

service: automation.turn_on
data: {}
target:
  entity_id:
    - automation.keypad_armed

…and it will run on the next trigger.

Hello Stiltjack… In face in my case (I use the visual automation editor), each time I run this automation.turn_off, it disactivate the automation :frowning: Yes, I could possible reactive it after… but it would have been easier to just stop it (for running instances…)

Thanks WallyR, I’ll give it a try, even if I find it a bit more complex than just calling a service! :slight_smile:

In that case, what happens if it’s triggered again immediately? This is quite possible in, say, an automation triggered by a light or temperature threshold, where the sensor may hover around the critical level for several minutes.

Turning it off, then turning it on again later allows the user some control over what happens in the meantime.