KeyMaster Z-Wave lock manager and scheduler

Here’s your fix replace the automations as listed:

    - alias: BackDoor Add Code
      condition:
        - condition: state
          entity_id: 'binary_sensor.allow_automation'
          state: 'on' 
      trigger:
        entity_id: binary_sensor.active_backdoor_1, binary_sensor.active_backdoor_2
        platform: state
        to: 'on'
      action:
        - service: lock.set_usercode
          data_template:
            node_id: >- 
                {{states.lock.schlage_allegion_be469_touchscreen_deadbolt_backdoor.attributes.node_id}}
            code_slot: >-
                {% set object_id = trigger.to_state.object_id %}
                {% set index = -1 %}
                {% set code_slot = object_id[index:] %}
                {{ code_slot  }}
            usercode: >-
                {% set object_id = trigger.to_state.object_id %}
                {% set index = -1 %}
                {% set code_slot = object_id[index:] %}    
                {% set codetext = 'backdoor_pin_' + code_slot | string %}
                {% set code = states['input_text'][codetext].state %}
                {{ code | string }}

and

    - alias: BackDoor Clear Code
      condition:
        - condition: state
          entity_id: 'binary_sensor.allow_automation'
          state: 'on' 
      trigger:
        entity_id: binary_sensor.active_backdoor_1, binary_sensor.active_backdoor_2
        platform: state
        to: 'off'
      action:
        # - service: lock.clear_usercode
        #   data_template:
        #     node_id: >- 
        #         {{states.lock.schlage_allegion_be469_touchscreen_deadbolt_backdoor.attributes.node_id}}
        #     code_slot: >-
        #         {% set object_id = trigger.to_state.object_id %}
        #         {% set index = 17 %}
        #         {% set code_slot = object_id[inex:] %}
        #         {{ code_slot  }}
        - service: lock.set_usercode
          data_template:
            node_id: >- 
              {{states.lock.schlage_allegion_be469_touchscreen_deadbolt_backdoor.attributes.node_id}}
            code_slot: >-
              {% set index = -1 %}
              {% set object_id = trigger.to_state.object_id %}
              {% set code_slot = object_id[index:] %}
              {{ code_slot }}
            usercode: >-
              {{ range(1000, 9999) | random | int }}

Should fix you right up.

3 Likes

Perfect! That worked! Thank you so much.

1 Like

I’m thinking you can go thru your yamls and change any index = whatever to index = -1.
Maybe leave this post here for others to use as well. :smiley:

Good day all,

First of all, I’d like to hank firstof9 and the rest of the experts for creating this package and helping out!

Second, I need to put the caveat out there that I’m not much of a programmer and I am just starting out with Home Assistant. That said, this is the first time I’ve successfully got my Schlage connect to do more than simply lock and unlock with an automation software.

With the above said, I’m having problems implementing this solution. I followed the guide and ran into a lot of side tasks that I had to research how to implement. I think I’m close to a working solution, but I’m stuck at the end of the install. I can’t figure out where to put the code:

resources:
    - url: /community_plugin/lovelace-card-mod/card-mod.js
      type: module
    - url: /community_plugin/lovelace-fold-entity-row/fold-entity-row.js
      type: module
    - url: /community_plugin/lovelace-card-tools/card-tools.js
      type: js

I’ve tried putting it in the \config.storage\lovelace file using samba and editing the file in notepad++. I inserted it at the very top of the file which caused lovelace to crash on reboot. I also attempted to inserting it in lovelace using raw configuration editor which also crashes lovelace.

When I open the lock tab in lovelace, I see the following error.

Custom element doesn’t exist: fold-entity-row.

entities:

  • entity: input_boolean.reset_advanced_frontdoor_1
  • type: divider
  • entity: input_boolean.accesslimit_frontdoor_1
  • entity: input_number.accesscount_frontdoor_1
  • type: divider
  • entity: input_boolean.daterange_frontdoor_1
  • entity: input_datetime.start_date_frontdoor_1
  • entity: input_datetime.end_date_frontdoor_1
  • type: divider
  • input_boolean.sun_frontdoor_1
  • input_datetime.sun_start_date_frontdoor_1
  • input_datetime.sun_end_date_frontdoor_1
  • type: divider
  • input_boolean.mon_frontdoor_1
  • input_datetime.mon_start_date_frontdoor_1
  • input_datetime.mon_end_date_frontdoor_1
  • type: divider
  • input_boolean.tue_frontdoor_1
  • input_datetime.tue_start_date_frontdoor_1
  • input_datetime.tue_end_date_frontdoor_1
  • type: divider
  • input_boolean.wed_frontdoor_1
  • input_datetime.wed_start_date_frontdoor_1
  • input_datetime.wed_end_date_frontdoor_1
  • type: divider
  • input_boolean.thu_frontdoor_1
  • input_datetime.thu_start_date_frontdoor_1
  • input_datetime.thu_end_date_frontdoor_1
  • type: divider
  • input_boolean.fri_frontdoor_1
  • input_datetime.fri_start_date_frontdoor_1
  • input_datetime.fri_end_date_frontdoor_1
  • type: divider
  • input_boolean.sat_frontdoor_1
  • input_datetime.sat_start_date_frontdoor_1
  • input_datetime.sat_end_date_frontdoor_1
    head:
    label: Advanced Options
    type: section
    type: ‘custom:fold-entity-row’

