Some Schlage z-wave lock template sensor connfigurations

I was trying to come up with some useful abstracted views to how my z-wave lock works, and am currently giving this a spin. I’m using a Schlage BE469NXCEN Touchscreen DeadBolt lock and have been very pleased with it so far.

The battery level thing is something that’s been floating around a bit… Since a recent change to HASS about events not firing upon attribute change (vs. state change), I’m not sure how “reliable” this might be. It probably will only get updated when the lock changes state from locked to unlocked or similar. This might be close enough…

sensor frontdoorlock:
  - platform: template
    sensors:
      frontdoorbattery:
        # entity_id: zwave.front_door_lock_2
        entity_id: zwave.front_door_lock
        value_template: "{{ states.zwave.front_door_lock.attributes.battery_level }}"
        friendly_name: 'Front Door Lock Battery'
        unit_of_measurement: '%'

This bit is intended to capture the last user code used to operate the lock. While my lock is configured to only use an entered code to unlock (19), it also covers the case of a code that was used secure the lock (18).

      # this sensor is intended to capture the user number that was used during
      # the last operation that required a code to be entered.  it will persist
      # after subsequent other events (manual locking, etc.) that didn't involve
      # a user code
      front_door_code:
        friendly_name: Front Door Last Code
        entity_id:
          - sensor.front_door_lock_alarm_type
          - sensor.front_door_lock_alarm_level
        value_template: >-
          {% if is_state('sensor.front_door_lock_alarm_type', '18') or
                is_state('sensor.front_door_lock_alarm_type', '19') %}
            {% if not is_state('sensor.front_door_lock_alarm_level', '0') %}
              {{states('sensor.front_door_lock_alarm_level')}}
            {% else %}
              {# just provide previous value if no user code entered #}
              {{states('sensor.front_door_code')}}
            {% endif %}
          {% else %}
            {# just provide previous value if no user code entered #}
            {{states('sensor.front_door_code')}}
          {% endif %}

This is intended to capture a generic view on what state the lock is in, depending on what operations have been done to it.

      front_last_action:
        friendly_name: 'Front Door Last Action'
        entity_id:
          - sensor.front_door_lock_alarm_type
          - sensor.front_door_lock_alarm_level
        value_template: >-
          {% if is_state('sensor.front_door_lock_alarm_type', '18') %}
            {% if is_state('sensor.front_door_lock_alarm_level', '0') %}
          Locked: Outside Keypad
            {% else %}
          Locked: User {{states('sensor.front_door_lock_alarm_level')}}
            {% endif %}
          {% elif is_state('sensor.front_door_lock_alarm_type', '19') %}
            Unlocked: User Code {{states('sensor.front_door_lock_alarm_level')}}
          {% elif is_state('sensor.front_door_lock_alarm_type', '21') %}
            Locked: {{[ 'Outside Lock', 'Inside Deadbolt', 'Outside Keypad' ][states('sensor.front_door_lock_alarm_level')|int]}}
          {% elif is_state('sensor.front_door_lock_alarm_type', '22') %}
            Unlocked: Inside Deadbolt
          {% else %}
            Unknown: {{states('sensor.front_door_lock_alarm_type')}}/{{states('sensor.front_door_lock_alarm_level')}}
          {% endif %}

I wonder at times if this shouldn’t be tweaked to reflect the current state of the lock vs. what operation was performed. My lock doesn’t report back a reason for when it was locked or unlocked via z-wave command (as compared to operating the local locally.) So you can have this funky situation where the last action was “Locked: Inside Deadbolt”, but the door might actually be unlocked due to a z-wave initiated action…

Maybe this might be a useful example for someone…

9 Likes

thanks for this! Trying it out

Thanks for this. This helped with notifications for who was unlocking the door. It worked for me with the Schlage Connect BE469.

The automations are based on alarm_type: The following alarm types were the only ones witnessed and their meaning:
18: Locked by outside button
19: Unlocked by User (then get code)
21: Locked from inside (manual deadbolt lock)
22: Unlocked from inside (manual deadbolt unlock)
27: Auto lock after 30 seconds (if enabled)

4 Likes

for some reason, my alarm type and level don’t change when I unlock the door. Is there something you did to make it work?

The alarm types were changing for me when expected. Maybe the zwave did not sync correctly. I would remove the connection and reconnect via the lock. I remember having to do that twice before I got it properly set up. Also, make sure to restart the Home Assistant server after you sync it. For some reason I do not fully understand, once the server restarts the sensors and states are named and work correctly.