KeyMaster Z-Wave lock manager and scheduler

What repo did you use for the OZW beta?

I use the docker image that Fishwaldo puts out: docker pull openzwave/ozwdaemon:allinone-latest

Iā€™m not surprised. I knew (but failed to document) that loading times can be painful. This is part of the reason that my recommended method of adding the GUI is to use an entire view. You should only load this GUI when you actually need to use it.

Have you narrowed down what elements are actually slowing down load times? If youā€™ve managed to find a solution Iā€™d be happy to update the package.

I assume youā€™re also using a container for home assistant. Can you share how youā€™re firing that up? Especially any docker-compose files.

Ah, the beta exists in integrations already. Did you have to disable the non-beta integration first?

After adding the beta integration, do you see multiple ā€œlockā€ services? For example, lock.clear_usercode is not working in the standard integration, but you said itā€™s working in the beta for your kwikset lock? Are they named the same way?

Yes, I also moved my Home Assistant to a docker container on one of my servers, my Zwave is now decoupled from my HA and running on the rPi3 that used to host HA as well.

No currently you only get lock.lock, and lock.unlock. I can manually add/remove user codes via MQTT.

Iā€™m going to try to see if I can whip up a PR for user codes.

With my UI updates that I posted yesterday, the front end loading is nice and quick on low-end hardware. On high end hardware itā€™s negligible. A ~1 second delay on the lock config page load and 1-2 seconds on the specific code edit popup.

Regarding the actual HA z-wave load, after some monitoring, itā€™s only an extra minute or two to finish z-wave starting, and thatā€™s fine considering I normally donā€™t restart HA, except when tinkering.

But as I mentioned yesterday, decoupling the Lovelace page with button cards from the actual popup of code config data made a big difference.

Thanks for the awesome package!

So when I delete a use code this happens:


2020-07-02 16:59:17 DEBUG (MainThread) [custom_components.ozw] [VALUE CHANGED] node_id: 14 - label: Alarm Type - value: 33 - value_id: 144115188316782609 - CC: CommandClass.ALARM,
2020-07-02 16:59:17 DEBUG (MainThread) [custom_components.ozw] [VALUE CHANGED] node_id: 14 - label: Alarm Level - value: 3 - value_id: 144396663293493265 - CC: CommandClass.ALARM

Alarm Type: 33 (User Deleted)
Alarm Level: 3 (Code Slot)

This happened when I deleted code slot 3. Guess that could be used to verify the codeā€™s been wiped.

Edit: PRā€™s in.

Iā€™m going to be afk for a few days. My NUC got hit by ransomware. Little fā€™ers

bummer. :frowning:

First time posting here and thereā€™s a LOT to read through in this thread so apologies if I missed something relevant. Moved to HA from Wink only about a month ago so Iā€™m an HA noob. Be gentle. :slight_smile:

I have a single Kwikset 916 lock. First and only lock Iā€™ve ever played with. Iā€™ve got HA running in Qemu on my NAS. Itā€™s the default HASSOS 4.10 (4.11 was JUST released but I havenā€™t updated yet). Itā€™s a VM that is a very stripped down OS that just runs docker. Itā€™s what you end up when you follow the guides and download their images for running it as a VM. You canā€™t install gawk or any packages that I can see in that OS so I fired up Debian on WSL and did an apt-get install gawk and after considerabke mucking around was able to get a clean run of setup.sh then moved that folder into my HAā€™s packages folder and it all looks good.

