Yet another Zwave Lock code manager

There are several packages out there for lock and code management, including one from me. What I have noticed is some people are really looking for just a simple way to set a code and clear a code. No need to one use, or calendars, etc. I also feel like I see many, many post from people looking for help because they are new to HA and don’t yet really understand what is really happening with these packages. I was one of those people. So since I’m sitting home like so many others. I took my lock package and stripped out anything fancy. This is basically, set a code ,clear a code. Get a notification if you want, and that about it. I have not tested it on my install, but it should work. I’m not posting on github, and don’t plan on keeping this updated. It’s for one lock only, and if you don’t want to edit the yaml, you’ll have to name your entities accordingly. Copy the code below, into a yaml file, put it in your packages folder. If you don’t know how to change the name of an entity, or what a package folder is, I recommend doing a bit more reading before continuing.

#################################################################
# For this to work Name your lock entities as follows            #
# lock.front_door                                               #
# sensor.front_door_deadbolt_alarm_type,                        #
# sensor.front_door_deadbolt_alarm_level                        #
# use the recorder component in your configuration.yaml         #
# For notifications I use pushbullet, but replace with          #
# notifyier of your choice if you wish.                         #
#################################################################
automation:
  - alias: Keypad switch turned on (Front Door)
    initial_state: true
    trigger:
      - platform: state
        to: 'on'
        entity_id:
          - input_boolean.door_keypad_1_front_switch
          - input_boolean.door_keypad_2_front_switch
          - input_boolean.door_keypad_3_front_switch
          - input_boolean.door_keypad_4_front_switch
          - input_boolean.door_keypad_5_front_switch
          - input_boolean.door_keypad_6_front_switch
          - input_boolean.door_keypad_7_front_switch
          - input_boolean.door_keypad_8_front_switch
          - input_boolean.door_keypad_9_front_switch
          - input_boolean.door_keypad_10_front_switch
          - input_boolean.door_keypad_11_front_switch
          - input_boolean.door_keypad_12_front_switch
          - input_boolean.door_keypad_13_front_switch
          - input_boolean.door_keypad_14_front_switch
          - input_boolean.door_keypad_15_front_switch

    condition:
      - 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 ~ '_code' %}
          {{ (states['input_text'][select_id].state != 'Code Here') }}

    action:
      - service: lock.set_usercode
        data_template:
          node_id: >-
            {{ states.lock.front_door.attributes.node_id }}
            
          code_slot: >-
            {% set object_id = trigger.to_state.object_id %}
            {% set code_slot = "_".join(object_id.split("_")[2:-2]) %}
            {{ code_slot }}

          usercode: >-
            {% set object_id = trigger.to_state.object_id %}
            {% set code_slot = "_".join(object_id.split("_")[2:-2]) %}
            {% set user_code_id = 'door_keypad_' ~ code_slot ~ '_code' %}
            {{ states['input_text'][user_code_id].state }}

  - alias: Keypad switch turned off (Front Door)
    initial_state: true
    trigger:
      - platform: state
        to: 'off'
        entity_id:
          - input_boolean.door_keypad_1_front_switch
          - input_boolean.door_keypad_2_front_switch
          - input_boolean.door_keypad_3_front_switch
          - input_boolean.door_keypad_4_front_switch
          - input_boolean.door_keypad_5_front_switch
          - input_boolean.door_keypad_6_front_switch
          - input_boolean.door_keypad_7_front_switch
          - input_boolean.door_keypad_8_front_switch
          - input_boolean.door_keypad_9_front_switch
          - input_boolean.door_keypad_10_front_switch
          - input_boolean.door_keypad_11_front_switch
          - input_boolean.door_keypad_12_front_switch
          - input_boolean.door_keypad_13_front_switch
          - input_boolean.door_keypad_14_front_switch
          - input_boolean.door_keypad_15_front_switch
    
    condition:
      - 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 ~ '_code' %}
          {{ (states['input_text'][select_id].state != 'Code Here') }}

    action:
