This is an automated archive made by the Lemmit Bot.
The original was posted on /r/homeassistant by /u/tobboss1337 on 2025-05-08 11:39:28+00:00.
I have a rock solid solution without helpers, multiple automation or any other complexity for ensuring that an automation may only one once a day even if the trigger conditions occur multiple times. I proposed it as a solution to another user's question and was irritated that it seems to be common to build complex helpers and additional automations to reset helpers. I received much positive feedback so I decided to dedicate an own post for it.
This solution is used for my automated window shutters which are triggered by sunrise or a specific time but only the first occurence shall execute the automation. Another example would be to trigger something on the first motion detector of many but not on each.
How it works
It makes sure the automation can only run once a day. You can just use it as is here. No adaptations, no helper needed. In the GUI add a template condition under conditions and paste this line and you are done:
{{ this.attributes.last_triggered is none or this.attributes.last_triggered < today_at() }}
this
refers to the automation itself and the last_triggered
attribute is checked.today_at()
equals midnight, the beginning of the actual day. The none
clause is a little addition for the edge case of a fresh automation that never ran before, so that you won't have to trigger it by hand for the first time to not throw an error.
When you are preferring not to use the GUI but YAML, this would be the code for the condition:
condition:
- condition: template
value_template: >
{{ this.attributes.last_triggered is none or this.attributes.last_triggered < today_at() }}
If you just want to block it for some hours after the last event you can check whether now()
minus the last trigger time has a certain delta of for example 2 hours (7200s).
{{ this.attributes.last_triggered is none or (now() - this.attributes.last_triggered).total_seconds() > 7200 }}
I hope this will help some of you who didn't know this solution yet! Have fun!
EDIT: Addition from the comments: This solution also survives HA restarts
EDIT2: My application example may be not the best. There is a lot more motivation and potential from ideas in the comments for other "only on first of multiple events" use cases.