Lastly, I am getting errors with my config regarding the door sensor. I’m sure I can fix these if I read through this thread some more because it is mentioned several times in the setup to ignore that code until later… Just wanted to note it in case it’s relevant…

Thanks in advance for the help!

This would go in dashboard resources tab.


Best bet is to not modify the files in .storage unless you have to. :slight_smile:

We’d need to know the error to help with that. Feel free to post it.

Welcome to the community! If this is the error you’re referencing:

When I open the lock tab in lovelace, I see the following error.
Custom element doesn’t exist: fold-entity-row.

The instructions say:

The easiest way to add these plugins is using the Home Assistant Community Store. You will need to go to “Settings” and add the following repositories in order to download the plugins:

But you’ll also have to install Fold Entity Row. I understand what you mean when you say there are “a lot of side tasks”, but if you have HACS it’s easier.

Thanks for the help guys. Still have the same error though. I added all 3 urls to my resources per your photos, but it didn’t work. I also added the additional two links which shouldn’t belong here:
https://github.com/thomasloven/lovelace-auto-entities
https://github.com/thomasloven/lovelace-card-tools

I also set up HACS and installed auto-entities and card-tools. I did not need these links since they were already listed in integrations. Therefore, I just used the built in install button.

Where am I going wrong?

Thanks Kevin! I missed your response. You had the answer with:

But you’ll also have to install Fold Entity Row. I understand what you mean when you say there are “a lot of side tasks”, but if you have HACS it’s easier.

Ok, the code seems to be working and I can drop down the menu in lovelace. Visually, it looks good now. But, I still have a problem…

The code entries don’t appear to be doing anything with the lock. I have an idea that it has something to do with the number of digits in the code. My lock is configured for 8 digits currently. For testing purposes, I tried making a new code in block 9 (yes, I have 9 code slots configured) and tried codes: 1234, 123456, 12345678. Non of them worked. Do I need to factory reset the lock and reprogram it for a 4 or 6 digit code?

Is your lock a BE469ZP, or something else? There’s a lot that could be happening, but without specific errors, the logs are your best starting place. In Configuration -> Z-Wave -> OZW Log, you can tail the last 500 entries.


A new window will pop up and you can watch z-wave activities in that window as they happen. If you select your lock at the top of that screen, you can set codes manually under “Node user codes.” I had to delete the trailing \xa\xd and set the code to 5555.

This generated 73 new lines in the open z-wave log, and the user code appeared to reset back to its old setting. I suspect this could be fixed with a “delay:” parameter to the zwave device configuration, but I didn’t bother to try. If it resets back to the previous code, don’t give up (this threw me quite awhile, as I kept thinking it had refused the new code). Read the logs. It’s tedious, but it’ll tell you exactly what’s happening. Spread out through the new log entries, look for lines similar to these:

Info, Node023, Value::Set - COMMAND_CLASS_USER_CODE - Code 4: - 4 - 1 - 0x35 0x35 0x35 0x35
Detail, Node023, Decrypted Packet: 0x00, 0x63, 0x03, 0x04, 0x01, 0x35, 0x35, 0x35, 0x35, 0x0a, 0x0d
 Info, Node023, Received User Code Report from node 23 for User Code 4 (Occupied)

If you’re not able to set a code that way, you have a fundamental problem between the lock and Home Assistant that you’ll have to address first. For my BE469ZP I had to reset the lock to factory defaults and make sure the lock was in the “locked” position when I did the secure pairing.

If you’re able to successfully set the codes that way, but the package isn’t working for you, re-run setup and re-insert the lovelace code for the package.

Kevin,

Thanks for the help. I’ll start looking through the code. Yes my lock is a BE469ZP.

I think the pairing is fine since I can lock and unlock from the automatically generated lovelace entities. I can see the messages being passed from the lock to HA as I manipulate it. Perhaps only part of it isn’t paired correctly?

Does code length have any requirements? Remember my lock is set for 8 digits at the moment. Does that matter?

I’m afraid I don’t understand what you want me to do to test if there is a fundamental problem. You put the following code in your last post:

 Info, Node023, Received User Code Report from node 23 for User Code 4 (Occupied)

Where do I past this? Remember, I’ve been playing with HA for all of 2 days. I still have my training wheels on…

I don’t know. Let’s find out.

In side panel, select Configuration, then scroll to the bottom of the page and find Z-Wave. On the new page, select your lock:


Scroll down to the bottom of that screen, just above where you can tail the logs, and find “Node user codes”:
image
In that box, you can select a code slot, and enter a code. In the example above, I entered \x35\x35\x35\x35 and deleted \xa\xd from the end, then press “SET USERCODE”. My lock isn’t configured for 8 digits, but if yours is, you can try \x35\x35\x35\x35\x35\x35\x35\x35 and that should work.