# this is where usercodes get deleted, for the many locks there is a known issue with clear usercode
# so this sets a random code, of course that means there is an unknown code in the cleared
# slots.  If you dont like that set a specific code that only you know using - usercode: number_here
      - service: lock.set_usercode
        data_template:
          usercode: >-
            {{ range(1000, 9999) | random }}
          node_id: >-
            {{ states.lock.front_door.attributes.node_id }}

          code_slot: >-
            {% set object_id = trigger.to_state.object_id %}
            {% set code_slot = "_".join(object_id.split("_")[2:-2]) %}
            {{ code_slot }}

  - alias: Keypad switch turned on or off with no code set
    initial_state: true
    trigger:
      - platform: state
        to: 'on'
        entity_id:
          - input_boolean.door_keypad_1_front_switch
          - input_boolean.door_keypad_2_front_switch
          - input_boolean.door_keypad_3_front_switch
          - input_boolean.door_keypad_4_front_switch
          - input_boolean.door_keypad_5_front_switch
          - input_boolean.door_keypad_6_front_switch
          - input_boolean.door_keypad_7_front_switch
          - input_boolean.door_keypad_8_front_switch
          - input_boolean.door_keypad_9_front_switch
          - input_boolean.door_keypad_10_front_switch
          - input_boolean.door_keypad_11_front_switch
          - input_boolean.door_keypad_12_front_switch
          - input_boolean.door_keypad_13_front_switch
          - input_boolean.door_keypad_14_front_switch
          - input_boolean.door_keypad_15_front_switch

    condition:
      - 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 ~ '_code' %}
          {{ (states['input_text'][select_id].state == 'Code Here') }}

    action:
      - service: input_boolean.turn_off
        data_template:
          entity_id: > 
            {{ trigger.to_state.object_id }}
      - service: notify.pushover
        data_template:
          title: "No Code Entered"
          message: >-
             Please enter a name and a code before turning on the switch.  
          target:
          - YOUR NAME HERE
        
  - alias: Notify on Unlock (Front Door)
    initial_state: true
    trigger:
    - platform: template
      value_template: "{{ states.sensor.front_door_report.state.lower().startswith('keypad unlock') }}"
    action:
    - delay:
        seconds: 1
# This will set a a friendly name of whoever unlocked the door to input_text.front_door_code, use in other automations if you wish
    - service: input_text.set_value
      data_template:
        entity_id: input_text.front_door_code
        value: >
          {% set number = states('sensor.front_door_deadbolt_alarm_level') %}
          {% set entity_id = 'input_text.door_keypad_' + number + '_name' %}
          {% set user = 'Master' if number == '0' else states(entity_id) %}
          {{ user }}
    - condition: template
      value_template: >-
        {% set code_used = states('sensor.front_door_deadbolt_alarm_level') %}
        {% set notify_input_object_id = 'code_' ~ code_used ~ '_notify' %}
        {{ states['input_boolean'][notify_input_object_id].state == 'on' }}
    - service: notify.pushover
      data_template:
        title: "Front Door Unlocked"
        message: >-
           by {{ states.input_text.front_door_code.state }} at {{ as_timestamp (now()) | timestamp_custom('%I:%M %p') }} 
        target:
        - YOUR NAME HERE

input_text:
  front_door_code:
    name: Last Person to Unlock Front Door with Keypad

  door_keypad_1_name:
    name: Name
  door_keypad_1_code:
    name: Code
    pattern: '[0-9]*'
  door_keypad_2_name:
    name: Name
  door_keypad_2_code:
    name: Code
    pattern: '[0-9]*'
  door_keypad_3_name:
    name: Name
  door_keypad_3_code:
    name: Code
    pattern: '[0-9]*'
  door_keypad_4_name:
    name: Name
  door_keypad_4_code:
    name: Code
    pattern: '[0-9]*'
  door_keypad_5_name:
    name: Name
  door_keypad_5_code:
    name: Code
    pattern: '[0-9]*'
  door_keypad_6_name:
    name: Name
  door_keypad_6_code:
    name: Code
    pattern: '[0-9]*'
  door_keypad_7_name:
    name: Name
  door_keypad_7_code:
    name: Code
    pattern: '[0-9]*'
  door_keypad_8_name:
    name: Name
  door_keypad_8_code:
    name: Code
    pattern: '[0-9]*'
  door_keypad_9_name:
    name: Name
  door_keypad_9_code:
    name: Code
    pattern: '[0-9]*'
  door_keypad_10_name:
    name: Name
  door_keypad_10_code:
    name: Code
    pattern: '[0-9]*'
  door_keypad_11_name:
    name: Name
  door_keypad_11_code:
    name: Code
    pattern: '[0-9]*'
  door_keypad_12_name:
    name: Name
  door_keypad_12_code:
    name: Code
    pattern: '[0-9]*'
  door_keypad_13_name:
    name: Name
  door_keypad_13_code:
    name: Code
    pattern: '[0-9]*'
  door_keypad_14_name:
    name: Name
  door_keypad_14_code:
    name: Code
    pattern: '[0-9]*'
  door_keypad_15_name:
    name: Name
  door_keypad_15_code:
    name: Code
    pattern: '[0-9]*'

