In automation below, I have the issue that my trigger entity jumps from off to on, multiple times (because the person walking to the front-door needs to walk 5s :-))
How can I make sure that my automation runs only once after entity trigger ?
There are various ways to throttle an automation. For short throttle durations in automations that use single mode, you can usually just add a delay to the end of the automation’s action sequence. For longer throttle durations, you can use a condition that checks how long it has been since the automation last executed its actions:
- alias: Prevent automation from running more than once per hour
condition: template
value_template: |
{{ this.attributes.last_triggered | default(as_datetime(0), 1) < now() - timedelta(hours=1) }}
In addition to Didgeridrew’s advice, you may also wish to consider specifying the exact state-change that should trigger the automation. Currently, your State Trigger is configured to trigger for any state-change (and for changes in the binary_sensor’s attributes, if any).
triggers:
- trigger: state
entity_id:
- binary_sensor.g4_pro_person_detected
from: 'off'
to: 'on'