KeyMaster Z-Wave lock manager and scheduler

Alright let me try that. I really appreciate your help and your patience. I’ll be back with results.

EDIT: Ok, so when trying to regenerate the files through lock-manager.generate_package, I get the following error: Screen Shot 2020-07-29 at 23.23.24

Also, when going through the integration options, I get an Input Malformed error.

While you’re in the integrations menu, refresh your browser and try the options button again.

It worked, now I can set the options, but somehow my entities are unavailable now.

Mine did that as well, just had to do a quick HA restart to get it all working properly again.

The restart did it, however i’m back to where we were. I am able to send codes by calling the service but not through the overview. Could it be the lock I’m using?

Double check the ‘allow_automation’ bool it turns off on restart.

Still nothing, i got new notifications thogh, that’s new but still the code is not being sent to the lock :cold_sweat:

any errors showing up in the log?

yes, new error, I think it has something to do with OZW?

Looks like you grabed the OpenZwave beta version, you want the 0.0.4 version that one has the zwave.set_usercode commands. Easy fix just grab the version and run the generator again.

Im back with the status report error.Screen Shot 2020-08-01 at 22.16.31

Can you confirm line 50 says somethig like:
{% set number = states('sensor.mylockname_alarm_level_maindoor') %}

Yes it does.

If you copy and paste line 50 to line 95 into the dev-tools -> templates section you should be able to see where the error is coming from.

Example of working result:

I am really REALLY confused about what to download and put where. I need the ozw beta version (service: ozw.set_usercode). If I look at https://github.com/firstof9/lock-manager/tree/dev-ozw-beta it has a custom_components/lock manager directory but setup.sh is at the top level. It does have the correct lock_manager_common.txt with the requisite ozw.set_usercode If I look at GitHub - FutureTense/lock-manager: Home Assistant Lock Manager it does not have the same structure; it has the setup.sh and FrontDoor.ini in the same folder. If I go to https://github.com/firstof9/lock-manager/tree/dev-ozw-beta and use the URL for git clone, I end up with the version that uses lock.set_usercode.

1 Like

So I took another go at this. I did the above but replaced the lock_manager_common.txt with the code from the ozw_beta before I initiated the service call to initialize frontdoor. My frontdoor_lock_manager_common.yaml has the requisite ozw,set_usercode service calls but it’s not working… I can paste the code from the yaml after substituting code_slot: and usercode: into developer, service and the service call works…

##################################################
################  COMMON ENTITIES  ###############
##################################################

###############  input_boolean:  #################
input_boolean:
  frontdoor_lock_notifications:
    name: "Lock Notifications"
  frontdoor_dooraccess_notifications:
    name: "Door Notifications"
  frontdoor_garageacess_notifications:
    name: "Garage Notifications"
  frontdoor_reset_lock:
    name: "frontdoor reset lock"

############## binary_sensor:  ####################
binary_sensor:
- platform: template
  sensors:

    4in1_pir_sensor_access_control_frontdoor:
      value_template: "{{ is_state('sensor.4in1_pir_sensor_access_control_frontdoor', '22') }}"
      friendly_name: "frontdoor"
      device_class: door

    4in1_pir_sensor_burglar_frontdoor:
      value_template: "{{ is_state('sensor.4in1_pir_sensor_burglar_frontdoor', '3') }}"
      friendly_name: "frontdoor Sensor Tamper"
      device_class: safety

###################  sensor:  ####################
sensor:

- platform: time_date
  display_options:
    - 'time'
    - 'date'
    - 'date_time'
    - 'date_time_iso'
    - 'time_date'
    - 'time_utc'
    - 'beat'

