KeyMaster Z-Wave lock manager and scheduler

the entity database doesn’t seem to be an issue to me. i block many of the frivolous entities from being recorded. the main thing is the page load time on the front end. and before i added the lock manager yesterday, with the most recent updates to 0.111.4, the frontend has been super snappy. the big thing is loading all of those entities. i’ve done well to limit my views and only load what is necessary.

i’m not positive, but it seems like the more info popup information only loads when clicked/tapped. at least it does on the regular more info (when you click, that is when it queries the history engine to populate the recent state history). i’m going to work on this a little today and will let everyone know if it made a difference.

for other parts of my UI i’ve migrated a lot of stuff that used to be preloaded (and clutter the UI) like my server monitoring info (cpu,ram, disk use, etc). i changed to now just have button cards with a connected/disconnected state, and when i tap i get a browser mod-popup with bar-cards and entity list of the health in realtime. looks good and keeps the main page decluttered.

Wow. my assumptions were correct. reducing my ‘lock-manager’ view to just have button cards with browser-mod popups drastically sped up my loading on my phone. before it would take at least 10 seconds to load the view that @FutureTense provides in his package

now it’s about a 1 sec delay to load the page and maybe a 1-2 sec delay for any code to load. but i noticed, once i loaded one of the codes, the images cached and the subsequent popups were almost instant!

time to make it prettier and clean it up more now that it is functional. probably add some more folding rows to hide the days of the week as i won’t be using those most of the time.

access count and date range will probably be the most used. (though if my wife forces me now that i have this cool way to manage the lock, might need to do the day of the week for maid service (ugh, lazy :slight_smile: ) )
note, i also use lovelace_gen to keep my config files small

20200630_132834

I did some testing with the new ozw beta, looks like I was able to get a usercode to delete in my Kwikset lock now. :tada:

Wow that is very cool. Mind sharing your new yaml when you get it tweaked?

sure thing. i need to fix a few ui things that i broke last night and i’ll post up later today.

i tried using more nested fold-entity-rows for the days of the week config part. on the desktop browser, browser mod doesn’t do a good job of expanding the popup, so it cuts off some of the days, even after expanding others. not quite sure if/how i will be able to correct that. the workaround is to zoom out. i’ll need to dig into that at a later date.

however, in the mobile phone, there are no issues with this and the popup displays properly in the app (i use companion app on my android phone) as well as expands with scroller. since i’ll most likely use my phone for whenever i need to change or update a code, i don’t see the issue i’m dealing with on the desktop or tablets, being an issue for me, but i feel it’s worth mentioning for others.

OK. i’m happy with what i have now. this i gonna be a long post.

My config is broken up into many files and I heavily leverage lovelace_gen and button-card templates to keep things small. I also use layout-card fairly heavily to get the dynamic page sizes so things look nice on desktop/tablet as well as mobile. a lot of inspiration from dwains-theme in my config

So my system overview page i have a “lock manager card” per se that keeps overview things for this package neat.


the code from inside that page is here

          
          # ---------------------------------
          # ----- LOCK MANAGER
          # ---------------------------------
          #- break
          - type: vertical-stack
            cards:
              - type: markdown
                content: |
                  ## Lock Manager
                  ---
              # Lock Manager Status Buttons    
              - !include ../champs-lovelace/cards/more-page/lock-manager-status-buttons.yaml
              
              - type: custom:restriction-card
                restrictions:
                  pin:
                    code: !secret restriction_card_pin_code
                  block:
                    exemptions:
                      - user: !secret user_id
                card:
                  type: custom:button-card
                  icon: mdi:lock-smart
                  name: Front Door Codes and Configuration
                  template: lock_manager_button
                  tap_action:
                    action: navigate
                    navigation_path: /champs-theme-ng/keypad-frontdoor

              # Lock Manager Overrides
              - !include ../champs-lovelace/cards/more-page/lock-manager-overrides.yaml   
                    

the status buttons and overrides section in the above code block are below

lock-manager-status-buttons.yaml:

# lovelace_gen

type: horizontal-stack
cards:
  - type: custom:button-card
    entity: binary_sensor.system_ready
    template: lock_manager_button
    show_state: false
  - type: custom:button-card
    entity: binary_sensor.allow_automation
    template: lock_manager_button
    show_state: false

lock-manager-overrides.yaml:

# lovelace_gen

