I have created an automation to open my garage door with a zigbee keypad when I “arm” the system and close it when I “disarm” the system. I want to send myself a notification if the wrong keycode is entered five times. I can only see the passcode entered through events. is there a way to look for a wrong keycode. I’m guessing I could use a counter to get the number of wrong keycodes I am looking for but how do I check for the wrong passcode?
What does the events look like?
I assume you could use event trigger.
Action is two choose one template if passcode is not correct and one of correct.
One increase a counter the other resets.
event_type: zha_event
data:
device_ieee: 00:0d:6f:00:0c:3e:d2:d7
unique_id: 00:0d:6f:00:0c:3e:d2:d7:1:0x0501
device_id: 4f41d799ba05d2bcbdaa1e85436c13f4
endpoint_id: 1
cluster_id: 1281
command: arm
args:
arm_mode: 0
arm_mode_description: Disarm
code: "4646"
zone_id: 0
I just dont know the format for trigger.event.data mentioned here:
Try a choose with template in actions
{{ trigger.event.data.args.code == "4646" }}
And just do a tts or something as the action to test it.
And the trigger should be
platform: event
event_type: zha_event
event_data:
device_ieee: 00:0d:6f:00:0c:3e:d2:d7
unique_id: 00:0d:6f:00:0c:3e:d2:d7:1:0x0501
device_id: 4f41d799ba05d2bcbdaa1e85436c13f4
endpoint_id: 1
cluster_id: 1281
You can probably remove the two last lines also but I’m not sure how it works
I get this when I use that template -
Error occurred while testing condition
In ‘template’ condition: UndefinedError: ‘trigger’ is undefined
any ideas? thank you for your help so far
You need to show the automation
alias: Centralite Keypad - Tell me when wrong passcode
description: send me a notification when the passcode to open the garage door is incorrect
trigger:
- platform: event
event_type: zha_event
event_data:
platform: event
event_type: zha_event
event_data:
device_ieee: 00:0d:6f:00:0c:3e:d2:d7
unique_id: 00:0d:6f:00:0c:3e:d2:d7:1:0x0501
device_id: 4f41d799ba05d2bcbdaa1e85436c13f4
endpoint_id: 1
cluster_id: 1281
condition: []
action:
- choose:
- conditions:
- condition: template
value_template: "{{ trigger.event.data.args.code == \"4646\" }}"
sequence: []
mode: single
I tested just the template and I get that error
You have duplicated your trigger.
alias: Centralite Keypad - Tell me when wrong passcode
description: send me a notification when the passcode to open the garage door is incorrect
trigger:
- platform: event
event_type: zha_event
event_data:
device_ieee: 00:0d:6f:00:0c:3e:d2:d7
unique_id: 00:0d:6f:00:0c:3e:d2:d7:1:0x0501
device_id: 4f41d799ba05d2bcbdaa1e85436c13f4
endpoint_id: 1
cluster_id: 1281
condition: []
action:
- choose:
- conditions:
- condition: template
value_template: "{{ trigger.event.data.args.code == \"4646\" }}"
sequence: []
mode: single
ok I have your code in there and it works. thank you for clearing that up. I really appreciate it.