Schlage Connect ZWave Locks

Does anyone know how to debug openzwave? It is crashing periodically but I don’t see any crash log or such.

@Matthew_Noecker, are you still trying to get alarm level to “reset” back to 0? I created a template sensor to give me this functionality and can share it if you are still looking to do this.

I’d love to see that as well. :slight_smile:

As we’ve seen, alarm_level stays constant until a different value of alarm_level is set. So it is useful for seeing the last code that was entered, but not useful for triggering new automations each time a code is entered, if it is the same code as what was previously entered.

A template sensor works around this. First, you must create a time_date sensor if you don’t already have one.

sensor:

  - platform: time_date
          display_options:
            - 'date_time'

Then your template sensor can look like this:

  - platform: template
    sensors:
      template_door_code_entered:
        value_template: >-
          {% if ((as_timestamp(strptime(states.sensor.date__time.state, "%Y-%m-%d, %H:%M")) - as_timestamp(states.sensor.schlage_fe599gr_wireless_door_lock_alarm_level.last_changed)) < 1) %}
            {{ states.sensor.schlage_fe599gr_wireless_door_lock_alarm_level.state }}
          {% else %}
            0
          {% endif %}

The template_door_code_entered will update to the alarm_level for the code just entered and stay that way for up to a minute, until the date__time sensor updates again. At that time the template_door_code_entered returns to 0. So you can trigger automations by looking for when template_door_code_entered is a valid code (valid codes are 1-254 or whatever upper limit for the number of codes a Schlage can store) and trigger automations for “wrong code entered” when template_door_code_entered goes to 255.

Note: I don’t know why sensor.date__time has a double underscore but that is the correct syntax for it to work in hass.

4 Likes

That is a great code snippet @kap! Thanks. I have a Schlage FE599 Z-Wave lock and the following seems to be working for me. The lock is on my garage door and the “template_door_code_entered” shown above was the missing link for me. This allows detection of user codes when the same code is used multiple times in a row.

The following code is in my automations.yaml file:

  - id: garage_remote_actvity_detection
    alias: "Garage Door Lock Remote Activity"
    # Any change in lock state, lock or unlock
    trigger:
      - platform: state
        entity_id: lock.garage_entry_door
    # Ensure user code has not been entered
    condition:
      condition: state
      entity_id: sensor.garage_door_code_entered
      state: '0'
    # input_select is used for tracking
    action:
      - service: input_select.select_option
        data_template:
          entity_id: input_select.lock_hass_status_for_garage_entry_door_lock
          option: >
            {% if is_state("lock.garage_entry_door", "locked") %}
              Locked by Home Assistant
            {% else %}
              Unlocked by Home Assistant
            {% endif %}
            
  ## When door is locked and set to Auto Re-Lock, the lock state doesn't toggle when user codes are entered
  - id: garage_code_used
    alias: "Garage Lock Code Used"
    ## leaving a value of zero indicates a user code was entered
    trigger:
      - platform: state
        entity_id: sensor.garage_door_code_entered
        from: '0'
    action:
      - service: input_select.select_option
        data:
          entity_id: input_select.lock_hass_status_for_garage_entry_door_lock
          option: Unlocked At Door

The following code is in my configuration.yaml file:

The input select is used to track operations performed by home assistant. It is used by a template sensor.

input_select:
  lock_hass_status_for_garage_entry_door_lock:
    name: Garage Door Lock HASS Status
    icon: mdi:lock
    options:
      - Locked by Home Assistant
      - Unlocked by Home Assistant
      - Unlocked At Door
      - Other

This is based on the code from @kap that detects when a user code is entered.

- platform: template
  sensors:
    garage_door_code_entered:
      value_template: >-
        {% if ((as_timestamp(strptime(states.sensor.date__time.state, "%Y-%m-%d, %H:%M")) - as_timestamp(states.sensor.garage_entry_door_alarm_level.last_changed)) < 1) %}
          {{ states.sensor.garage_entry_door_alarm_level.state }}
        {% else %}
          0
        {% endif %} 

The sensor below is what I use to display the locks current status and is used for automation triggers:

- platform: template
  sensors:
    garage_entry_door_last_action:
      friendly_name: 'Garage Entry Door Last Action'
      value_template: > 
                        {% if is_state('input_select.lock_hass_status_for_garage_entry_door_lock', 'Unlocked by Home Assistant') %}
                          Remotely Unlocked
                        {% elif is_state('input_select.lock_hass_status_for_garage_entry_door_lock', 'Locked by Home Assistant') %}
                          Remotely Locked
                        {% elif is_state('sensor.garage_door_code_entered', '0') %}
                          {% if is_state('lock.garage_entry_door', 'locked') %}
                            Auto Re-Locked
                          {% else %}
                            Unlocked by Ghost
                          {% endif %}
                        {% elif is_state('sensor.garage_entry_door_alarm_type', '16') %}
                          {% if is_state('sensor.garage_entry_door_alarm_level', '3') %}
                              Unlocked: Family Code
                          {% elif is_state('sensor.garage_entry_door_alarm_level', '4') %}
                              Unlocked: Friend Code
                          {% else %}
                            Unlocked: User Code {{states('sensor.garage_entry_door_alarm_level')}}
                          {% endif %}
                        {% else %}
                          {{ states.lock.garage_entry_door.attributes.lock_status }}
                        {% endif %}

I have a slightly different implementation for a Schlage Deadbolt Lock (BE469 Camelot)

      front_door_deadbolt_last_action:
        friendly_name: 'Front Door Last Action'
        value_template: >- 
                          {% if is_state('input_select.lock_hass_status_for_front_door_lock', 'Unlocked by Home Assistant') %}
                            Remotely Unlocked
                          {% elif is_state('input_select.lock_hass_status_for_front_door_lock', 'Locked by Home Assistant') %}
                            Remotely Locked
                          {% elif is_state('sensor.front_door_deadbolt_access_control', '6') and is_state('sensor.front_door_deadbolt_alarm_type', '19') %}
                            {% set door_lock_state = states('lock.front_door_deadbolt') %}
                            {% set alarm_level = states('sensor.front_door_deadbolt_alarm_level') %}
                            {% if is_state('sensor.front_door_deadbolt_alarm_level', '1') %}
                              {{ door_lock_state }} : Family Code
                            {% else %}
                              {{ door_lock_state }} : User Code {{ alarm_level }}
                            {% endif %}
                          {% else %}
                            {{ states.lock.front_door_deadbolt.attributes.notification }}
                          {% endif %}

How do you remove node 1 from the 1st group? I don’t see a way to do that.

this sorta confused me as well, but it actually made sense once I figured it out. Select your zwave node that you want to change the association on, select group1, then select the node1 (presumably your zwave stick), then you’ll see an option for ‘Remove from group’

1 Like

Thank you so much for the ultra fast response. That worked exactly as you described.

haha, np - the only reason why I responded so quickly was because I literally was on this thread doing this exact same thing.

I have the FE599 and the BE469 as well. I’ve always found the 599 to be problematic. Are you saying you are able to determine which code was used to unlock the 599 even if it is the same person each time. That was always my issue with the lock, so I ended up just giving up and moving on since most the time I automate the unlocking of this lock anyway.

I did add the lock a while back to group 2, but never removed it from group 1 is that the “trick”

Nevermind: I missed the previous post with the template. Great Idea, definitely gonna implement this in my config.

I have started a new thread that is specific to the FE599 lock and issues that I am experiencing.

Thank you for sharing this info on how to get the BE369 and FE599 Schlage locks working properly with Home Assistant and reporting their state. This was the last bit of info I needed to completely retire my old vera2.

No problem, glad to help. I’m hoping eventually that can be fixed within OpenZWave (or HA) but haven’t had time to dig into that.

I noticed you set a network key by using the code ```
$ cat /dev/urandom | tr -dc ‘0-9A-F’ | fold -w 32 | head -n 1 | sed -e ‘s/(…)/0x\1, /g’ -e ‘s/, $//’

Thank you for this,

I was successfully able to add my Schlage Century Connect and can lock/unlock from Home Assistant.

How do I add/delete user codes from HA?

Would love to know if this is possible through HA as well. I currently use SmartThings to add/delete/assign codes.

There absolutely is, I have this up & running

1 Like

Oh wow, had no idea… Thanks for sharing!

Just make sure you read all the instructions thoroughly. I had an issue where I couldn’t change codes but I found the naming of the lock entity was wrong in the instructions. Look towards the bottom and you will see my posts.

Make sure you exclude the lock from Smart Things then factory reset it before adding to HA. Also make sure you generate the secure network key

1 Like