type: vertical-stack
cards:
  - type: custom:mod-card
    style: |
      ha-card {
        background-color: var(--champs-theme-primary);
        padding-right: 20px;
        padding-bottom: 10px;
        border-radius: 10px;
      }
    card:    
      type: custom:fold-entity-row
      head:
        type: section
        label: Notification Override 
      entities:
        - entity: input_boolean.frontdoor_lock_notifications
        - entity: input_boolean.frontdoor_dooraccess_notifications
  - type: custom:mod-card
    style: |
      ha-card {
        background-color: var(--champs-theme-primary);
        padding-right: 20px;
        padding-bottom: 10px;
        border-radius: 10px;
      }
    card:  
      type: custom:fold-entity-row
      head:
        type: section
        label: Lock Manager Override
      entities:
        - entity: input_boolean.system_ready  
        - entity: input_boolean.allow_automation_execution

lock_manager_button button-card template:

lock_manager_button:
  size: 25px
  show_state: true
  show_name: true
  styles:
    grid:
      - grid-template-areas: '"n" "i" "s"'
      - grid-template-columns: 1fr
      - grid-template-rows: min-content min-content min-content min-content
    card:
      - background-color: var(--champs-theme-primary)
      - border-radius: 10px
    name:
      - font-size: 14px
      - color: var(--champs-theme-names)
    state: 
      - font-size: 14px
    icon:
      - padding-bottom: 10px

  tap_action:
    action: none

Then, on my actual lock-manager page that the Front Door Codes and Configuration button navigates to looks like the images below. here i’m using button-card and button-card templates as well as browser-mod for the popups




lock-manager-lovelace.yaml

# lovelace_gen

###################################
#----------------------------------
#---- Lock Manager ----------------
#----------------------------------
###################################

- title: 'FrontDoor Codes and Configuration'
  path: keypad-frontdoor
  background: var(--background-image)
  icon: 'mdi:lock-smart'
  panel: true
  cards:
    # Main Container
    - type: custom:mod-card
      style: |
        ha-card {
          max-width: 1465px;
          padding: 10px;
          padding-bottom: 50px;
          margin: 10px auto;
        }
      card:
        type: vertical-stack
        cards:
          # start homepage header
          - type: custom:mod-card
            style: |
              ha-card {
                padding: 0px;
               background-color: var(--champs-theme-primary);
                --ha-card-background: transparent;
                border-radius: 10px;
                overflow: hidden;
              }
              @media only screen and (min-width: 1025px) {
                ha-card {
                  margin-top: 25px;
                  padding-top: 15px;
                  padding-bottom: 10px;
                }
              }
            card:
              type: custom:layout-card
              layout: horizontal
              column_width: 100%
              cards:
                #Header
                - !include
                  - ../partials/header.yaml
                  - title: Front Door Codes and Configuration
                    navigation_path: more-page

          - type: vertical-stack
            cards:
              # Lock Manager Status Buttons
              - !include ../champs-lovelace/cards/more-page/lock-manager-status-buttons.yaml
              
              # Lock Manager Overrides
              - !include ../champs-lovelace/cards/more-page/lock-manager-overrides.yaml

              # Lock Code Configuration
              - type: markdown
                content: "## Lock Code Config"
              - type: custom:layout-card
                layout: horizontal
                min_columns: 3
                cards:
                  - type: custom:button-card
                    name: "Code 1"
                    entity: binary_sensor.active_frontdoor_1
                    template: lock_manager_button
                    tap_action:
                      !include ../champs-lovelace/views/popups/lock-manager/code-1.yaml  
                  - type: custom:button-card
                    name: "Code 2"
                    entity: binary_sensor.active_frontdoor_2
                    template: lock_manager_button
                    tap_action:
                      !include ../champs-lovelace/views/popups/lock-manager/code-2.yaml
                  - type: custom:button-card
                    name: "Code 3"
                    entity: binary_sensor.active_frontdoor_3
                    template: lock_manager_button
                    tap_action:
                      !include ../champs-lovelace/views/popups/lock-manager/code-3.yaml
                  - type: custom:button-card
                    name: "Code 4"
                    entity: binary_sensor.active_frontdoor_4
                    template: lock_manager_button
                    tap_action:
                      !include ../champs-lovelace/views/popups/lock-manager/code-4.yaml
                  - type: custom:button-card
                    name: "Code 5"
                    entity: binary_sensor.active_frontdoor_5
                    template: lock_manager_button
                    tap_action:
                      !include ../champs-lovelace/views/popups/lock-manager/code-5.yaml
                  - type: custom:button-card
                    name: "Code 6"
                    entity: binary_sensor.active_frontdoor_6
                    template: lock_manager_button
                    tap_action:
                      !include ../champs-lovelace/views/popups/lock-manager/code-6.yaml
                  - type: custom:button-card
                    name: "Code 7"
                    entity: binary_sensor.active_frontdoor_7
                    template: lock_manager_button
                    tap_action:
                      !include ../champs-lovelace/views/popups/lock-manager/code-7.yaml
                  - type: custom:button-card
                    name: "Code 8"
                    entity: binary_sensor.active_frontdoor_8
                    template: lock_manager_button
                    tap_action:
                      !include ../champs-lovelace/views/popups/lock-manager/code-8.yaml
                  - type: custom:button-card
                    name: "Code 9"
                    entity: binary_sensor.active_frontdoor_9
                    template: lock_manager_button
                    tap_action:
                      !include ../champs-lovelace/views/popups/lock-manager/code-9.yaml
                  - type: custom:button-card
                    name: "Code 10"
                    entity: binary_sensor.active_frontdoor_10
                    template: lock_manager_button
                    tap_action:
                      !include ../champs-lovelace/views/popups/lock-manager/code-10.yaml
        

