I have an automation setup, and there are two triggers that effectively do the same thing. Thing is, sometimes one sensor triggers, other times the other sensor triggers first, it all depends on how quick the cloud service is responding. I want either one to trigger the automation, but I do not want the automation to trigger more than once in a period of 5 minutes, give or take. How can I accomplish this so that the below automation will still in essence work, but that it won’t trigger more than once?
alias: Garage Door Opened
description: ''
trigger:
- platform: state
entity_id: cover.garage_door
to: opening
- platform: state
entity_id:
- binary_sensor.garage_door
to: 'on'
condition: []
action:
- service: notify.alexa_media
data:
target: >-
media_player.echo_show_kitchen, media_player.bedroom_echo,
media_player.basement_echo
message: Garage Door Open
data:
type: announce
mode: single
The easiest way is to put a wait period after the “real” action. Because the automation is set to single mode, it won’t run more than once at the same time. So as long as the wait period is busy, a seconds trigger will be ignored.
That is why I said easiest. other that will survive reboot is to create a timer helper with the flag to on to restore it on a reboot. Start the timer as part of the action, and put in a condition that the timer should not be running.