Incidentally, to sum up the problems people are having with setup.sh I think they seem to be one or more of these:

  • No gawk and no way to install it.
  • They are using the shell you get from TMUX using the Terminal/SSH add-on which seems problematic. It loads Busybox which does not get hung up the below array creation but again no gawk.
  • Using the terminal directly from HASS OS produced different results. It errors out on the ā€œ(ā€ in files=(*.ini) whatever version of BASH that is does not apparently like using () to create arrays. files=*.ini works but does not create an array so the for loop hates it. Probably would have gotten hung up on no gawk anyway if it had gotten that far.
  • As someone else pointed out sensorname= default contains spaces and caps so it makes you think itā€™s just a friendly name thing that can have spaces in it but this does not bode well with setup.sh. I would change that default or add a comment to the FrontDoor.ini
  • The error message in your else statement lock_manager.ini is incomplete or does not exist is kind of misleading. I spent some time looking around for this missing ini file before I realized it was just the generic error thatā€™s thrown when parsing the ini files fails and has nothing to do with a specific ini file. I think this error should be changed to ā€œProblem parsing your ini file(s). Please check the syntax and make sure you have gawk installed.ā€ or something similar.

There are too many different ways to run HA me thinks. So perhaps a different, more universal, setup script might be in order but itā€™s way out of my league to come up with one. Not sure if HASS OS is also what gets used on the Rasberry Pi loads but if it is that would explain a lot. I think thatā€™s probably the most popular deployment.

One other small thing I noticed was for notifications you use notify.my_devices which doesnā€™t work on my system. Iā€™m guessing itā€™s a custom array you setup? I donā€™t know but changing that to my specific phone worked. I donā€™t know if thereā€™s a universal value here that would work for any user that might be better or if it should be made into a part of the GUI to choose notification devices. Just thought iā€™d point out that youā€™re probably publishing something that only works for you. :wink:

Anyway, my real reason for posting is that Iā€™m very very close to having this running perfect but I need some help debugging. The GUI is all setup fine. I did the bits with the input_booleans and all that is fine. But the automations never seem to trigger when I set the codes in the GUI. When triggering the Add codes automation manually it still does not set the codes. However, I can go to the node under Z-Wave and Node user codes section and program it fine there. Also, can go to Developer Tools -> Services -> lock.set_usercode and program it using that tool. My lock (I have no idea about others) requires the codes be converted from ascii and sent as hex in this format: \x31\x32\x33\x34 (which is ā€œ1234ā€). Even in the lock.set_usercode service I have to do usercode: \x31\x32\x33\x34.
Is this just my lock or does everyones locks send the codes as hex?

I assume the add usercode automation is supposed to be triggered after you set a pin and toggle enabled right? The execution time does not update on it though. Manually executing it does not set the codes either although iā€™m not sure if itā€™s supposed to work like that or only be triggered by the GUI?

So I guess Iā€™m wondering where I should start debugging here. Is there a log I should be looking at? Do I need to figure out how to modify the code to convert the ascii to hex? Iā€™m a sysadmin by trade and not a developer but I could probably hack that out but I think iā€™m getting hung up somewhere before that process.

Iā€™m using PowerShell to convert the ascii to hex in the format it wants and then paste that into HA:

Function MakeHexforDoorLock { Param([string]$Code); (format-hex -InputObject $Code -Encoding ascii).HexBytes -split(" ") | %{ write-host $('\x' + $_) -NoNewline }}
# then run it like so:
MakeHexforDoorLock -code "1234"
# Output:
\x31\x32\x33\x34

And thatā€™s how Iā€™m setting my codes right now which works but Iā€™d just love to get this GUI up and running 100% with the scheduling and guest codes, etc.

Thanks for reading my small novel. Any help is appreciated.
-Sean

One follow up thing I noticed was that while lock.set_usercode service seems to work fine when I pass the correct hex code values, running lock.get_usercode does not seem to do anything. I donā€™t see anything happen in the OZW log like I do when I trigger lock.set_usercode. Are these services part of this project or built into the system? Do I need to fix the lock.get_usercode first? Is that my real problem? and where would I look at that code?

Pass the value as a string or int, not a hex value.

They are a service provided by the zwave integration. Short answer: yes the system.

No

No

You canā€™t really in that version of zwave.

In the ozw beta thatā€™s being tested, all the usercode commands work as advertised. (stay tuned on that).

1 Like

Thanks for your reply. I see you are right about lock.set_usercode. The hex values are needed only when I program directly from the zwave integration.

But what about the automation? They should work to program whatever codes I have entered into the GUI and upon enabling a code the automation should be triggered right? So it seems I have two problems. The GUI isnā€™t triggering the automation and the automation doesnā€™t work when triggered manually. I guess iā€™ll start there. Thanks.

Depends, they should set, but if thereā€™s an error for some reason, it wonā€™t trigger and set the codes. Check your home-assitant.log for errors regarding the automations.

1 Like

There will be a breaking change for this package in ozw.

Example:

      - service: lock.set_usercode
        data_template:
          node_id: >-
            {{states.lock.kwikset_touchpad_electronic_deadbolt_locked_frontdoor.attributes.node_id}}
          code_slot: >-
            {% set index = 17 %}
            {% set object_id = trigger.to_state.object_id %}
            {% set code_slot = object_id[index:] %}
            {{ code_slot  }}
          usercode: >-
            {{ range(1000, 9999) | random | int }}

This will need to be changed to:

      - service: lock.set_usercode
        data_template:
          entity_id: lock.kwikset_touchpad_electronic_deadbolt_locked_frontdoor
          code_slot: >-
            {% set index = 17 %}
            {% set object_id = trigger.to_state.object_id %}
            {% set code_slot = object_id[index:] %}
            {{ code_slot  }}
          usercode: >-
            {{ range(1000, 9999) | random | int }}

From node_id to entity_id?

Correct, you can also send it a list of locks to update, so you can bulk add/remove codes if you like.

1 Like

Maybe you can help me get the new OZW installed? Iā€™m using a docker setup btw.

I use docker-compose to manage mine hereā€™s an example you can use to fire yourā€™s up:

version: '3'
services:
  ozwd:
    image: openzwave/ozwdaemon:allinone-latest
    container_name: "ozwd"
    security_opt:
      - seccomp:unconfined
    devices:
      - "/dev/ttyUSB0"
    volumes:
      - ./ozw:/opt/ozw/config
    ports:
      - "1983:1983"
      - "5901:5901"
      - "7800:7800"
    environment:
      MQTT_SERVER: "192.168.0.1"
      MQTT_USERNAME: "my-username"
      MQTT_PASSWORD: "my-password"
      USB_PATH: "/dev/ttyUSB0"
      OZW_NETWORK_KEY: "0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00"
    restart: unless-stopped

I put my ozw in /opt/ozw on my ā€˜DockerPiā€™ and I renamed my device to /dev/zwave

    devices:
      - "/dev/serial/by-id/usb-0658_0200-if00:/dev/zwave"
    volumes:
      - /opt/ozw:/opt/ozw/config
...
      USB_PATH: "/dev/zwave"
  1. That MQTT Server is the one that you were using before?
  2. Whatā€™s the /dev/ttyUSB0 used for? How does that compare to the /dev/zwave you have below? I take it you renamed it so you didnā€™t have to modify your existing docker-compose?
  3. Is the network key the same one you used for the older OZW?