Show which code unlocked your Schlage lock (mostly solved)

So after seeing a lot of posts on here about people not being able to see their Schlage locks’ user codes (this issue focusing specifically on “which code was just used to unlock the front door?” issue), I decided to do a bit of research and poking, and I got it working for my setup.

The way this ends up working, is the lock (once securely paired) will provide an entityname_alarm_level and entityname_alarm_type whenever someone does something with the door. On my Schlage Camelot, model BE469NXCEN, these are how they work:

Alarm_type 18 means the door was locked by pressing the Schlage button.
Alarm_type 21 means the door was locked via the inside thumb turn.
Alarm_type 22 means the door was unlocked via the inside thumb turn
Alarm_type 19 means the door was unlocked via the keypad.

For entries where the Alarm_Type is 19, then the Alarm_Level on that same reading will return which slot the code came from. So, since I used HA to set the codes for my friends to the high-numbered lock slots, they won’t get overwritten if we, say, temporarily enter a code using the keypad method so our neighbor can watch our cat or something. You’ll need to know which codes are assigned to which slots in your lock to progress any further with this.

So, with the following template, I get myself a Sensor that tells me which of my friends unlocked the front door. Then you can just pop that sensor into a view, and then you can call it in a notify script using, with mine as an example,
{{ states.sensor.front_door_last_state.state }} to send the state.

One issue with this, that I am still working on but also don’t care that much about, is that when HA first restarts, this sensor template will be Unknown, so we have to account for that. Another one is that if you use ZWave to unlock/lock your Schlage, it will not update either of these values, so any automations calling this state will show the most recent value (usually a thumb turn, in my case)

Anyway, I ramble. Here be the template:

- platform: template
    sensors:
      front_door_last_state:
        friendly_name: Front Door Last Code
        entity_id:
          - sensor.front_door_alarm_type
          - sensor.front_door_alarm_level
        value_template: >-
          {% if is_state('sensor.front_door_alarm_type', '19') %}
            {% if is_state('sensor.front_door_alarm_level', '3') %}
              Unlocked by Deprecated Group Code
            {% elif is_state('sensor.front_door_alarm_level', '1') %}
              Unlocked by Us
            {% elif is_state('sensor.front_door_alarm_level', '27') %}
              Unlocked by Steph
            {% elif is_state('sensor.front_door_alarm_level', '25') %}
              Unlocked by Rachael
            {% elif is_state('sensor.front_door_alarm_level', '26') %}
              Unlocked by Kat
            {% elif is_state('sensor.front_door_alarm_level', '28') %}
              Unlocked by Ruth
            {% else %}
              Unlocked by an Untracked User Code            
            {% endif %}
          {% elif is_state('sensor.front_door_alarm_type', '18') %}
            Locked via Outside Button
          {% elif is_state('sensor.front_door_alarm_type', '21') %}
            Locked via Thumbturn
          {% elif is_state('sensor.front_door_alarm_type', '22') %}
            Unlocked via Thumbturn
          {% else %}
            Unknown due to HA restart          
          {% endif %}

Hope that helps someone else. I haven’t checked this forum in a month or two but Schlage help was scarce back then and probably still is now.

5 Likes

hejman08,

i can’t quite see how this works.

here is my configuration.

Current version of homeassistant
VeraPlus Version 1.7.3232
Schlage Lock Company BE468CAM605 Connect Camelot Touchscreen Deadbolt
The lock is connected to VeraPlus

Device shows up in homeassistant as:
lock.carport_door_lock_25
locked
Vera Device Id: 25
battery_level: 98
friendly_name: Carport Door Lock

I don’t see anywhere that homeassistant has sensors that are related to the lock.

What am i missing.

Thanks in advance

Yeah this took me a bit of fiddling to figure out. I managed to also find some z-wave lock documentation which should be consistent among z-wave locks here (useful info is on Page 4).

I decided to use two templates to track the “Action” and the “User” separate. That also allows me to track other statuses that are useful - like the “jammed” state which seems to be a general “something went wrong and the door didn’t lock” state. It is definitely useful - I’ve had the door fail to lock when I pressed the outside button and didn’t notice so I got a notification and went back to lock it manually.

The other thing I found in the documentation is that it definitely should track wireless lock/unlock but I’ve found that it doesn’t actually report that status (as you found).

