KeyMaster Z-Wave lock manager and scheduler

Thanks joe_blow, i missed that post and it did help, but now I am getting:

Error rendering data template: str: Invalid entity ID ‘lock.LOCKFACTORYNAMEPREFIX_frontdoor’

I have renamed all my entities as *_frontdoor and regenerated the files many times. Anything else you can think of?

Look at your yaml in the packages folder. It looks like it does not actually have the lock name. It should not say “ock.LOCKFACTORYNAMEPREFIX_frontdoor” unless your lock is actually named “ock.LOCKFACTORYNAMEPREFIX_frontdoor”

Ahhh crap…ughhh so I was going through a previous thread tested sending the set lock commands from HA to my be469nx and it was setting the codes in my lock, but next steps were to start over and reinstall everything since I know HA is able to set the lock codes to the lock. I removed everything and went step by step, but now when I go to integrations click add and search for “lock-manager” I can’t see it anymore. The lock manager folder is in the custom_components folder, HA has been restarted.

did you add the custom repository back through HACS?

@joe_blow originally I copied the lock-manager folder to the custom_components, then on configuration > Integrations > + > ‘lock-manger’ it showed up there. I just played around adding it in HACS and was able to do so, but I don’t see a way to config it so that it generates the package folder?

does it appear as an integration in configuration -> integrations? If so, click “options” on the lock-manager card.

No it doesn’t show the manager card either. I tried clicking + to add it, but it doesn’t show up there either.

hard to tell what’s going on. I would manually delete the lock-manager folder from custom_components, delete the custom repository from HACS, and go through the steps again. If you use HACS there’s no need for any sort of manual install. The integration should be automatically added to the custom_components directory and in turn show up when you try to add it as in the screenshot above.

Thank you @joe_blow! I didn’t mess with anything in HACS initially when I first started. It just showed up in configuration > Integrations > +. I can see it without having to add the custom repository in HACS if I just copy the folder to the custom_configuration, but still acts the same. I’ll keep playing with it, but I appreciate the help.

@ptdalen I’m not sure why it generated like that, the rest of the yaml files generated with the correct lock name. I updated these and now I have a new error about it having no attribute.

frontdoor Clear Code: Error executing script. Unexpected error for call_service at pos 1: Error rendering data template: UndefinedError: 'None' has no attribute 'schlage_frontdoor_frontdoor'
While executing automation automation.frontdoor_clear_code
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 230, in async_render
    return compiled.render(kwargs).strip()
  File "/usr/local/lib/python3.8/site-packages/jinja2/environment.py", line 1090, in render
    self.environment.handle_exception()
  File "/usr/local/lib/python3.8/site-packages/jinja2/environment.py", line 832, in handle_exception
    reraise(*rewrite_traceback_stack(source=source))
  File "/usr/local/lib/python3.8/site-packages/jinja2/_compat.py", line 28, in reraise
    raise value.with_traceback(tb)
  File "<template>", line 1, in top-level template code
  File "/usr/local/lib/python3.8/site-packages/jinja2/sandbox.py", line 407, in getattr
    value = getattr(obj, attribute)
jinja2.exceptions.UndefinedError: 'None' has no attribute 'schlage_frontdoor_frontdoor'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 132, in async_prepare_call_from_config
    template.render_complex(config[CONF_SERVICE_DATA_TEMPLATE], variables)
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 74, in render_complex
    return {key: render_complex(item, variables) for key, item in value.items()}
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 74, in <dictcomp>
    return {key: render_complex(item, variables) for key, item in value.items()}
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 76, in render_complex
    return value.async_render(variables)
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 232, in async_render
    raise TemplateError(err)
