Automations - Don't run if ran in last xxx sec/min/hrs/days

It would be nice to have an option to not run an automation if it ran in the last xxx sec/min/hours/days etc or set a max number of occurrences ran in a time period

In the meantime you can do this with an input_boolean. I use one to keep track of if my Roomba have vacuumed today, so that it doesn’t run again every hour since I have an automation that checks if we are home every hour, and as soon as we are not at home it runs and then sets input_boolean.vacuumed_today to on. I have another automation that sets the input_boolean back to off at midnight.
But it would be nice to be able to set an automation attribute to “run once a day” or something like that.

1 Like

If you feel like looking into programming, I really can recommend AppDaemon.
I have a small fountain that turns on for 20 minutes when I have been on my porch for one minute. After that it will be in “cool down” mode for two hours before being armed and once again react to me entering the porch. All this also fenced in time to only run between noon and eight in the evening. Including a button used to start the “timer” manually, this took about 60 lines of Python code…
http://appdaemon.readthedocs.io/en/latest/

Thanks @Phudeot. Ideally a one liner in the automation condition is what I’m looking for.

I’m currently running DomotiGa which has this feature built-in and I use it for quite a few automations.
I could always add scripts left, right and center to achieve what I’m looking for, but right now I’m trying to simplify things :wink:
The ultimate goal would be to replace DomotiGa altogether as it doesn’t have such a big community as HA and as a result doesn’t get updated very often (last major update was probably close to 12 months ago)

Anyway thanks for the tip

by the way I found a solution, in case that helps someone else.
This will ensure the automation doesn’t run again if it ran in the last xx sec

  condition:
    condition: template
    value_template: '{{ as_timestamp(now()) - as_timestamp(states.automation.automation_name.attributes.last_triggered) | int > xx }}'
3 Likes