Look back to middle - late August in this thread. There was discussion about using the events emitted by Keymaster instead of the built in notify script handler.
Thank you Andrew to taking the time to assist me with my concern. I did search and I am not sure if the following is what you meant:
alias: 0 - Lock Logging
description: ""
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 -%}
condition: []
action:
- service: logbook.log
data:
name: "{{ trigger.event.data.lockname }}"
entity_id: "{{ trigger.event.data.entity_id }}"
message: "{{ sn }} {{ verb }} the {{ trigger.event.data.lockname }}"
- choose:
- conditions:
- "{{ sn != 'Manual' }}"
sequence:
- service: input_text.set_value
data:
value: "{{ sn }}"
target:
entity_id: input_text.yale_user
- service: input_datetime.set_datetime
data:
datetime: "{{ now() }}"
target:
entity_id: input_datetime.last_user
mode: single
Could you please confirm. Sorry for being a newbie to HA and to the coding. I was thinking I only have to replace Keypad unlock operation with my phrase. Thank you again for your time and assistance.
Thatās the final code snippet that I had written previously, yes. The final intent was to help the requester of it with the following:
- log to the system log the lock and method / person that opened it
- save the date and time of the last named slot usage to a datetime helper
- save the last named slot usage name to a text helper
Modifying the actions section is effectively what you need to be doing as if it was your manual_notify script.
Alternatively, you could do some debugging and actually figure out what all is passed to the manual_notify script and do the work there
Thank you again Andrew and I do appreciate your help. I will try to play with it and get it to work the way I want it to be. Thank you again.
Thanks to all who make our locks work with HA. Itās my hope that one day all of this will be in the UI.
Hello @firstof9,
Thank you! Iām glad youāre looking into it
I do (two āSchlage BE468GBAK), at a remote location.
Installed and configured GitHub - firstof9/keymaster at zig2mqtt-support
Iām stuck at starting the Zigbee2MQTT add-on: startup fails as Iām already running ZHA and (think that I) cannot run both at the same time with the same controller.
Good time to switch though. Iāll do the migration this WE and report back.
Iām also trying to get what code was used to open the lock into the Logbook, but I feel like Iām missing something. Iāve looked through Home Assistantās docs on Automation and Scripts Yaml and have tried adding code snippets from this thread to my automation.yaml. However, I canāt seem to get anything to appear in the logbook, and it seems to break my keymaster_frontdoor_manual_notify script. Iām guessing this is because configuration.yaml includes automation, scripts, and scenes and Iāve got some sort of formatting issue in automation.yaml.
Looking at:
It seems to format entries like:
- id: foo
alias: bar
While in this thread I see snippets like:
- alias: bar
id: foo
I guess first I should just ask, am I on the right track? Are you guys adding these entries to automation.yaml?
Are you editing automation.yaml directly? You really should be only editing it via the UI unless you really know what youāre doingā¦
As to the order in your two examples. As far as yaml is concerned, they are the exact same.
Hah, yep, formatting issue. I was editing automation.yaml directly. I find yaml easier to read than the UI in this instance, but Iām just not quite as familiar with it as I need to be to write it apparently. Or I overlooked an indentation error.
Either way, you gave me the idea to create as much of the automation as I could with the UI, then edit yaml for the rest.
Itās working now, and in case it helps anyone else, here is the entirety of my automation.yaml:
- id: '1667935594434'
alias: 01 - Lock Logging
description: ''
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 -%}
condition: []
action:
- service: logbook.log
data:
name: "{{ trigger.event.data.lockname }}"
entity_id: "{{ trigger.event.data.entity_id }}"
message: "{{ sn }} {{ verb }} the {{ trigger.event.data.lockname }}"
mode: single
Learnt the hard way last week that Zigbee2MQTT changes the network key of the Zigbee dongle upon first start: it scrapped my existing Zigbee networkā¦ (had to re-pair everything once I got on site). I have a lot of devices requiring ZHA and will have to keep it running.
- do you have a zigbee lock / have you been able to use your code with it ( Iām considering purchasing a second zigbee stick to run Zigbee2MQTT on it and test it)
- also found GitHub - firstof9/keymaster at zha-support
Could you tell me whatās its status?
Thanks!
I do not have a zigbee lock to test with at this time.
I do however have a zigbee network setup now.
Not yet.
As of August.:
FutureTense, I got this working last year with your help, so that I can use my Keypad to disarm my Alarm. Is there a way to do the opposite, i.e. use the Keypad to ARM my alarm system? Currently, when my wife or I leave the house and we want the alarm on, we arm it with our phones through the HA app. I donāt have any wall panels currently (maybe next project). That works fine for us, but if we have someone come to the house (say for example the Cleaners), they can disarm the Alarm, but then when they leave - it either stays disarmed or we have to ānoticeā when the leave and manually re-arm the system. It would seem that if I can use Keymaster to ādisarmā the alarm, I SHOULD be able to have an event that āre-Armsā the Alarm if someone uses the keypad to lock it. Obviously, I canāt just re-arm the alarm every time the door locks - as there are many times when the door is locked that we DONāT want the Alarm on?
So I am thinking that in the automation, condition value_template, I just need to change the values in trigger.event.data.action_code, but I am not sure what they need to be changed to? Any help is greatly appreciated and thank you for a great project!
Thanks so much for your work! I got your branch set up and tested it out with my Kwikset 914 Zigbee locks and it doesnāt seem to be working, unless Iām doing something wrong. It added the integration with no problem (didnāt seem any different than before) but the Lovelace view wonāt add codes and shows entity not available for sensor.connected_******** and binary_sensor.active_******** (asterisks are lock names omitted). I believe these are supposed to show the code adding status. Much appreciated!
Edit: Iām an idiot, forgot to restart after adding the integration. After doing so, the behavior now seems no different than the main branch- just sticks on adding or deleting and does nothing.
Yup itās slow going.
Thanks for this integration. Just set it up. Had a question. Is it ok to change the number of codes once the service has been setup? I see the option when i hit configure on a service. Or should I delete and re add? I am trying to determine if I should start with a small number like 5 and add more as needed? I started with 25 and would like to reduce it.
You can reduce the code slots, the files will be re-generated.
@amoney I agree with @firstof9 on that. Iāve got several locks and I usually just add the number of slots that I need to manage, and when I outgrow that (or no longer need that many on a regular basis) then I change the number and get the files all regenerated.
I would strongly recommend that you make sure that any codes that are assigned to higher number slots are cleared before you reduce though
After I setup the integration i see a couple of errors in the logs
2022-12-09 07:30:28.954 ERROR (MainThread) [frontend.js.latest.202212080] https://**********.duckdns.org/lovelace/default_view:0:0 Uncaught TypeError: Failed to resolve module specifier "@rollup/plugin-node-resolve". Relative references must start with either "/", "./", or "../".
2022-12-09 07:30:28.985 ERROR (MainThread) [frontend.js.latest.202212080] https://*****************.duckdns.org/local/community/lovelace-card-tools/webpack.config.js:1:14 Uncaught ReferenceError: require is not defined
I added the webpack.config.js as a module under ressources. Any ideaās on what I need to do to clean these errorrs up?
I am having difficulty with notification for a second door. History shows that manual notify automation is firing for the new lock. It just is not passing ātitle:ā and āmessage:ā If i replace ā{{ title }}ā and ā{{ message }}ā with text the notification is sent.
Notifications for the old lock work as expected.
notification script looks like this:
keymaster_frontdoor_manual_notify:
mode: parallel
sequence:
- service: notify.telegram_all
data:
title: '{{ title }}'
message: '{{ message }}'
keymaster_back_door_manual_notify:
mode: parallel
sequence:
- service: notify.telegram_all
data:
title: '{{ title }}'
message: '{{ message }}'
back_door_manual_notify throws the following error:
2022-12-09 08:33:36.132 ERROR (SyncWorker_15) [homeassistant.components.telegram_bot] Error sending message: Can't parse entities: can't find end of the entity starting at byte offset 4. Args: (2115185726, 'back_door\nManual unlock operation'), kwargs: {'parse_mode': 'Markdown', 'disable_web_page_preview': None, 'disable_notification': False, 'reply_to_message_id': None, 'reply_markup': None, 'timeout': None}
Any thoughts on how to fix?
From my poor coding eye, Iām thinking that the nManual in āback_door\nManual unlock operationā is a typo. I just cant find where I can find it to correct.
Any help would be appreciated.