- platform: template
  sensors:

    frontdoor_statusreport:
      friendly_name: 'frontdoor Status Report'
      value_template: >
          {% set number = states('sensor.zm1702_electronic_deadbolt_door_alarm_level_frontdoor') %}
          {% set alarm_type_value = states('sensor.zm1702_electronic_deadbolt_door_alarm_type_frontdoor') %}

          {% if ((as_timestamp(now())-as_timestamp(states.lock.zm1702_electronic_deadbolt_door_frontdoor.last_changed)) < 15 and (as_timestamp(now())-as_timestamp(states.sensor.zm1702_electronic_deadbolt_door_alarm_type_frontdoor.last_changed)) > 15) %}

          {%    if (states.lock.zm1702_electronic_deadbolt_door_frontdoor.state) == 'locked' %}
          {%       set alarm_type_value = '24' %}
          {%    elif (states.lock.zm1702_electronic_deadbolt_door_frontdoor.state) == 'unlocked' %}
          {%       set alarm_type_value = '25' %}
          {%    endif %}

          {% endif %}

          {% set alarm_type_general_actions = {
            '0':'No Status Reported',
            '9':'Lock Jammed',
            '17':'Keypad Lock Jammed',
            '21':'Manual Lock',
            '22':'Manual Unlock',
            '23':'HA Lock Jammed',
            '24':'HA Lock',
            '25':'HA Unlock',
            '26':'Auto Lock Jammed',
            '27':'Auto Lock',
            '32':'All Codes Deleted',
            '161':'Bad Code Entered',
            '167':'Battery Low',
            '168':'Battery Critical',
            '169':'Battery Too Low To Operate Lock' } %}
          {% set alarm_type_lock_actions = {
            '18':'Keypad Lock',
            '19':'Keypad Unlock',
            '162':'Lock Code Attempt Outside of Schedule' } %}
          {% set alarm_type_code_actions = {
            '33':'Code Deleted',
            '112':'Code Changed',
            '113':'Duplicate Code' } %}
          {% if alarm_type_value in alarm_type_code_actions %}
            {{alarm_type_value}};{{ alarm_type_code_actions[alarm_type_value] }};{{number}}
          {% elif alarm_type_value in alarm_type_lock_actions  %}
            {{alarm_type_value}};{{ alarm_type_lock_actions[alarm_type_value] }};{{number}}
          {% elif alarm_type_value in alarm_type_general_actions %}
            {{alarm_type_value}};{{ alarm_type_general_actions[alarm_type_value] }}
          {% else %}
            {{-1}};Unknown Alarm Type Value {{ states('sensor.zm1702_electronic_deadbolt_door_alarm_type_frontdoor') }}
          {% endif %}

###################  script    :  ####################
script:
  frontdoor_reset_lock:
    sequence:
      - service: script.frontdoor_manual_notify
        data_template:
          title: "reset"
          message: "frontdoor"

  frontdoor_conditional_notify:
    sequence:
      - condition: template
        value_template: >-
          {% set inputbool = boolean %}
          {% if states(inputbool) == 'on'%}
            true
          {% else %}
            false
          {% endif %}
      - service: script.frontdoor_manual_notify
        data_template:
          title: "{{title}}"
          message: "{{message}}"

  frontdoor_manual_notify:
    sequence:
      - service: notify.my_devices
        data_template:
          title: "{{title}}"
          message: "{{message}}"

######################################################

