Iâm not 100% certain that the changes here are going to work, but I think they should.
ias: SS - Lock Logging
description: Custom Keymaster Notification
trigger:
- platform: event
event_type: keymaster_lock_state_changed
event_data:
state: unlocked
variables:
sn: |-
{%- if trigger.event.data.code_slot_name == "" -%}
Manual
{%- else -%}
{{ trigger.event.data.code_slot_name }}
{%- endif -%}
verb: |-
{%- if trigger.event.data.code_slot_name == "" -%}
unlock of
{%- else -%}
unlocked
{%- endif -%}
door: |-
{%- if trigger.event.data.lockname == "front_door" -%}
Front Door
{%- elif trigger.event.data.lockname == "laundry_room" -%}
Laundry Room Door
{%- else -%}
Garage Side Door
{%- endif -%}
code_slot: trigger.event.data.code_slot
notify_state: >-
{% states("input_boolean.notify_" + trigger.event.data.lockname + "_ +
code_slot | string) %}
condition: []
action:
- data:
name: "{{ trigger.event.data.lockname }}"
entity_id: "{{ trigger.event.data.entity_id }}"
message: "{{ sn }} {{ verb }} the {{ door }}"
action: logbook.log
- if:
- condition: template
value_template: "{{ notify_state == \"on\" }}"
then:
- metadata: {}
data:
message: "{{ sn }} {{ verb }} the {{ door }}"
title: "{{ door }}"
data:
tag: "{{ door }}"
action: notify.mobile_app_ss_s24u
mode: single
Iâve added two new variables code_slot (which comes from the event data) and the state of the notify boolean.
Then in the notify action itself, Iâve wrapped it in an if statement to say only send a notification if the notify toggle is âonâ.
I have not tested this with an actual lock, but the variable setting should work and then itâs just a matter of making sure that the if logic is correct.
Yes, thatâs what I was referring to. I only did a minimal amount of testing in the dev tools template tester to figure out some of the syntax there. You may need to fiddle around with it some to figure out how to get that variable to be set correctly. Alternatively, you could try moving the states expression down into to the value_template section of the if condition and replace the variable check.
In any case, this should be the right direction for you to play with.
Thanks. I dont know much of this level of coding in HA but will start working to learn. Can I ask if this also has anything in it regarding the showing of only when a lock has its code entered (vs a manual unlock from inside of the home)? Thanks again for all the help
No, I didnât include anything to not send a notification if itâs a manual unlock. But that would just be another condition in that if statement making sure that
Thanks. So I dont really know what Im doing but I messed with the syntax and think the issue was a â in the notify_state to make it stop throwing a syntax error. It didnt seem to work (in that I disabled the laundry room lock) but it was still sending me the notification. If Im understanding correctly it should be using the bottom message when the lock is enabled. I temp put a â2â in the wording to see if firing and it still using the first message line (that doesnt have the 2) so I suppose its not recognizing it as off.
Although I believe that is going to the logbook but still seems to be whats going to my phone. Hopefully that makes sense. As for the sn != âManualâ, would that go where âvalue_templateâ is? My apologies Im just winging this lol
Here was the code currently
alias: SS - Lock Logging2
description: Custom Keymaster Notification
trigger:
- platform: event
event_type: keymaster_lock_state_changed
event_data:
state: unlocked
variables:
sn: |-
{%- if trigger.event.data.code_slot_name == "" -%}
Manual
{%- else -%}
{{ trigger.event.data.code_slot_name }}
{%- endif -%}
verb: |-
{%- if trigger.event.data.code_slot_name == "" -%}
unlock of
{%- else -%}
unlocked
{%- endif -%}
door: |-
{%- if trigger.event.data.lockname == "front_door" -%}
Front Door
{%- elif trigger.event.data.lockname == "laundry_room" -%}
Laundry Room Door
{%- else -%}
Garage Side Door
{%- endif -%}
code_slot: trigger.event.data.code_slot
notify_state: >-
{{ states('input_boolean.notify_' + trigger.event.data.lockname + '_ +
code_slot | string') }}
condition: []
action:
- data:
name: "{{ trigger.event.data.lockname }}"
entity_id: "{{ trigger.event.data.entity_id }}"
message: "{{ sn }} {{ verb }} the {{ door }}"
action: logbook.log
- if:
- condition: template
value_template: "{{ notify_state == \"on\" }}"
then:
- metadata: {}
data:
message: "{{ sn }} {{ verb }} the2 {{ door }}"
title: "{{ door }}"
data:
tag: "{{ door }}"
action: notify.mobile_app_ss_s24u
mode: single
And sorry one more dumb thing, this is linked to the âLock Notificationsâ and not the Door or Garage Notifications right? (from the Lock dashboard)
Ok, Iâve re-looked at this and yes, I had a few code errors in it. Hereâs an updated version that should do what youâre wanting.
Youâll note that Iâve expanded the if condition with another condition checking on the state of the slot name not being "Manual". By default all of the conditions to an if are done as an AND conditional with HA, so by stating that the Lock Notifications setting needs to be on as well as it not being a Manual operation, should mean that you only get notifications where you want them but everything gets logged no matter what.
Again, I havenât fully tested the logic on this, but Iâm reasonably confident in this version.
alias: SS - Lock Logging
description: Custom Keymaster Notification
trigger:
- platform: event
event_type: keymaster_lock_state_changed
event_data:
state: unlocked
variables:
sn: |-
{%- if trigger.event.data.code_slot_name == "" -%}
Manual
{%- else -%}
{{ trigger.event.data.code_slot_name }}
{%- endif -%}
verb: |-
{%- if trigger.event.data.code_slot_name == "" -%}
unlock of
{%- else -%}
unlocked
{%- endif -%}
door: |-
{%- if trigger.event.data.lockname == "front_door" -%}
Front Door
{%- elif trigger.event.data.lockname == "laundry_room" -%}
Laundry Room Door
{%- else -%}
Garage Side Door
{%- endif -%}
code_slot: trigger.event.data.code_slot
notify_state: >-
{% states("input_boolean.notify_" + trigger.event.data.lockname + "_" +
code_slot | string) %}
condition: []
action:
- data:
name: "{{ trigger.event.data.lockname }}"
entity_id: "{{ trigger.event.data.entity_id }}"
message: "{{ sn }} {{ verb }} the {{ door }}"
action: logbook.log
- if:
- condition: template
value_template: "{% notify_state == \"on\" %}"
- condition: template
value_template: "{% sn != \"Manual\" %}"
then:
- metadata: {}
data:
message: "{{ sn }} {{ verb }} the {{ door }}"
title: "{{ door }}"
data:
tag: "{{ door }}"
action: notify.mobile_app_ss_s24u
mode: single
I have notifications setup. There are 3 people in my house. When I use my code to unlock the lock, the notification shows my name. When my wife uses her code, my sonâs name shows in the notification and vice versa. So I just switched their names in KeyMaster. After I did that, I disabled my wifeâs code, then re-enabled it. Now, the PIN Status shows as Adding and never changes to Connected. Her code still seemed to work for a couple of days but now it doesnât. Any ideas how I can fix this? I am on the newest version.
Turn âEnabledâ to off on your wifeâs code or the code where you are stuck at âAddingâ then;
Go to âDeveloper Toolsâ, then âACTIONSâ, in Actions select âZ-Wave: Clear lock user codeâ, then in Targets select âChose Entityâ and select your lock, in code slot put in your the code slot number, select âPerform Actionâ. That what I call a reset, this should work, give it about 20 seconds before switching the code to Enable.
Thank you for the suggestion. Unfortunately, it doesnât seem to work for me. Something is not being cleared out. I have 3 locks. My front door is the master. I selected my front door lock as the entity and entered 2 for the code slot. Then, clicked the perform Action button. After a couple of seconds, the Perform Action button turned green with a check mark. I waited a couple of minutes and tried to enable the code but it just stayed at adding. I tried adding all three locks but that did not work either. I also tried clicking on Advanced Options and then Reset Code Slot but that, also, did not work. When I disable the code, the PIN Status shows Deleting and then Disconnected. Re-enabling the code just gets stuck at Adding.
I entered my wifeâs name with a number 2, code into another slot and it works. If I remove the 2 from her name, it does not work. When I add the 2 back, it works again.
I sorry it didnât work for you. Do you have any AC powered ZWAVE devices within 10 feet of the locks?
Like repeaters, outlets, or light switches? This is an indication that you need a buffering ZWAVE repeater next to the locks, some commands are being dropped.
I have 3 Inovelli wall rocker within 8 feet of the front door lock. The Zwave receiver is within 12 feet.
I looked at the events for that lock Zwave JS and I could see it was receiving the information. Iâm not sure what happened but it is working properly now. I must have done something that stopped it from working properly but Iâm not exactly sure what.
I was curious about this custom notification. I am getting this error: Message malformed: invalid template (TemplateSyntaxError: Encountered unknown tag 'states'.) for dictionary value @ data['trigger'][0]['variables']['notify_state']
New error: Message malformed: invalid template (TemplateSyntaxError: Encountered unknown tag 'sn'.) for dictionary value @ data['action'][1]['if'][0]['value_template']
I am not getting any notifications for Keymaster even though I have the manual script modified the way that I need. In the automations for user and lock notify, it shows that they have never run. They used to before I had to remove and readd my locks. I get a notification when the door opens and closes which uses the Keymaster automation, and it is showing as running. Iâm wondering if itâs tied to keymaster_lock_state_changed never firing. How can I test this theory and/or fix the issue.
I have lock and door notifications enabled (and showing enabled) via the lovelace card.
UPDATE:
I tried subscribing to the event keymaster_lock_state_changed but it did not fire when manually locking/unlocking or when using a user code to lock/unlock.â
UPDATE2:
I resaved the two locks and now keymaster_lock_state_changed is firing and calling script but itâs not sending notification. Script looks good to me. Do you see anything wrong here? Again, itâs working for door open/close.
Ive have just repaired this integration after months where all entities showed up as unavailable, thankfully the lock and codes still worked. After reconfiguring and fixing one of the automations (I think thats what did it) all came back.
I was wondering however and given I have a very basic setup (1 lock/5 Users) if there was a way in which I could check the log/history to see when a particular user unlocked. I managed to get the ânotificationâ working, but rather just want a log to see a user access. Thanks
I think the easiest way to do this would be to setup a telegram bot for notifications, then you can review the Telegram chat for the âaccess logâ
Of course, the ZWAVE Addon will have a log, but it will be the user number not name. You can have that log saved to a file and filter out âkeypad unlockâ events.
For my experience, Telegram would be the easiest and best way to do this.