I have a couple of instances where an automation might be in a running state (repeat, delay, wait etc) and I need to stop the automation from running. The only way to accomplish this right now as far as I’m aware is to turn the automation off then turn it back on.
Is there a way, or could there be a way to stop an automation run without turning it off and then back on?
Reload is the only other way to do it. It’s actually stopping and restarting but with a single service call (and not just one but all automations).
If the goal is to find a service call to stop a single running automation without calling the automation.turn_off service, it doesn’t exist (based on the documentation).
I actually did consider this, but it seems like a bit of a “workaround” to me. I really think there needs to be an automation.stop service for these situations. But I guess this will work for now. Thanks for the suggestion.
I agree that using a script is a workaround. Your question was how to stop a running automation (without turning it off) and the answer isn’t “Don’t use an automation, use a script.” Fact is, there is no way to do what you want with an automation.
Now comes the thorny part: we get a consistency problem if automation.stop is implemented.
To stop a running script (without disabling it), call script.turn_off
To stop a running automation (without disabling it), call automation.turn_offautomation.stop
The two are closely related yet will have different terms for stopping their execution. Ideally, script.turn_off would disable the script, just like automation.turn_off disables an automation. However, it doesn’t; there’s no concept of disabling a script, only to stop a running script.
Not sure if there’s way to create consistency without a breaking change.
Also for reference and previously related discussion, see:
EDIT: I can’t find where it was discussed right now, but the other thing to consider about an automation.stop service is, why are you calling it? More importantly, why would you call it and not also want to prevent the automation from running again?
Here’s the scenario. Some script or whatever decides it needs to stop a running automation. So it calls a (theoretical) automation.stop service. But immediately after it does that the automation is triggered again, and so it’s running again. The script or whatever continues with the assumption that the automation isn’t running, but it is.
So, what is the purpose / use case for stopping an automation, but not also disabling its triggers?
I simply turn the automation off, then after a short delay turn it back on. Simply ends it and resets it, ready for it to triggger again. This is this for my pending alarm warning automation.
Not sure if this is helpful, but since there isn’t a direct way of telling an automation to stop executing, and I’m not sure about the implications of turning it off and on again, this is what I’ve been doing to address the scenario:
Create a boolean helper
Set it to true when I’m starting execution
When the time comes to decide if I need to proceed, check that the helper boolean is still true.
This gives me the opportunity to turn that boolean off externally where needed, and it also gives me full control of the original script, so that it can continue to run and do some things, while not doing some other things as per my choosing (e.g. when no motion detected, turn off ac conditionally, but always turn off lights).