Call Service: automation.pause

Good day Community,

Wondering if a new Call Service to prevent an automation from running for a given amount of time can be easily implemented. Example:

service: automation.pause
data: {}
target:
  entity_id: automation.test
  for:
    hours: 0
    minutes: 30
    seconds: 0

See here for a good use case:

Thanks all!

An easy solution to this was provided by sparkydave. Did you try it?

Hi @tom_l, I posted this one before I saw @sparkydave’s reply. I’m not quite sure it will work but I did just post a response to his and seeing what they might suggest.

Another option… In the last steps of the sequence that detects that you manually changed it, instead of calling “automation.pause”, couldn’t you turn off the automation, perform a 20 minute delay, then turn the automation back on?

That’s fraught with danger. The automation never gets tuned back on if you restart while in the delay. Timers can be restored, with a bit of jiggery-pokery. And if you don’t go to the trouble of doing that then the timer is idle and the condition passes.

Ah, yes. I completely ignored the restart scenario.

With 2022.4, Timers “can now restore/survive their state across restarts”. Wondering if this feature request makes more sense now.

Conditions are still the recommended way of preventing an automation from running.

Just add this as a condition and you’ve got a rate limited automation:

condition: "{{ this.attributes.last_triggered < now() - timedelta(minutes=20) }}"

Change the timedelta according to your use case. With this template the automation will only trigger once every 20 minutes.

Last triggered survives restarts too so you don’t have to worry about timers or anything. Or trying to figure out how your automation got paused by looking at a bunch of different traces.

1 Like

Hello,
where and how exactly do I have to enter this as a condition? As Template?

Thx

Here in the documentation you will find all explained.

1 Like