KeyMaster Z-Wave lock manager and scheduler

Did you do this through the standalone UI for the control panel or through the integration by opening the webui? I would like to make this change also however I seem to be having a problem with zwave shutting down when trying to do it through the integration. Are there instructions on how to load the standalone UI?
**Edit - I figured out my issue with running the integrated OZW Admin panel. I had to increase the cache size for it to load and open.

Try dropping this file into the custom component directory and issue the service call lock-manager.generate_package then restart HA.



Lock Entities

My advice would be to manually unlock and lock the door. Then, take a look at the states for those entities and see which one is reporting the usercode_values. My assumption is it is one of the sensors listed, they just are not named intuitively. I think you’ll continue to get that error until you give the config form a sensor to use.

Would I then need to rename that sensor? I don’t get any options from the dropdown for usercode_values

Looks like it’s now using - input_text.frontdoor_status_report to store the value. Good news, it’s updating, bad news, it seems to be one action behind. haha. When I unlock the door, it shows what I did previously

Examples
UNlock deadbolt
lock deadbolt - Shows unlocked
use keypad unlock - Shows locked manually
Manually lock - shows - 5;Keypad Lock;1

All of the items above do show the proper values too, just did not have them hand to copy/paste

interesting, mine update immediately.

I’m getting the same results. Curious if your user notifications are reporting the same, mine are.

Adding a 3 second delay to the automation solves the issue. I’ll try setting to .5 seconds and see if that still works

EDIT: 500 miliseconds works for me and seems to work all the time

1 Like

