KeyMaster Z-Wave lock manager and scheduler

I have your example working. (It was working originally, I just didn’t realize, I was supposed to be looking in the log for the lock entity)–> I’m so new with all of this and I was looking in all kinds of stupid/ wrong places.

1 Like

Hey there! Yes my NodeRed is a bit complicated but I needed the announcement to cover everyone who was coming home. If you are just looking to announce when the keypad is unlocked by a pin you could use the event to watch for the unlock and then send a modified message using the pin event accordingly. Open the function I created and look at the top where the keypad name is captured.

Honestly I wasn’t sure myself, I’ve never used the logbook.log service.

I follow. Very appreciative of your alls help. Everything is working great!

1 Like

Here’s a working automation using the lock information you gave me. This has an extra condition that it will only fire if the keymaster event is for an unlock.

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 -%}
      door: >-
        {%- if trigger.event.data.lockname == "front_door" -%}
          Front Door
        {%- elif trigger.event.data.lockanme == "back_door" -%}
          Back Door
        {%- else -%}
          Garage Entry Door
        {%- endif -%}
condition: []
action:
  - service: logbook.log
    data:
      name: '{{ trigger.event.data.lockname }}'
      entity_id: '{{ trigger.event.data.entity_id }}'
      message: '{{ sn }} {{ verb }} the {{ door }}'
  - service: notify.tykes_notices
    data:
      title: '{{ door }}'
      message: '{{ sn }} {{ verb }} the {{ door }}'
      data:
        tag: '{{ door }}'
mode: single

This also sends to my tykes_notices notification group (phone, email, and web browser)

Since there is a data tag tied to the door, that means each time it happens, if you haven’t seen the notification it will get overwritten by the new notice. If you don’t want that, just remove the data tag section, or use a unique tag such as repeating the message. That way you would only have the latest notice of any specific type of unlock event.

1 Like

@wtstreetglow I’ll go a step further and try and help you for your question in the Can someone help me out with the conditions section of an automation (I don’t know the proper way to write it) thread by doing your alarm unlock but only if it’s for a named keypad unlock event (so manual unlocks will not disarm).

A couple of things about this:

  • You probably want to change the name at this point :smiley:
  • I dropped the notification section on the lock logging, you could add that back in
  • I don’t have an alarm panel so I can’t test if this logic fully works, but given what I saw in the other thread I suspect that it will
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' }}"
          - "{{ states('alarm_control_panel.alarmo') != 'Disarmed' }}"
        sequence:
          - service: alarm_control_panel.alarm_disarm
            entity_id: alarm_control_panel.alarmo
            data:
              code: !secret alarm_code
          - service: notify.adult_phones
            data:
              message: "House alarm disabled for {{ sn }}"
    default: []
mode: single
1 Like

@tykeal, thank you for taking the time to show me and others how to do this. I really do appreciate it. I will review it and make sure I understand how you’ve done things over the next few days. → sadly, I’m slow with these things because they are all incredibly new concepts to me. (I didn’t even know about the concept of “events” until the last few days.)

I like this, I have something similar implemented in my HA instance after our previous discussions. Very grateful for you showing me how to do that.

This is fantastic. I will have to do this more. I had heard of this concept but didn’t know how to do it until you just showed me this. I really like that idea.

Awesome… was able to get it announce name of person using the code, but can I have it not announce when I lock or unlock door manually?

[{"id":"d8c5bcf103107513","type":"api-call-service","z":"96f2d1e869eeacad","name":"set volume","server":"6821cdda.fbbcd4","version":5,"debugenabled":false,"domain":"media_player","service":"volume_set","areaId":[],"deviceId":[],"entityId":["media_player.man_cave_echo","media_player.living_room","media_player.master_bedroom_echo"],"data":"{\"volume_level\":0.4}","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":270,"y":160,"wires":[["8f4034fbeb070758"]]},{"id":"8f4034fbeb070758","type":"api-call-service","z":"96f2d1e869eeacad","name":"Notify via Mancave, Living Room Echo","server":"6821cdda.fbbcd4","version":5,"debugenabled":false,"domain":"notify","service":"alexa_media","areaId":[],"deviceId":[],"entityId":[],"data":"{\t   \"message\": payload.event.code_slot_name & \" arrived\",\t   \"data\": {\t       \"type\": \"tts\"\t    },\t   \"target\": [\t       \"media_player.man_cave_echo\",\t       \"media_player.living_room\",\t       \"media_player.master_bedroom_echo\"\t   ]\t}","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":450,"y":280,"wires":[[]]},{"id":"7f2f95052ebcd92f","type":"server-events","z":"96f2d1e869eeacad","name":"Keymaster Lock State Change","server":"6821cdda.fbbcd4","version":1,"event_type":"keymaster_lock_state_changed","exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"waitForRunning":true,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"eventData"},{"property":"topic","propertyType":"msg","value":"$outputData(\"eventData\").event_type","valueType":"jsonata"},{"property":"event_type","propertyType":"msg","value":"$outputData(\"eventData\").event_type","valueType":"jsonata"}],"x":160,"y":60,"wires":[["d8c5bcf103107513"]]},{"id":"6821cdda.fbbcd4","type":"server","name":"Home Assistant","version":4,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true,"heartbeat":false,"heartbeatInterval":30,"areaSelector":"friendlyName","deviceSelector":"friendlyName","entitySelector":"friendlyName","statusSeparator":"at: ","statusYear":"hidden","statusMonth":"short","statusDay":"numeric","statusHourCycle":"h23","statusTimeFormat":"h:m"}]