###################  automation:  ####################
automation:

    - alias: frontdoor Notifications
      trigger:
        platform: state
        entity_id: sensor.frontdoor_statusreport
      condition:
        - condition: state
          entity_id: 'binary_sensor.allow_automation'
          state: 'on'
        - condition: template
          value_template: >-
            {% set report = states.sensor.frontdoor_statusreport.state %}
            {% set a = report.split(';') %}
            {% if (a|length) != 3 or (a[2] == "0") %}
              {{ true }}
            {% else %}
              {{ true }}
            {% endif %}
      action:
        - service: script.frontdoor_conditional_notify
          data_template:
            boolean: input_boolean.frontdoor_lock_notifications
            title: "Sensor Status Report"
            message: >-
              {% set report = states.sensor.frontdoor_statusreport.state %}
              {% set a = report.split(';') %}
              {% set msg = "ID:" + a[0] + " MSG:" + a[1] %}
              {% if (a|length) == 3 %}
              {%   set msg = msg + " SLOT:" + a[2] %}
              {% endif %}
              {{ a[1] }}

    - alias: frontdoor User Notifications
      trigger:
        platform: state
        entity_id: sensor.frontdoor_statusreport
      condition:
        - condition: state
          entity_id: 'binary_sensor.allow_automation'
          state: 'on'
        - condition: template
          value_template: >-
            {% set report = states.sensor.frontdoor_statusreport.state %}
            {% set a = report.split(';') %}
            {% if (a|length) == 3 and (a[2] | int > 0) %}
              {{ true }}
            {% else %}
              {{ false }}
            {% endif %}
        - condition: template
          value_template: >-
            {% set report = states.sensor.frontdoor_statusreport.state %}
            {% set a = report.split(';') %}
            {% set entity_id = 'notify_frontdoor_' + a[2] %}
            {% set notify = states['input_boolean'][entity_id].state %}
            {{ notify == "on" }}
      action:
        - service: script.frontdoor_manual_notify
          data_template:
            title: >-
              {% set report = states.sensor.frontdoor_statusreport.state %}
              {% set a = report.split(';') %}
              {{ a[1] }}
            message: >-
              {% set report = states.sensor.frontdoor_statusreport.state %}
              {% set a = report.split(';') %}
              {% set entity_id = 'input_text.frontdoor_name_' + a[2] %}
              {% set user = states(entity_id) %}
              {{ user }}