In the logs, you should see a lot of new lines scroll by. My lock is node 23, and I set code slot 4 to user code 5555, but your values will be different. The “info” and “detail” lines I pasted above will reflect the node, node ID, code slot, and user code values you’re using. If you’re seeing lines like that, and the user code you enter using the \x35\x35\x35\x35\x35\x35\x35\x35 format works on the door, your lock is paired correctly. If you’re getting errors, if you don’t see HA sending anything to the lock, or if the code doesn’t work, you may not be securely paired to the lock. If it’s paired but not securely paired, you’ll have to fix that first.

Ok, Have some progress. I’m seeing some interesting things, and I think I can confirm that we have a secure connection.

  1. I can manually manipulate code 1 with \x35\x35\x35\x35\x35\x35\x35\x35. When I try to change the code back to its proper code using lovelace, I don’t see any transaction in the log. So apparently, there is a lovelace issue? I’m guessing you are going to tell me to reinstall the script???

  2. I can’t change code 8 or 9 manually. It sends the codes and appears to be good (from my limited understanding of the logs), but they don’t take in the lock. Is there a limit to the number of codes? Do I have to activate that slot somehow?

Again, I really appreciate the help! I’m so excited to get this lock finally working to its full potential!

I’m guessing you are going to tell me to reinstall the script???
I think that’s what I had to do at this point, but you might also check the HA log.
In the side panel, click developer tools → logs and see if you have any errors there. I haven’t set longer codes, but I seem to recall someone else in this thread doing that. You might re-read the thread and see if you notice anything new, now that you’re a little more familiar.

Keep working at it!

I may have found my problem on reinstalling. I remember seeing this error before, but thought I solved it. Trying to solve it again is proving elusive. setup.sh is calling the number of codes slots which I have set to 9. I tried resetting it to 6, but that didn’t fix the issue.

This is the error:

lockmanager $ ./setup.sh
awk: cmd. line:9: Unexpected token
lock_manager.ini is incomplete or does not exist
./setup.sh: line 80: ((: i<=: syntax error: operand expected (error token is “<=”)
./setup.sh: line 97: ((: i<=: syntax error: operand expected (error token is “<=”)
creating
BusyBox v1.31.1 () multi-call binary.

Usage: mkdir [OPTIONS] DIRECTORY…

Create DIRECTORY

    -m MODE Mode
    -p      No error if exists; make parent directories as needed

BusyBox v1.31.1 () multi-call binary.

Usage: mv [-fin] SOURCE DEST
or: mv [-fin] SOURCE… DIRECTORY

Rename SOURCE to DEST, or move SOURCE(s) to DIRECTORY

    -f      Don't prompt before overwriting
    -i      Interactive, prompt before overwrite
    -n      Don't overwrite an existing file

BusyBox v1.31.1 () multi-call binary.

Usage: mv [-fin] SOURCE DEST
or: mv [-fin] SOURCE… DIRECTORY

Rename SOURCE to DEST, or move SOURCE(s) to DIRECTORY

    -f      Don't prompt before overwriting
    -i      Interactive, prompt before overwrite
    -n      Don't overwrite an existing file

lockmanager $

Attached is my file FrontDoor.ini file:

.

What am I doing wrong?

Do a search for “awk: cmd. line:9: Unexpected token” in this thread. I remember seeing a discussion about it.

1 Like

You’re just missing the package, the command to install it is in previous posts. :slight_smile:

Yep, I found the gawk issue the first time I tried installing it because I read the whole thread two days ago. My attempt to reinstall without blowing everything up, I forgot about that step. It still didn’t work after messing around with the code for a few hours, so I restored a snapshot to go back to a known working copy before all this code was installed and I did additional snapshots as I went to attempt to make it easier if i need to try again. So after a full day of trying to get this to work, here is where I’m at:

I completed a fresh install. Lovelace looks good but its a bit slow compared to before. I have 10 user codes which may add to that issue… The lock is working with manual inputs and lovelace lock/unlock commands. The lock manager is still not updating the lock. When watching the log, no z-wave traffic is generated when manipulating lovelace lock manager. I attempted to input the code 55555555 into position 1, enabled the code slot and nothing happens. The only errors I receive is the missing doorsensor and garage entities which is expected.

Once again, I’m stuck. I don’t know where to start looking for the issue. All I know is what I said above and that lovelace lockmanager doesn’t generate any zwave traffic which is the same issue I experienced prior to my snapshot restore.

Suggestions are welcome! Sorry, to bombard the board with questions.

Sounds like the automation isn’t firing, check the HA log.

I checked the Logbook, Developers Tools Logs, and I manually opened the Home-Assistant.log file in the config folder. There is no indication of lock traffic at all. I also attempted to switch on a light to generate normal working traffic and didn’t see anything either though. I do see light and lock changes in Logbook.

Am Looking in the correct places? I don’t see any change in Home-Assistant.log