and each code popup is basically identical just referencing the appropriate code number entities. below is the code-10.yaml

# lovelace_gen

# popup for code config
haptic: heavy
action: call-service
service: browser_mod.popup
service_data:
  title: 'Code 10'
  style:
    background: var(--champs-theme-primary)
  card:
    type: entities
    show_header_toggle: false
    entities:
      - type: divider
      - entity: input_text.frontdoor_name_10
      - entity: input_text.frontdoor_pin_10
      - entity: input_boolean.enabled_frontdoor_10
      - entity: input_boolean.notify_frontdoor_10
      - type: divider
      - entity: binary_sensor.active_frontdoor_10
        state_color: true
      - type: divider
      - type: 'custom:fold-entity-row'
        head:
          type: section
          label: Advanced Options
        entities:
          - entity: input_boolean.reset_codeslot_frontdoor_10
          - type: divider
          - entity: input_boolean.accesslimit_frontdoor_10
          - entity: input_number.accesscount_frontdoor_10
          - type: divider
          - entity: input_boolean.daterange_frontdoor_10
          - entity: input_datetime.start_date_frontdoor_10
          - entity: input_datetime.end_date_frontdoor_10
          - type: divider
      - type: custom:fold-entity-row
        head:
          type: section
          label: 'Day of Week Access Breakdown'
        entities:
          - type: custom:fold-entity-row
            head:
              type: section
              label: 'Sun'
            entities: 
              - input_boolean.sun_frontdoor_10
              - input_boolean.sun_inc_frontdoor_10
              - input_datetime.sun_start_date_frontdoor_10
              - input_datetime.sun_end_date_frontdoor_10
          - type: custom:fold-entity-row
            head:
              type: section
              label: 'Mon'
            entities: 
              - input_boolean.mon_frontdoor_10
              - input_boolean.mon_inc_frontdoor_10
              - input_datetime.mon_start_date_frontdoor_10
              - input_datetime.mon_end_date_frontdoor_10
          - type: custom:fold-entity-row
            head:
              type: section
              label: 'Tues'
            entities: 
              - input_boolean.tue_frontdoor_10
              - input_boolean.tue_inc_frontdoor_10
              - input_datetime.tue_start_date_frontdoor_10
              - input_datetime.tue_end_date_frontdoor_10
          - type: custom:fold-entity-row
            head:
              type: section
              label: 'Weds'
            entities: 
              - input_boolean.wed_frontdoor_10
              - input_boolean.wed_inc_frontdoor_10
              - input_datetime.wed_start_date_frontdoor_10
              - input_datetime.wed_end_date_frontdoor_10
          - type: custom:fold-entity-row
            head:
              type: section
              label: 'Thurs'
            entities: 
              - input_boolean.thu_frontdoor_10
              - input_boolean.thu_inc_frontdoor_10
              - input_datetime.thu_start_date_frontdoor_10
              - input_datetime.thu_end_date_frontdoor_10
          - type: custom:fold-entity-row
            head:
              type: section
              label: 'Fri'
            entities: 
              - input_boolean.fri_frontdoor_10
              - input_boolean.fri_inc_frontdoor_10
              - input_datetime.fri_start_date_frontdoor_10
              - input_datetime.fri_end_date_frontdoor_10
          - type: custom:fold-entity-row
            head:
              type: section
              label: 'Sat'
            entities: 
              - input_boolean.sat_frontdoor_10
              - input_boolean.sat_inc_frontdoor_10
              - input_datetime.sat_start_date_frontdoor_10
              - input_datetime.sat_end_date_frontdoor_10
        
          
  deviceID:
    - this

the only other thing i might do is add the code user name to the button card, but yeah, overall. loving this package. hope this helps inspire others. I sure have had a ton of inspiration from those brighter than me on this forum over the years.

cheers!

3 Likes

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