input_boolean:
  door_keypad_1_front_switch:
  door_keypad_2_front_switch:
  door_keypad_3_front_switch:
  door_keypad_4_front_switch:
  door_keypad_5_front_switch:
  door_keypad_6_front_switch:
  door_keypad_7_front_switch:
  door_keypad_8_front_switch:
  door_keypad_9_front_switch:
  door_keypad_10_front_switch:
  door_keypad_11_front_switch:
  door_keypad_12_front_switch:
  door_keypad_13_front_switch:
  door_keypad_14_front_switch:
  door_keypad_15_front_switch:

  code_1_notify:
    name: Notify when Used
  code_2_notify:
    name: Notify when Used
  code_3_notify:
    name: Notify when Used
  code_4_notify:
    name: Notify when Used
  code_5_notify:
    name: Notify when Used
  code_6_notify:
    name: Notify when Used
  code_7_notify:
    name: Notify when Used
  code_8_notify:
    name: Notify when Used
  code_9_notify:
    name: Notify when Used
  code_10_notify:
    name: Notify when Used
  code_11_notify:
    name: Notify when Used
  code_12_notify:
    name: Notify when Used
  code_13_notify:
    name: Notify when Used
  code_14_notify:
    name: Notify when Used
  code_15_notify:
    name: Notify when Used