Anyway here are my templates.

Action

  sidedoor_action:
    friendly_name: 'Side Door Action'
    value_template: >
      {% if is_state('sensor.side_door_alarm_type', '22') %}
        Manual Unlock
      {% elif is_state('sensor.side_door_alarm_type', '21') %}
        Manual Lock
      {% elif is_state('sensor.side_door_alarm_type', '19') %}
        Keypad Unlock
      {% elif is_state('sensor.side_door_alarm_type', '18') %}
        Keypad Lock
      {% elif is_state('sensor.side_door_alarm_type', '25') %}
        Wireless Unlock
      {% elif is_state('sensor.side_door_alarm_type', '24') %}
        Wireless Lock
      {% elif is_state('sensor.side_door_alarm_type', '9') %}
        Lock Jammed
      {% elif is_state('sensor.side_door_alarm_type', '161') %}
        Tamper Alarm
      {% else %}
        Other
      {% endif %}

User

  sidedoor_code:
    friendly_name: 'Side Door Code'
    value_template: >
      {% if is_state('sensor.side_door_alarm_type', '19') or is_state('sensor.side_door_alarm_type', '18') %}
        {% if is_state('sensor.side_door_alarm_level', '1') %}
          User1
        {% elif is_state('sensor.side_door_alarm_level', '2') %}
          User2
        {% elif is_state('sensor.side_door_alarm_level', '3') %}
          User3
        {% elif is_state('sensor.side_door_alarm_level', '4') %}
          User4
        {% else %}
          Unknown
        {% endif %}
      {% else %}
        n/a
      {% endif %}

Note the “N/A” which is basically “no code”.

Hopefully you find some of that interesting. I would love to hear if there are any solutions to the wireless lock/unlock but I’m not hopeful.

1 Like

Is the lock paired securely? I don’t know how to do that with Vera specifically - I’m using a Z Stick. It could be a limitation of Vera.

Until you all posted here, I was not aware of “secure” pairing. I have found some information on the vera site about secure pairing and will give it a go this pm.

http://wiki.micasaverde.com/index.php/Schlage_Lock

I have also submitted a support ticket to vera because my lock is a BE468 and their documentation indicates model BE469. I wonder if there is a difference from an integration/behavior perspective.

@athome Did you get anywhere with it?

I use VeraPlus as my z-wave hub and have confirmed with Vera that the integration with the Schlage BE468 / BE469 has defects.

Since I don’t have any zigbee devices, my plan is to replace the VeraPlus with a z-stick.

From Vera support:

NOV 25, 2017 | 03:10AM PST
Camelia replied:
Hello Frederick,

Sorry for the late response but I was out of office for few days.

If your door lock is paired with Vera unit you can go to the dashboard of the Vera unit then to Devices, go on the door lock and click the “>” button. After this on the top of the screen you will see a green bar, there you have the option “add pin codes”, you’ll have to click on it, add a name for the pin code,the pin code that you want and click on save.

To add notifications go on the door lock and click on “>” button, after that scroll down and there you have a menu for the door lock you have an option called “pin codes”, there is the list of all the pin codes added on the door lock, also in that menu you have the option called notification, once you click on that one you must select the type of notification that you want to create, add the name for it and which user should be notified.

To add restrictions you must on on the list of the pin codes, on the right side of the screen you have an option to add restriction and to delete the pin code from the list.

Also on the latest version of the firmware we have reported to our colleagues from the development that the nitifications are no longer received from the schlage soorlock and in order to work correctly you must doengrade the firmware version on the vera unit.
Please let me know if you have further questions and I will get back to you asap.

@athome thanks for that. I use a VeraPlus too, and have the BE469 lock. It works fine for me and even on the latest firmware…I get all the notifications it can throw at me, but that is the main issue, its only Vera that sends the notification. In HA, I just get the unlock/lock status, device ID and friendly name. I would love to have an event when the door is unlocked via PIN #.

One thing I have seen in the Vera forums, they are thinking of integrating with IFTTT, so maybe, and this would be a miracle for Vera folks to finally do something that everyone has been doing for a while, they will allow sending that notification to IFTTT, and if its there then I can send that back to HA.

The VeraPlus does have a USB port and I think you can instruct it to use that for a new z-wave network over the OOTB one, but I don’t feel like forking out for that in case it doesn’t work.

