So I am using a Wyze door sensor to track when a key is picked up and replaced on the hook. This works great except I have unnecessary repeat events when people are fiddling with the key in order to get it to sit right.
So im trying to put a condition in to say that if the key has been off the hook in the last 1 minute, then dont fire the automation.
I wrote what I think would work but now the automation doesn’t fire at all reguardless of how long it takes.
Any ideas?
- alias: Voice command for when gate tag box is opened.
initial_state: true
hide_entity: false
trigger:
platform: state
entity_id: binary_sensor.wyzesense_778be928
from: 'off'
to: 'on'
condition:
condition: state
entity_id: binary_sensor.wyzesense_778be928
state: 'off'
for:
minutes: 1
action:
- service: tts.google_translate_say
entity_id: media_player.security_office_speaker
data:
message: 'State why the entrance gate tag is being used.'
The trigger requires the binary_sensor to change from off to on.
The condition requires the binary_sensor to be off for at least a minute.
The trigger wants on whereas the condition wants off. This will never happen
Try this:
- alias: Voice command for when gate tag box is opened.
trigger:
platform: state
entity_id: binary_sensor.wyzesense_778be928
from: 'off'
to: 'on'
for:
minutes: 1
action:
- service: tts.google_translate_say
entity_id: media_player.security_office_speaker
data:
message: 'State why the entrance gate tag is being used.'
The assumption I’ve made is when the key is on the hook the binary_sensor indicates on. It must be ‘on the hook’ for a solid minute before the action is performed.
So if someone puts the key on the hook for a moment then jostles it so the binary_sensor reports on then off then on, etc, none of that will cause the trigger to fire. The key has to sit undisturbed on the hook for a full minute to cause the trigger to fire.
You can probably reduce the for from 1 minute to something less like 15 seconds.
Naah, key on hook is an ‘off’ with a waze door sensor. Notification need to be instant. I could also do it by triggering a timer that flicks a boolean switch, just seems overly complicated.
Fine. Change the State Trigger accordingly and set for to a few seconds, just enough to “debounce” the on-hook activity.
- alias: Voice command for when gate tag box is opened.
trigger:
platform: state
entity_id: binary_sensor.wyzesense_778be928
from: 'on'
to: 'off'
for: '00:00:03'
action:
- service: tts.google_translate_say
entity_id: media_player.security_office_speaker
data:
message: 'State why the entrance gate tag is being used.'