sensor:
  - platform: template
    sensors:
      front_door_report:
        friendly_name: 'Front Door'
        value_template: >
          {% set number = states('sensor.front_door_deadbolt_alarm_level') %}
          {% set alarm_type_value = states('sensor.front_door_deadbolt_alarm_type') %}
          {% 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.front_door.last_changed)) < 15 and (as_timestamp(now())-as_timestamp(states.sensor.front_door_deadbolt_alarm_type.last_changed)) > 15  and (states.lock.front_door.state) == 'locked' else alarm_type_value %}
          {% set alarm_type_value = '25' if (as_timestamp(now())-as_timestamp(states.lock.front_door.last_changed)) < 15 and (as_timestamp(now())-as_timestamp(states.sensor.front_door_deadbolt_alarm_type.last_changed)) > 15  and (states.lock.front_door.state) == 'unlocked' else alarm_type_value %}
          {% 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_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_alarm_type') }}
          {% endif %}

script:
  door_keypad_1_delete:
    alias: Delete Door Code 1
    sequence:
    - service: input_text.set_value
      data:
        value: 'Name Here'
        entity_id: input_text.door_keypad_1_name
    - service: input_text.set_value
      data:
        value: 'Code Here'
        entity_id: input_text.door_keypad_1_code
    - service: input_select.select_option
      data:
        option: 'Disabled'
        entity_id: input_select.door_keypad_1_slot_state
    - service: input_boolean.turn_off
      entity_id:
      - input_boolean.door_keypad_1_front_switch
      - input_boolean.code_1_notify

  door_keypad_2_delete:
    alias: Delete Door Code 2
    sequence:
    - service: input_text.set_value
      data:
        value: 'Name Here'
        entity_id: input_text.door_keypad_2_name
    - service: input_text.set_value
      data:
        value: 'Code Here'
        entity_id: input_text.door_keypad_2_code
    - service: input_select.select_option
      data:
        option: 'Disabled'
        entity_id: input_select.door_keypad_2_slot_state
    - service: input_boolean.turn_off
      entity_id:
      - input_boolean.door_keypad_2_front_switch
      - input_boolean.code_2_notify

  door_keypad_3_delete:
    alias: Delete Door Code 3
    sequence:
    - service: input_text.set_value
      data:
        value: 'Name Here'
        entity_id: input_text.door_keypad_3_name
    - service: input_text.set_value
      data:
        value: 'Code Here'
        entity_id: input_text.door_keypad_3_code
    - service: input_select.select_option
      data:
        option: 'Disabled'
        entity_id: input_select.door_keypad_3_slot_state
    - service: input_boolean.turn_off
      entity_id:
      - input_boolean.door_keypad_3_front_switch
      - input_boolean.code_3_notify

  door_keypad_4_delete:
    alias: Delete Door Code 4
    sequence:
    - service: input_text.set_value
      data:
        value: 'Name Here'
        entity_id: input_text.door_keypad_4_name
    - service: input_text.set_value
      data:
        value: 'Code Here'
        entity_id: input_text.door_keypad_4_code
    - service: input_select.select_option
      data:
        option: 'Disabled'
        entity_id: input_select.door_keypad_4_slot_state
    - service: input_boolean.turn_off
      entity_id:
      - input_boolean.door_keypad_4_front_switch
      - input_boolean.code_4_notify

  door_keypad_5_delete:
    alias: Delete Door Code 5
    sequence:
    - service: input_text.set_value
      data:
        value: 'Name Here'
        entity_id: input_text.door_keypad_5_name
    - service: input_text.set_value
      data:
        value: 'Code Here'
        entity_id: input_text.door_keypad_5_code
    - service: input_select.select_option
      data:
        option: 'Disabled'
        entity_id: input_select.door_keypad_5_slot_state
    - service: input_boolean.turn_off
      entity_id:
      - input_boolean.door_keypad_5_front_switch
      - input_boolean.code_5_notify

  door_keypad_6_delete:
    alias: Delete Door Code 6
    sequence:
    - service: input_text.set_value
      data:
        value: 'Name Here'
        entity_id: input_text.door_keypad_6_name
    - service: input_text.set_value
      data:
        value: 'Code Here'
        entity_id: input_text.door_keypad_6_code
    - service: input_select.select_option
      data:
        option: 'Disabled'
        entity_id: input_select.door_keypad_6_slot_state
    - service: input_boolean.turn_off
      entity_id:
      - input_boolean.door_keypad_6_front_switch
      - input_boolean.code_6_notify

  door_keypad_7_delete:
    alias: Delete Door Code 7
    sequence:
    - service: input_text.set_value
      data:
        value: 'Name Here'
        entity_id: input_text.door_keypad_7_name
    - service: input_text.set_value
      data:
        value: 'Code Here'
        entity_id: input_text.door_keypad_7_code
    - service: input_select.select_option
      data:
        option: 'Disabled'
        entity_id: input_select.door_keypad_7_slot_state
    - service: input_boolean.turn_off
      entity_id:
      - input_boolean.door_keypad_7_front_switch
      - input_boolean.code_7_notify

  door_keypad_8_delete:
    alias: Delete Door Code 8
    sequence:
    - service: input_text.set_value
      data:
        value: 'Name Here'
        entity_id: input_text.door_keypad_8_name
    - service: input_text.set_value
      data:
        value: 'Code Here'
        entity_id: input_text.door_keypad_8_code
    - service: input_select.select_option
      data:
        option: 'Disabled'
        entity_id: input_select.door_keypad_8_slot_state
    - service: input_boolean.turn_off
      entity_id:
      - input_boolean.door_keypad_8_front_switch
      - input_boolean.code_8_notify

  door_keypad_9_delete:
    alias: Delete Door Code 9
    sequence:
    - service: input_text.set_value
      data:
        value: 'Name Here'
        entity_id: input_text.door_keypad_9_name
    - service: input_text.set_value
      data:
        value: 'Code Here'
        entity_id: input_text.door_keypad_9_code
    - service: input_select.select_option
      data:
        option: 'Disabled'
        entity_id: input_select.door_keypad_9_slot_state
    - service: input_boolean.turn_off
      entity_id:
      - input_boolean.door_keypad_9_front_switch
      - input_boolean.code_9_notify

  door_keypad_10_delete:
    alias: Delete Door Code 10
    sequence:
    - service: input_text.set_value
      data:
        value: 'Name Here'
        entity_id: input_text.door_keypad_10_name
    - service: input_text.set_value
      data:
        value: 'Code Here'
        entity_id: input_text.door_keypad_10_code
    - service: input_select.select_option
      data:
        option: 'Disabled'
        entity_id: input_select.door_keypad_10_slot_state
    - service: input_boolean.turn_off
      entity_id:
      - input_boolean.door_keypad_10_front_switch
      - input_boolean.code_10_notify

  door_keypad_11_delete:
    alias: Delete Door Code 11
    sequence:
    - service: input_text.set_value
      data:
        value: 'Name Here'
        entity_id: input_text.door_keypad_11_name
    - service: input_text.set_value
      data:
        value: 'Code Here'
        entity_id: input_text.door_keypad_11_code
    - service: input_select.select_option
      data:
        option: 'Disabled'
        entity_id: input_select.door_keypad_11_slot_state
    - service: input_boolean.turn_off
      entity_id:
      - input_boolean.door_keypad_11_front_switch
      - input_boolean.code_11_notify

  door_keypad_12_delete:
    alias: Delete Door Code 12
    sequence:
    - service: input_text.set_value
      data:
        value: 'Name Here'
        entity_id: input_text.door_keypad_12_name
    - service: input_text.set_value
      data:
        value: 'Code Here'
        entity_id: input_text.door_keypad_12_code
    - service: input_select.select_option
      data:
        option: 'Disabled'
        entity_id: input_select.door_keypad_12_slot_state
    - service: input_boolean.turn_off
      entity_id:
      - input_boolean.door_keypad_12_front_switch
      - input_boolean.code_12_notify

  door_keypad_13_delete:
    alias: Delete Door Code 13
    sequence:
    - service: input_text.set_value
      data:
        value: 'Name Here'
        entity_id: input_text.door_keypad_13_name
    - service: input_text.set_value
      data:
        value: 'Code Here'
        entity_id: input_text.door_keypad_13_code
    - service: input_select.select_option
      data:
        option: 'Disabled'
        entity_id: input_select.door_keypad_13_slot_state
    - service: input_boolean.turn_off
      entity_id:
      - input_boolean.door_keypad_13_front_switch
      - input_boolean.code_13_notify

  door_keypad_14_delete:
    alias: Delete Door Code 14
    sequence:
    - service: input_text.set_value
      data:
        value: 'Name Here'
        entity_id: input_text.door_keypad_14_name
    - service: input_text.set_value
      data:
        value: 'Code Here'
        entity_id: input_text.door_keypad_14_code
    - service: input_select.select_option
      data:
        option: 'Disabled'
        entity_id: input_select.door_keypad_14_slot_state
    - service: input_boolean.turn_off
      entity_id:
      - input_boolean.door_keypad_14_front_switch
      - input_boolean.code_14_notify

  door_keypad_15_delete:
    alias: Delete Door Code 15
    sequence:
    - service: input_text.set_value
      data:
        value: 'Name Here'
        entity_id: input_text.door_keypad_15_name
    - service: input_text.set_value
      data:
        value: 'Code Here'
        entity_id: input_text.door_keypad_15_code
    - service: input_select.select_option
      data:
        option: 'Disabled'
        entity_id: input_select.door_keypad_15_slot_state
    - service: input_boolean.turn_off
      entity_id:
      - input_boolean.door_keypad_15_front_switch
      - input_boolean.code_15_notify

I’m also not building out a lovelace for everyone. I think getting to know lovelace and customize it how you want is a bit part of HA. Here is a single, super simple lovelace for a single slot.

type: entities
title: Code Slot One
entities:
  - entity: input_text.door_keypad_1_name
  - entity: input_text.door_keypad_1_code
  - entity: input_boolean.code_1_notify
  - entity: input_boolean.door_keypad_1_front_switch
  - entity: script.door_keypad_1_delete

repeat for all 15 slots if you wish, or create your own how you want.

2 Likes

@ptdalen, thanks for this. I fit the criteria you describe pretty well.

I think I have installed the package correctly. However, since I have used my existing lock entity names in node red, I did a search and replace on the yaml code to change your entity names to mine.

When I run the configuration validation, I get

Error loading /config/configuration.yaml: invalid key: "OrderedDict([('trigger.to_state.object_id', None)])"
  in "/config/packages/simplelock/simplelock.yaml", line 136, column 0

I’ve no idea what that means, but I notice that it is right above the line with “notify.pushover”, which I assume is calling Pushbullet. If I don’t want notifications, can I just comment that “action:” section out?

You can absolutely comment out the pushover notifications. You could probably remove the entire automation if you don’t want notifications, or change the action to do anything you’d like other than notify.

Also if you dont mind, if you do get this working, (I never fully tested), can you report back on any other issues you run into? Thanks!

I would like to get this working and am happy to help as much as I can. So here’s where I am now. I have commented out lines 104 through 173, since they looked like the notification automations. I did not comment the rest of the automation section as it looked like that was used to set and clear the codes. The validation now yields

expected a dictionary for dictionary value @ data['packages']['automation']

It seems that this can be caused by an indentation error but I’m not seeing anything in the automation section.

Found another log that may be of more help

2020-04-20 21:10:36 ERROR (MainThread) [homeassistant.config] Invalid config for [homeassistant]: expected a dictionary for dictionary value @ data['packages']['automation']. Got [OrderedDict([('alias', 'Keypad switch turned on (Front Door)'), ('initial_state', True), ('trigger', [OrderedDict([('platform', 'state'
), ('to', 'on'), ('entity_id', ['input_boolean.door_keypad_1_front_switch', 'input_boolean.door_keypad_2_front_switch', 'input_boolean.door_keypad_3_front_switch', 'input_boolean.door_keypad_4_front_switch', 'input_boolean.door_keypad_5_front_switch', 'input_boolean.door_keypad_6_front_switch', 'input_boolean.door
_keypad_7_front_switch', 'input_boolean.door_k...                                                                                                                                                                                                                                                                          
expected a dictionary for dictionary value @ data['packages']['sensor']. Got [OrderedDict([('platform', 'template'), ('sensors', OrderedDict([('front_door_report', OrderedDict([('friendly_name', 'Front Door'), ('value_template', "{% set number = states('sensor.assa_abloy_yale_key_free_touchscreen_deadbolt_yrd446_a
larm_level_backdoor') %} {% set alarm_type_value = states('sensor.assa_abloy_yale_key_free_touchscreen_deadbolt_yrd446_alarm_type_backdoor') %} {% set entity_id = 'input_text.door_keypad_' + number + '_name' %} {% set user = 'Master' if number == '0' else sta.... (See /config/configuration.yaml, line 2). 

I have tried combing through this and coming up with similar errors when I try to check the config. If i don’t comment out the notification component I get the “invalid key” at line 136. If I comment this out then I get an error with invalid template. Did anyone get this to work?

Update - I commented out all the automatons and it works

I admit that I have not used the code I posted, but I pulled from my larger package. I believe the issue was some spacing around line 136. I think it’s fixed now, and II updated the yaml in post 1.

If it still does not work, try commenting out one automation at a time so to find the one with the error.

Hopefully it’s all good though. Let me know if it works for you.

Thanks for having a look at it. I tried adding each automation separately and the config check would produce these errors.

The add or remove code autoamtion -
Invalid config for [automation]: invalid template (TemplateSyntaxError: unexpected '>') for dictionary value @ data['condition'][0]['value_template']. Got None. (See ?, line ?).

The notification for no data in the fields automation -

Error loading /config/configuration.yaml: invalid key: "OrderedDict([('trigger.to_state.object_id', None)])"
  in "/config/packages/verysimplelock.yaml", line 44, column 0

The notify of unlock automation works well though but cant remember if i modified anything

  - alias: Notify on Unlock (Front Door)
    initial_state: true
    trigger:
    - platform: template
      value_template: "{{ states.sensor.front_door_report.state.lower().startswith('keypad unlock') }}"
    action:
    - delay:
        seconds: 1
# This will set a a friendly name of whoever unlocked the door to input_text.front_door_code, use in other automations if you wish
    - service: input_text.set_value
      data_template:
        entity_id: input_text.front_door_code
        value: >
          {% set number = states('sensor.front_door_alarm_level') %}
          {% set entity_id = 'input_text.door_keypad_' + number + '_name' %}
          {% set user = 'Master' if number == '0' else states(entity_id) %}
          {{ user }}
    - condition: template
      value_template: >-
        {% set code_used = states('sensor.front_door_alarm_level') %}
        {% set notify_input_object_id = 'code_' ~ code_used ~ '_notify' %}
        {{ states['input_boolean'][notify_input_object_id].state == 'on' }}
    - service: notify.mobile_app_sm_g950f
      data_template:
        title: "Front Door Unlocked"
        message: >-
           by {{ states.input_text.front_door_code.state }} at {{ as_timestamp (now()) | timestamp_custom('%I:%M %p') }}

The first few automations not working is not a big deal as I am working on using node red for these automations but I thought others might be having the same issue.

Cheers

1 Like

Hi All, Thought i would show how I modified this manager to make it a more streamlined UI. I created 3 more text inputs which are the only ones displayed on the UI. When you modify these and toggle the boolean it will then update the values of the associated entities. I have used node red for all the automation. I might integrate the more complicated versions in the future to then have date and interval ranges without having to have all the cards displayed.


1 Like

Very nice. On a side note, I fixed the automation section of the code posted above. I was missing a data template on line 136. I believe this should work as advertised now.

Edit: actually a few more typos and spacing. I am confident that now the automations should load without error.

1 Like