Quick question. More of a question about value templates, but it is related to code slot alerts.

will this work? I have 10 input_text values, so I can change names. It’s actually part of another automation setup that allows me to add/remove codes, as well. I figure I already have friendly names for the code slots, so why not use them. When I look at the value template examples for sensors, I dont see any that use the state of another sensor as the “output”, which is why I’m asking

      garagedoor_code:
        friendly_name: 'Garage Door Code'
        value_template: >
          {% if is_state('sensor.lock_garage_door_lock_alarm_type', '19') or is_state('sensor.lock_garage_door_lock_alarm_type', '18') %}
            {% if is_state('sensor.lock_garage_door_lock_alarm_level', '1') %}
              {{ states.input_text.door_keypad_1_name.state }}
            {% elif is_state('sensor.lock_garage_door_lock_alarm_level', '2') %}
              {{ states.input_text.door_keypad_2_name.state }}
            {% elif is_state('sensor.lock_garage_door_lock_alarm_level', '3') %}
              {{ states.input_text.door_keypad_3_name.state }}
            {% elif is_state('sensor.lock_garage_door_lock_alarm_level', '4') %}
              {{ states.input_text.door_keypad_4_name.state }}
            {% elif is_state('sensor.lock_garage_door_lock_alarm_level', '5') %}
              {{ states.input_text.door_keypad_5_name.state }}
            {% elif is_state('sensor.lock_garage_door_lock_alarm_level', '6') %}
              {{ states.input_text.door_keypad_6_name.state }}
            {% elif is_state('sensor.lock_garage_door_lock_alarm_level', '7') %}
              {{ states.input_text.door_keypad_7_name.state }}
            {% elif is_state('sensor.lock_garage_door_lock_alarm_level', '8') %}
              {{ states.input_text.door_keypad_8_name.state }}
            {% elif is_state('sensor.lock_garage_door_lock_alarm_level', '9') %}
              {{ states.input_text.door_keypad_9_name.state }}
            {% elif is_state('sensor.lock_garage_door_lock_alarm_level', '10') %}
              {{ states.input_text.door_keypad_10_name.state }}
            {% else %}
              Unknown
            {% endif %}
          {% else %}

Thanks

Replying to my own post., the answer is defintiely yes. I’m using the package from this post

and using this, I am able to get as the name I entered as the alert vs user 1, etc. I may try to combine these all together into a single package, might work well together

1 Like

planetawylie et. al.

Yes, i have made headway. Here is the trick. The VeraPlus does not expose all of the zwave attributes. I have move all of my z-wave devices off of VeraPlus over to an aeotec z-stick and the experience is very much improved. in addition to now having access to all of the schlage lock attributes, i also now have access to the battery level – including the schlage – from all of my battery powered aeotec devices. The move took a couple of days, but the dividend has been worth the effort.

2 Likes

Its definitely super easy to do this when directly paired with Hass. One of the attributes on my two Schlage locks will change to something like “Unlocked with code by User 2”. I just used a Node Red block to monitor that attribute for the “User X” text and assign an output to do whatever I want.

I think this is what I’m looking for. After struggling with my Schlage Lock for a while I finally realized that it had been paired un-securely and I was successfully able to add it back into my zwave network as a secure node. I can now see all 8 sensors and I’m ready to start taking advantage of the secure-add features like setting and getting user codes. I really want to send a notification when the door is unlocked to tell me how it was unlocked, and if it was unlocked with a code which code / which user.

I read through the templating section here https://www.home-assistant.io/docs/configuration/templating/ but I think I’m a bit over my head. I don’t yet understand what to do with your template code for action and user. Do I save those as separate files? How do I incorporate them into my config file? Mainly… how do I learn more about adding and using templates, I feel like I somehow missed 4 or 5 lessons and the templating section is creating more questions than it’s answering.

The code that I included in my comment above is from my configuration.yaml file. It’s under the “Sensor” section, so it starts like this:

sensor:
  - platform: template
    sensors:
        sidedoor_action:
          friendly_name: 'Side Door Action'

Then if you want another template sensor you do another one at the same indent as “sidedoor_action”, so that’s where you would put the code for “sidedoor_code” from my original post above.

Hope that helps!

extremely helpful, still figuring out the importance of the nuances of indentation. Thanks!