On a side note (of course I manually entered all sensors directly

This seems to work (at least in the template area)

      

      front_door_report:
        friendly_name: 'Front Door'
        value_template: >
          {% set number = states('sensor.be469_touchscreen_deadbolt_user_code_frontdoor') %}
          {% set alarm_type_value = states('sensor.be469_touchscreen_deadbolt_access_control_frontdoor') %}
          {% set entity_id = 'input_text.door_keypad_' + number + '_name' %}
          {% set user = 'Master' if number == '0' else states(entity_id) %}
          {% set alarm_type_value = '24' if (as_timestamp(now())-as_timestamp(states.lock.be469_touchscreen_deadbolt_locked_frontdoor.last_changed)) < 15 and (as_timestamp(now())-as_timestamp(states.sensor.be469_touchscreen_deadbolt_access_control_frontdoor.last_changed)) > 15  and (states.lock.be469_touchscreen_deadbolt_locked_frontdoor.state) == 'locked' else alarm_type_value %}
          {% set alarm_type_value = '25' if (as_timestamp(now())-as_timestamp(states.lock.be469_touchscreen_deadbolt_locked_frontdoor.last_changed)) < 15 and (as_timestamp(now())-as_timestamp(states.sensor.be469_touchscreen_deadbolt_access_control_frontdoor.last_changed)) > 15  and (states.lock.be469_touchscreen_deadbolt_locked_frontdoor.state) == 'unlocked' else alarm_type_value %}
          {% set alarm_type_general_actions = {
            '1':'Manual Lock',
            '2':'Manual Unlock',
            '3':'RF Lock',
            '4':'RF Unlock',
            '7':'Manual not fully locked',
            '8':'RF not fully locked',
            '9':'Auto Lock locked',
            '10':'Auto Lock not fully locked',
            '11':'Lock Jammed',
            '16':'Keypad temporary disabled',
            '17':'Keypad busy' } %}
          {% set alarm_type_lock_actions = {
            '5':'Keypad Lock',
            '6':'Keypad Unlock' } %}
          {% set alarm_type_code_actions = {
            '12':'All User Codes Deleted',
            '13':'Single Code Deleted',
            '14':'New User Code Added',
            '15':'Duplicate Code' } %}         
          {% if alarm_type_value in alarm_type_code_actions %}
            {{ alarm_type_code_actions[alarm_type_value] }} (Code {{ number}})
          {% elif alarm_type_value in alarm_type_lock_actions and number == '0' %}
            {{ alarm_type_lock_actions[alarm_type_value] }} with Schlage Button
          {% elif alarm_type_value in alarm_type_lock_actions  %}
            {{ alarm_type_lock_actions[alarm_type_value] }} with Code {{ number }} ({{ user }})
          {% elif alarm_type_value in alarm_type_general_actions %}
            {{ alarm_type_general_actions[alarm_type_value] }}
          {% else %}
            Unknown Alarm Type Value {{ states('sensor.be469_touchscreen_deadbolt_access_control_frontdoor') }}
          {% endif %}

Edit works as a sensor in the package as well. No delay/automation needed

Just a heads up for everyone. The “status report” only generates when something occurs on the lock itself. For example, a user enters their PIN to open/close the deadbolt. Or the user presses the “close” button. Or the deadbolt is manually turned. However when a “lock/unlock” command is sent to the lock, that does NOT generate a report. But I’m looking into making this happen.

I have a dumb question. I was working on seeing if I could get my lockpackge updated as well, and ran into issues with the clear code. It works perfectly with your code, but not even with the services for me. What I am I doing wrong

This does not work
image

This work great

    - alias: frontdoor Clear Code
      condition:
        - condition: state
          entity_id: 'binary_sensor.allow_automation'
          state: 'on' 
      trigger:
        entity_id: binary_sensor.active_frontdoor_1
        platform: state
        to: 'off'
      action:
        - service: ozw.clear_usercode
          data_template:
            entity_id: lock.be469_touchscreen_deadbolt_locked_frontdoor
            code_slot: >-
                {% set object_id = trigger.to_state.object_id %}
                {% set index = object_id.rfind('_') + 1 %}
                {% set code_slot = object_id[index:] %}
                {{ code_slot  }}

And this was my code (lock was named differently at the time)

  - alias: Keypad switch turned off (Front Door)
    initial_state: true
    trigger:
      - platform: state
        to: 'off'
        entity_id:
          - input_boolean.door_keypad_1_front_switch
    condition:
      - condition: state
        entity_id: 'input_boolean.allow_zwave_automation_execution'
        state: 'on'
      - condition: template
        value_template:  >-
          {% set object_id = trigger.to_state.object_id %}
          {% set code_slot = "_".join(object_id.split("_")[2:-2]) %}
          {% set select_id = 'door_keypad_' ~ code_slot ~ '_front_slot' %}
          {{ (states['input_boolean'][select_id].state == 'on')}}
    action:
      - service: ozw.clear_usercode
        data_template:
          entity_id: lock.front_door
          code_slot: >-
            {% set object_id = trigger.to_state.object_id %}
            {% set code_slot = "_".join(object_id.split("_")[2:-2]) %}
            {{ code_slot }}

I verifed the conditions were good, it just did not clear, so then I tried to clear via services and nothing, then back to your package and it cleared the code as expected. Is there a trick I’m missing?

Actually after a lot of HA restarts, Docker restarts, OZW restarts, I’ve realized that the ozw.clear_usercode does not work consistantly for me. After the right reboot order it seems to work one or two times. I thought maybe it was because I renamed the entity. But I’ve tried quite a few possiblee scenarios and believe it’s the ozw.clear_usercode. I downloaded and connected MQTT explorer and watched commands get sent to the lock. Set user code shows a command sent 100% of the time. clear user code works once or twice and then the lock stops getting the commands. No messages at all. If I clear codes on different slots, it starts working (sometimes) again. Bottom line, for me I am not confident enough in the clear code for schlage locks enough to use that command. I think I’l go back to the less preferd setting a random (or specific code) for clearing, for a while.

Anyone else confirm this. Try setting and clearing the same slot multiple times. like 1 minute or so apart between actions.

EDIT: What I am noticing is that if I send clear user code to the same slot, even if I’ve loaded a code, that the clear command does not get sent. If I clear slot 1 and then clear slot 2, I can then clear slot 1 again. It seems as if OZW of HA will not send the command to the same slot twice, maybe a bug

You know, I was looking at this and I remembered that this was like this in the old 1.4 instance as well. I had kind of solved that with this

          {% set alarm_type_value = '3' if (as_timestamp(now())-as_timestamp(states.lock.front_door.last_changed)) < 15 and (as_timestamp(now())-as_timestamp(states.sensor.front_door_deadbolt_access_control.last_changed)) > 15  and (states.lock.front_door.state) == 'locked' else alarm_type_value %}
          {% set alarm_type_value = '4' if (as_timestamp(now())-as_timestamp(states.lock.front_door.last_changed)) < 15 and (as_timestamp(now())-as_timestamp(states.sensor.front_door_deadbolt_access_control.last_changed)) > 15  and (states.lock.front_door.state) == 'unlocked' else alarm_type_value %}

Basically if the lock changed but the access control did not change, you could be pretty sure the lock was unlocked by HA. But I’ve noticed my timestamps for the lock are not working anymore. Not sure if it’s an OZW, HA, or MQTT things, but when I put this in the template cheker

 {{ (as_timestamp(now())-as_timestamp(states.lock.front_door.last_changed)) }}

It does not reflect the last changed value correctly. My lock says state 10 seconds ago, the template above say 1100 seconds.

edit: neverrmind, was running template check on my main instance, not my test instance.

This is working for me including showing HA locks/unlocks in the sensor

  - platform: template
    sensors:
      front_door_report:
        friendly_name: 'Front Door'
        value_template: >
          {% set number = states('sensor.front_door_deadbolt_user_code') %}
          {% set alarm_type_value = states('sensor.front_door_deadbolt_access_control') %}
          {% set entity_id = 'input_text.door_keypad_' + number + '_name' %}
          {% set user = 'Master' if number == '0' else states(entity_id) %}
          {% set alarm_type_value = '3' if (as_timestamp(now())-as_timestamp(states.lock.front_door.last_changed)) < 15 and (as_timestamp(now())-as_timestamp(states.sensor.front_door_deadbolt_access_control.last_changed)) > 15  and (states.lock.front_door.state) == 'locked' else alarm_type_value %}
          {% set alarm_type_value = '4' if (as_timestamp(now())-as_timestamp(states.lock.front_door.last_changed)) < 15 and (as_timestamp(now())-as_timestamp(states.sensor.front_door_deadbolt_access_control.last_changed)) > 15  and (states.lock.front_door.state) == 'unlocked' else alarm_type_value %}
          {% set alarm_type_general_actions = {
            '1':'Manual Lock',
            '2':'Manual Unlock',
            '3':'RF Lock',
            '4':'RF Unlock',
            '7':'Manual not fully locked',
            '8':'RF not fully locked',
            '9':'Auto Lock locked',
            '10':'Auto Lock not fully locked',
            '11':'Lock Jammed',
            '16':'Keypad temporary disabled',
            '17':'Keypad busy' } %}
          {% set alarm_type_lock_actions = {
            '5':'Keypad Lock',
            '6':'Keypad Unlock' } %}
          {% set alarm_type_code_actions = {
            '12':'All User Codes Deleted',
            '13':'Single Code Deleted',
            '14':'New User Code Added',
            '15':'Duplicate Code' } %}
          {% if alarm_type_value in alarm_type_code_actions %}
            {{ alarm_type_code_actions[alarm_type_value] }} (Code {{ number}})
          {% elif alarm_type_value in alarm_type_lock_actions and number == '0' %}
            {{ alarm_type_lock_actions[alarm_type_value] }} with Schlage Button
          {% elif alarm_type_value in alarm_type_lock_actions  %}
            {{ alarm_type_lock_actions[alarm_type_value] }} with Code {{ number }} ({{ user }})
          {% elif alarm_type_value in alarm_type_general_actions %}
            {{ alarm_type_general_actions[alarm_type_value] }}
          {% else %}
            Unknown Alarm Type Value {{ states('sensor.front_door_deadbolt_access_control') }}
          {% endif %}

Feel free to use, ingnore, etc. :slight_smile:

Sorry noob here and trying to install it on my instance of HA, read the instructions and don’t think i’m doing this right. So I downloaded the file from github, saw that the lock-manager folder was in custom_components so I copied it there.

Renamed all the entities to include _frontdoor at the end, but I don’t see a packages directory in my config folder. Restarted HA, but nothing. What am I missing?

You need to go into Integrations and press the + type in lock-manager then follow the setup screen.

2 Likes

@firstof9 Thank you!

1 Like

I’m getting this error on the binary sensor and found a post that it was due to the platform not being added in the config, but that did not fix it. I have some TOD sensors, but maybe it’s something on my config?

Invalid config for [binary_sensor]: required key not provided @ data[‘platform’]. Got None. (See /config/configuration.yaml, line 122). Invalid config for [binary_sensor]: required key not provided @ data[‘platform’]. Got None. (See /config/configuration.yaml, line 122). Component error: system_ready - Integration ‘system_ready’ not found. Component error: night_mode - Integration ‘night_mode’ not found. Component error: allow_automation_execution - Integration ‘allow_automation_execution’ not found.
Invalid config for [binary_sensor.template]: required key not provided @ data[‘sensors’]. Got None. (See ?, line ?). Invalid config for [binary_sensor]: required key not provided @ data[‘platform’]. Got None. (See /config/configuration.yaml, line 122). Invalid config for [binary_sensor]: required key not provided @ data[‘platform’]. Got None. (See /config/configuration.yaml, line 122). Invalid config for [binary_sensor.template]: required key not provided @ data[‘sensors’]. Got None. (See ?, line ?). Invalid config for [binary_sensor]: required key not provided @ data[‘platform’]. Got None. (See /config/configuration.yaml, line 122). Invalid config for [binary_sensor]: required key not provided @ data[‘platform’]. Got None. (See /config/configuration.yaml, line 122). Component error: system_ready - Integration ‘system_ready’ not found. Component error: night_mode - Integration ‘night_mode’ not found. Component error: allow_automation_execution - Integration ‘allow_automation_execution’ not found.

Well I have narrowed it down to something with the way i’m adding the binary_sensor. The input_boolean is fine and I see it as a entity. I’ve tried adding platform: template, removing my TOD sensors, but no luck. Can anyone tell me what i’m doing wrong?

#Times of the Day binary sensor  
binary_sensor:
- platform: workday
  country: US
  workdays: [mon, tue, wed, thu, fri]
  excludes: [sat, sun, holiday]
  add_holidays:
    - '2020-10-09'
    - '2020-10-15'
    - '2020-10-16'

- platform: tod
  name: Early Morning
  after: sunrise
  after_offset: '-00:45'
  before: '08:00'

- platform: tod
  name: Morning
  after: '08:00'
  before: '12:00'

- platform: tod
  name: Afternoon
  after: '12:00'
  before: sunset
  before_offset: '-02:30'

- platform: tod
  name: Evening
  after: sunset
  after_offset: '-02:30'
  before: '20:30'

- platform: tod
  name: Night
  after: '20:30'
  before: '23:59'

- allow_automation:
  friendly_name: "Allow Automation"
  value_template: "{{ is_state('input_boolean.allow_automation_execution', 'on') }}"

- system_ready:
  friendly_name: "System ready"
  value_template: "{{ is_state('input_boolean.system_ready', 'on') }}"
  device_class: moving
  
input_boolean:
  good_night:
    name: Good Night
    icon: mdi:weather-night
    initial: off
  allow_automation_execution:
    name: 'Allow Automation'
    initial: off
  system_ready:
    name: 'System Ready'
    initial: off

You’re missing the platform.

- platform: template
  sensors:
    allow_automation:
      friendly_name: "Allow Automation"
      value_template: "{{ is_state('input_boolean.allow_automation_execution', 'on') }}"

    system_ready:
      friendly_name: "System ready"
      value_template: "{{ is_state('input_boolean.system_ready', 'on') }}"
      device_class: moving