So this is where you really need to use a function. You need to look at the state operation and determine what it is doing. Basically you want to look for “Keypad unlock operation” and then kick everything off.

var states = global.get('homeassistant.homeAssistant.states');

//Define Variable
const user_string = msg.payload.event.code_slot_name; 
const action_type = msg.payload.event.action_text;

  //Lock Actions
  if (action_type == "Keypad unlock operation") {
      msg.payload = user_string + " arrived.";
      return msg;
  }

Then for your announcement should change to:

{

   "message": payload.msg,

   "data": {

       "type": "tts"

    },

   "target": [

       "media_player.man_cave_echo",

       "media_player.living_room",

       "media_player.master_bedroom_echo"

   ]

}

I’ve got a question, and hoping someone can help me out. I copied the keymaster notification script to my script file. When I use the code on one of the locks it tells me who unlocked the door, but for my other 2 locks it just shows () instead of the name of the user. If it matters the door that don’t show the names is stuck on “Adding” for Pin Status. But the code still works.

Thank you so much. You make this thing looks so easy. I got it working. I had to make the slight change for it work. Thanks again @PrayerfulDrop

"message": "{{payload}}", 

instead of

 "message": payload.msg,
1 Like

If you look at my original function mode you can have more fun and randomize the announcements. Just in case you get bored with “@sparklee arrived” :grin:

I’m working on a non-Z-Wave open-source lock and, given this project’s support of MQTT, I’m hoping to use the correct MQTT topics/messages/format to make this lock work with the KeyMaster integration. Does a list of the expected topics/messages exist?

Unfortunately I do not have a Z-Wave lock to reverse engineer this myself, although perhaps that might be the way this has to go, depending on whether there are helpful people out there or not. :slightly_smiling_face:

Is it possible to add NFC or RFID card/tags ? :slight_smile:

Keymaster doesn’t support MQTT.

AFAIK those are not exposed via zwave methods of setting/removing and are app based and programmed via bluetooth.

1 Like

Ah, my mistake. I had the impression it supported zwave2mqtt. Thanks for the info.

Hi, I followed all the setup instructions and added lovelace code that was generated during setup. When I go to the dashboard to view the code slots PIN STATUS “Deleting” is stuck for all slots I had created.

I enabled debug mode as in the wiki, all I see in there is:

2022-07-29 19:28:09 DEBUG (MainThread) [custom_components.keymaster] Finished fetching keymaster data in 0.000 seconds (success: True)

I dont see any log entries that are different even when I trigger “Advanced options Reset Code slot” - I am not sure what’s wrong but the one lock entity is connected just fine via zwave because I can unlock, lock and re-interview the device just fine.

Any guidance on how to debug this more or what I did wrong? YALE AssureLock SL is my smartlock.

I’m having a very similar problem. I have two identical locks (BE469). One works perfectly and the other doesn’t.

The Pin Status for my codes is stuck in ‘Adding’. When I navigate to the entities for this lock, the status shows ‘Unavailable’. I have re-interviewed the lock, excluded and re-added, and reinstalled keymaster. Each time I see the same problem. The lock itself functions through HA. I just cant set codes through keymaster.

Are you using Zwave JS addon? Z-wave JS to mqtt? Are you able to see the user codes in config thru the z-wave interface? You may have to re-interview the lock multiple times. One of my Schlage Connects took like 5 re-interviews to have the user codes actually show up.

1 Like

Had the same issue of hanging with adding, also with a new BE469 after the first one has been up and running for a while.

I’m not 100% sure what resolved it, but the new lock is fully functioning now.

I think the trick was to configure the lock to use 6 digit codes (versus the default 4 digit) through the zwavejs2mqtt Configure screen (HA Settings > Devices and Services > Click Devices Tab up top > Select Device > Select Configure Device beneath Device info, change user code length from 4 to 6.)

You may want to restart HA now for good measure – mine restarted because I updated Core OS, but I’m not sure if that had anything to do with the lock functioning.

You should then be able to verify that the lock codes for all slots are showing as “available” in the ZWaveJS Usercode V1 dropdown panel for the lock. Before I did the above the dropdown would show the factory codes and I wasn’t able to manually override them. After it showed all slots as [0] available with no stored codes and I was able to add codes through Keymaster.

Good luck!