homeassistant.exceptions.TemplateError: UndefinedError: 'None' has no attribute 'schlage_frontdoor_frontdoor'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 191, in _async_step
    await getattr(
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 352, in _async_call_service_step
    domain, service, service_data = async_prepare_call_from_config(
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 135, in async_prepare_call_from_config
    raise HomeAssistantError(f"Error rendering data template: {ex}") from ex
homeassistant.exceptions.HomeAssistantError: Error rendering data template: UndefinedError: 'None' has no attribute 'schlage_frontdoor_frontdoor'

looks like you might have an extra “_frontdoor” in your syntax. Just replace all instances of “lock.LOCKFACTORYNAMEPREFIX_frontdoor” with the exact entity id of your lock.

Press F5 on this screen prior to pressing the +

Good catch, I was doing a find and replace and forgot to remove that. It’s fixed now, but i’m still getting this no attribute error

frontdoor Add Code: Error executing script. Unexpected error for call_service at pos 1: Error rendering data template: UndefinedError: 'None' has no attribute 'schlage_frontdoor'
While executing automation automation.frontdoor_add_code
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 230, in async_render
    return compiled.render(kwargs).strip()
  File "/usr/local/lib/python3.8/site-packages/jinja2/environment.py", line 1090, in render
    self.environment.handle_exception()
  File "/usr/local/lib/python3.8/site-packages/jinja2/environment.py", line 832, in handle_exception
    reraise(*rewrite_traceback_stack(source=source))
  File "/usr/local/lib/python3.8/site-packages/jinja2/_compat.py", line 28, in reraise
    raise value.with_traceback(tb)
  File "<template>", line 1, in top-level template code
  File "/usr/local/lib/python3.8/site-packages/jinja2/sandbox.py", line 407, in getattr
    value = getattr(obj, attribute)
jinja2.exceptions.UndefinedError: 'None' has no attribute 'schlage_frontdoor'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 132, in async_prepare_call_from_config
    template.render_complex(config[CONF_SERVICE_DATA_TEMPLATE], variables)
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 74, in render_complex
    return {key: render_complex(item, variables) for key, item in value.items()}
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 74, in <dictcomp>
    return {key: render_complex(item, variables) for key, item in value.items()}
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 76, in render_complex
    return value.async_render(variables)
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 232, in async_render
    raise TemplateError(err)
homeassistant.exceptions.TemplateError: UndefinedError: 'None' has no attribute 'schlage_frontdoor'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 191, in _async_step
    await getattr(
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 352, in _async_call_service_step
    domain, service, service_data = async_prepare_call_from_config(
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 135, in async_prepare_call_from_config
    raise HomeAssistantError(f"Error rendering data template: {ex}") from ex
homeassistant.exceptions.HomeAssistantError: Error rendering data template: UndefinedError: 'None' has no attribute 'schlage_frontdoor'

@firstof9 & @joe_blow it’s weird, but I ended up restoring to a previous snapshot from a week ago and was going to reconfigure all the changes, but had to revert back to the snapshot today because I forgot what I used for a config I was doing and all and behold I was able to see the lock manager when I clicked + from integrations. Something quirky was going on.

can you post the frontdoor Add Code automation from your .yaml?

This one frontdoor_lock_manager_common.yaml?

## WARNING ##
# This file is auotmaticly generated, any changes
# will be overwritten.

##################################################  
################  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"

###################  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 UC = 'sensor.schlage_allegion_be469_touchscreen_deadbolt_alarm_level_frontdoor' %}
        {% set AC = 'sensor.schlage_allegion_be469_touchscreen_deadbolt_access_control_frontdoor' %}

        {% if (((as_timestamp(now()) - as_timestamp(states.UC.last_changed)) < 15) and ((as_timestamp(now()) - as_timestamp(states.AC.last_changed)) < 15)) %}

          {% set usercode_value = states(UC) %}
          {% set alarm_type_value = states(AC) %}

          {% if 'alarm_type' in AC %}
            {% 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' } %}
          {% elif 'access_control' in AC %}
            {% 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' } %}
          {% endif %}
          {% if alarm_type_value in alarm_type_code_actions %}
            {{alarm_type_value}};{{ alarm_type_code_actions[alarm_type_value] }};{{usercode_value}}
          {% elif alarm_type_value in alarm_type_lock_actions  %}
            {{alarm_type_value}};{{ alarm_type_lock_actions[alarm_type_value] }};{{usercode_value}}
          {% 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(AC) }}
          {% endif %}
        {% else %}
        {% 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}}"

###################  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.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.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: lock.set_usercode
          data_template:
            node_id: >- 
                {{states.lock.lock.schlage_frontdoor.attributes.node_id}}
            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: lock.set_usercode
          data_template:
            node_id: >- 
              {{states.lock.lock.schlage_frontdoor.attributes.node_id}}
            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: >-
              {{ range(1000, 9999) | random | int }}

    - 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
          # Check for Keypad Unlock code
          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) or (a[0] | int == 6)  }}
            {% 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] }}

is this an extra “.lock”? It appears in frontdoor Add Code and frontdoor Clear Code.

I have only one lock. The only thing I can think of is when I was trying to add the lock it would show up, but not accept commands and end up being I didn’t add the zwave security to my config.yaml. It ended up creating a duplicate of this lock, but no entities were created and was not able to figure out how to remove it. Maybe that is why it thinks I have a extra one?

Change states.lock.lock.schlage_frontdoor.attributes.node_id to states.lock.schlage_frontdoor.attributes.node_id

OMG! It works! Thank you @joe_blow!

I got one last thing throwing a error, which isn’t a huge deal, but if it’s easy do you know what this could be?

Could not render template frontdoor Status Report: str: Invalid domain name 'UC'

I’m assuming it’s this
image