Good Evening, I have made automation for my unifi protect doorbell, when motion is detected it sends an announcement to amazon Alexa. The only issue I am having is that the automation is triggering multiply times. Alexa says “someone is at the front door” three times on one person at the front door. Is there a way to set a delay from the first time it triggers to the next time it triggers? Here is my current code.
alias: Someone is at the front door
description: ''
trigger:
- platform: state
entity_id: binary_sensor.motion_1_doorbell
for:
hours: 0
minutes: 0
seconds: 0
condition:
- condition: trigger
id: ''
action:
- service: notify.alexa_media_dinning_rm_echo_dot
data:
message: Someone is at the front door.
target: notify.alexa_media_dinning_rm_echo_dot
data:
type: tts
mode: single
I’d add a delay at the end for 1 minute, so that the automation doesn’t end immediately add max_exceeded: silent under mode so that it won’t spam the log with warnings that the automation is already running.
as a condition (template) of the automation, replace my_automation_name with the actual name of the your automation, and 60 with the number of seconds you want to delay the automation for. This will prevent the automation from running, if the time it was last triggered is LESS than the number of seconds you replace 60 with.
This method makes more sense than adding a delay at the end if you have long wait times (hours or more). This way the automation isn’t left running the entire time and isn’t affected by HA restarts. You can also do more complicated things with the code like “only run once per day”.