###############################
    - alias: frontdoor Sensor Close
      condition:
        - condition: state
          entity_id: 'binary_sensor.allow_automation'
          state: 'on'
      trigger:
        entity_id: binary_sensor.4in1_pir_sensor_access_control_frontdoor
        platform: state
        to: 'off'
      action:
        - service: script.frontdoor_conditional_notify
          data_template:
            boolean: input_boolean.frontdoor_dooraccess_notifications
            title: "frontdoor"
            message: "Closed"

    - alias: frontdoor Sensor Opened
      condition:
        - condition: state
          entity_id: 'binary_sensor.allow_automation'
          state: 'on'
      trigger:
        entity_id: binary_sensor.4in1_pir_sensor_access_control_frontdoor
        platform: state
        to: 'on'
      action:
        - service: script.frontdoor_conditional_notify
          data_template:
            boolean: input_boolean.frontdoor_dooraccess_notifications
            title: "frontdoor"
            message: "Opened"

    - alias: frontdoor Add Code
      condition:
        - condition: state
          entity_id: 'binary_sensor.allow_automation'
          state: 'on'
      trigger:
        entity_id: binary_sensor.active_frontdoor_1,binary_sensor.active_frontdoor_2,binary_sensor.active_frontdoor_3,binary_sensor.active_frontdoor_4,binary_sensor.active_frontdoor_5
        platform: state
        to: 'on'
      action:
        - service: ozw.set_usercode
          data_template:
            entity_id: lock.zm1702_electronic_deadbolt_door_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  }}
            usercode: >-
                {% set object_id = trigger.to_state.object_id %}
                {% set index = object_id.rfind('_') + 1 %}
                {% set code_slot = object_id[index:] %}
                {% set codetext = 'frontdoor_pin_' + code_slot | string %}
                {% set code = states['input_text'][codetext].state %}
                {{ code | string }}

    - alias: frontdoor Update Code
      trigger:
        entity_id: input_text.frontdoor_pin_1,input_text.frontdoor_pin_2,input_text.frontdoor_pin_3,input_text.frontdoor_pin_4,input_text.frontdoor_pin_5
        platform: state
      condition:
        - condition: state
          entity_id: 'binary_sensor.allow_automation'
          state: 'on'
        - condition: template
          value_template: >-
            {% set object_id = trigger.to_state.object_id %}
            {% set index = object_id.rfind('_') + 1 %}
            {% set code_slot = object_id[index:] %}
            {% set b = 'input_boolean.enabled_frontdoor_' + code_slot | string %}
            {{ is_state(b, 'on') and (trigger.from_state.state != trigger.to_state.state)}}
      action:
        - service: persistent_notification.create
          data_template:
            title: "frontdoor LOCK MANAGER"
            message: >-
              {% set object_id = trigger.to_state.object_id %}
              {% set index = object_id.rfind('_') + 1 %}
              {% set code_slot = object_id[index:] %}
              {{ 'You changed the PIN for code  ' + code_slot | string + '. Please enable it in order to make it active.'}}
        - service: input_boolean.turn_off
          data_template:
            entity_id: >-
              {% set object_id = trigger.to_state.object_id %}
              {% set index = object_id.rfind('_') + 1 %}
              {% set code_slot = object_id[index:] %}
              {{ 'input_boolean.enabled_frontdoor_' + code_slot | string }}

    - alias: Reset frontdoor
      condition:
        - condition: state
          entity_id: 'binary_sensor.allow_automation'
          state: 'on'
      trigger:
        entity_id: input_boolean.frontdoor_reset_lock
        platform: state
        from: 'off'
        to: 'on'
      action:
        - service: script.frontdoor_reset_lock
        - service: input_boolean.turn_off
          entity_id: input_boolean.frontdoor_reset_lock

    - alias: frontdoor Clear Code
      condition:
        - condition: state
          entity_id: 'binary_sensor.allow_automation'
          state: 'on'
      trigger:
        entity_id: binary_sensor.active_frontdoor_1,binary_sensor.active_frontdoor_2,binary_sensor.active_frontdoor_3,binary_sensor.active_frontdoor_4,binary_sensor.active_frontdoor_5
        platform: state
        to: 'off'
      action:
        - service: ozw.clear_usercode
          data_template:
            entity_id: lock.zm1702_electronic_deadbolt_door_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  }}

    - alias: frontdoor Decrement Access Count
      trigger:
        platform: state
        entity_id: sensor.frontdoor_statusreport
      condition:
        - condition: state
          entity_id: 'binary_sensor.allow_automation'
          state: 'on'
        - condition: template
          value_template: >-
            {% set report = states.sensor.frontdoor_statusreport.state %}
            {% set a = report.split(';') %}
            {% if (a|length) == 3 and (a[2] | int > 0) %}
               {{ (a[0] | int == 19) }}
            {% else %}
              {{ false }}
            {% endif %}
      action:
        - service: input_number.decrement
          data_template:
            entity_id: >-
              {% set report = states.sensor.frontdoor_statusreport.state %}
              {% set a = report.split(';') %}
              {{ 'input_number.accesscount_frontdoor_' + a[2] }}

h e l p ! ! !

Stand by, @FutureTense and I are working on updating his repo, you’ll be able to use his shortly.

I resolved my issue…
There was a typo in one input_boolean:
input_boolean.allow_automation_execution
was input_boolean.allow_aautomation_execution
I fixed that and set it to on and now I can use the UI to set codes!
My overlay of lock_manager_common.txt from the ozw_beta worked.

1 Like

Now to figure out how to get the latest log record from this Vision ZM1702 lock. In HomeSeer there was a child device “Get latest record” and when that was activated, the last notification record was retrieved from the log which updated another child device “Notifications”. I had events that triggered on lock state change that would activate get latest record which then populated the Notification device. With my Kwikset Smartcode deadbolt I did not have to do that in HS as it automatically sent the latest record to the Notification device. However, I do not see anything like this in OpenZWave for these locks. I haven’t set up the Kwikset in LOCK MANAGER yet to see if it behaves differently than the Vision. The long and short of it is, I do not see which code unlocked the door and when or how the door was last unlocked…

Sounds like this lock behaves fundamentally different than the Schlage lock. The status report sensor is geared towards the Schlage lock, and is kind of the glue of this entire project. Have you looked at @ptdalen project and see if your lock is supported? If so, we can probably handle yours too.