Schlage Connect Locks - HA Integration Needs Attention

When you do that is it just verifying that your code is good, or is it comparing to your actual configuration.

Verifies your coding.

1 Like

@ptdalen I cannot wait to see. Iā€™ve been holding off on implementing the @nalipaz version due to my lack of confidence in translating it over to my instance. By the way @nalipaz I am BLOWN AWAY by what you implemented and think itā€™s amazing. I downloaded your package but have been short on time (we have a newborn at home) so i have not had any chance to really get into the nitty gritty to even attempt an implementation. Itā€™s also more advanced than anything i have done so i have no problem admitting the code in this is above my head.

Anyways, the more simplified version that youā€™re working on @ptdalen seems exactly what I am looking for at least to start. Just a basic lock manager to start really with the code management.

@nalipaz

Also I confirmed that setting the code to ā€˜0000ā€™ actually sets a code of 0000, which works for opening my door.

Iā€™m going to try the setting to a random number route

Current in your code

    action:
      - service: lock.set_usercode
        data_template:
          usercode: '0000'
          node_id: >-
            {% set object_id = trigger.to_state.object_id %}
            {% set lock_name = "_".join(object_id.split("_")[3:-1]) %}
            {% set lock_id = 'lock_' ~ lock_name ~ '_door_lock' %}
            {{ states['lock'][lock_id].attributes.node_id }}

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

What I am planning on changing it to

    action:
      - service: lock.set_usercode
        data_template:
          usercode: >-
            {{ range(1000, 9999) | random }}

          node_id: >-
            {% set object_id = trigger.to_state.object_id %}
            {% set lock_name = "_".join(object_id.split("_")[3:-1]) %}
            {% set lock_id = 'lock_' ~ lock_name ~ '_door_lock' %}
            {{ states['lock'][lock_id].attributes.node_id }}

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

Seems the 0000 clear code issue is with schlage locks and openzwave. The only way I was able to clear my codes, what to change the pin length to 6 and then back to 4. Well that or doing a reset on the deadbold, which i did not want to do.

So I want to get better at understanding how to use the templating menu, but the couple of timeā€™s Iā€™ve tried, it has not worked for me. 100% itā€™s me and not understanding.

For example I want see if I can changed this

    condition:
      - condition: or
        conditions:
          - 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 ~ '_access_schedule' %}
              {{ states['input_select'][select_id].state == 'Always'  }}
              
          - 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 ~ '_access_schedule' %}
              {{ states['input_select'][select_id].state == 'Enabled'  }}

into this

      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 ~ '_access_schedule' %}
              {{ states['input_select'][select_id].state == 'Always' or states['input_select'][select_id].state == 'Enabled' }}
``

When I paste the bottom bit of code, I get errors about trigger being unidentified, etc. How would I start with something like this?
      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 ~ '_access_schedule' %}
              {{ states['input_select'][select_id].state in ['Always', 'Enabled'] }}
1 Like

So how would I test something like that in the UI template testing area?

{% set object_id = trigger.to_state.object_id %} 
{% set code_slot = "_".join(object_id.split("_")[2:-2]) %} 
{% set select_id = 'door_keypad_' ~ code_slot ~ '_access_schedule' %} 
{{ states['input_select'][select_id].state == 'Enabled' }}

This is the bits you put in there to see the output. Youā€™d have to put something into the object_id = part tho.

Example:

{% set object_id = "lock.lock_front_door_locked" %}
{% set code_slot = "_".join(object_id.split("_")[2:-2]) %} 
{% set select_id = 'door_keypad_' ~ code_slot ~ '_access_schedule' %} 
{{ states['input_select'][select_id].state == 'Enabled' }}
2 Likes

You canā€™t with triggers :(. You can fake it out by changing your first line to something that returns an object ID

          {% set object_id = xxxxxxxxxxxxxxxxxxxxx.object_id %}
          {% set code_slot = "_".join(object_id.split("_")[2:-2]) %}
          {% set select_id = 'door_keypad_' ~ code_slot ~ '_access_schedule' %}
          {{ states['input_select'][select_id].state in ['Always', 'Enabled'] }}
2 Likes

@ptdalen @firstof9 So are these reliable? Iā€™ve been toying with the idea of getting one

I have a Kwikset 910, works great.

I have three Schlage Locks. Two BE469, and one FE599. Iā€™ve had them for a couple years. Previously I used them with smartthings, and they worked great. They are working good with HA as well, but of course a bit of work has been required to get some of the functions I missed from Smartthings.

As far as the most important functions to me : Locking and unlocking with HA, they are 99%. I lock any unlocked doors when I go to bed, unlock a door when I get home, etc.

Setting codes is a good feature, but for most people itā€™s something youā€™d only do once in a while. I can get into the UI services and just put in a quick bit of code and set a code super quick without the need for any fancy automation. This is more of cool stuff sort of thing.

Maybe running different automatons based on who unlocked a door is pretty cool too, for the most part I already know who is home based on Presence Sensors.

Another nice thing to remember with most of these, is they are not really ā€œtiedā€ to any Smart Home system. Even if there is no power, your codes will still unlock the doors. I actually stopped carrying my key about a year ago. Of course I have two doors with smart deadbolts and a dumb code gargage door opener as a failsafe. The odds of all three failing or running out of battery is pretty slim.

Also both the quickset and the schlage do go on sale once in a while. I think I paid $140 ish for mine and normal price was $200

do they require a ā€˜company loginā€™ and constant internet? Trying to keep my digital footprint small.

No, 100% local. Honeslty, they dont even require any sort of Home automation. codes can be entered 100% via keypad. Thatā€™s how I did mine for the first few months.

OK, So this is one that is new to me, Trying to borrow yaml from other areas

  - alias: Keypad set random code for one time use
    trigger:
      - platform: state
        to: 'Enabled'
        entity_id:
          - input_select.door_keypad_16_access_schedule
          - input_select.door_keypad_17_access_schedule
          - input_select.door_keypad_18_access_schedule
    action:
      - service: input_text.set_value
        data_template:
          entity_id: >-
                {% 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' %}
                {{ ['input_text'][user_code_id] }}
          value: '{{ range(1000, 9999) | random }}'

My intent is for this to populate the input text with a 4 digit number when I select enabled. But nothing is happening. Well the value changes to enabled, but the input_text never gets a value

Might be because I donā€™t understand how the range works? Or maybe something else is wrong? Any ideas?

I see this error in the log, so Iā€™m thinking its formatting
Invalid service data for input_text.set_value: Entity ID is an invalid entity id for dictionary value @ data[ā€˜entity_idā€™]. Got ā€˜ā€™

Edit:

Iā€™m thinking this is the issue??
{% set code_slot = ā€œ".join(object_id.split("ā€)[2:-2]) %}

And I finally used the template checker tool in the UI. :slight_smile:

This is retuning blank, so thatā€™s my issue, but why? :frowning:

                {% set object_id = 'input_select.door_keypad_16_access_schedule.object_id' %}
                {% set code_slot = "_".join(object_id.split("_")[2:-2]) %}
                {% set user_code_id = 'door_keypad_' ~ code_slot ~ '_code' %}
                {{ ['input_text'][user_code_id] }}

are you sure object_id is a valid attribute? are you trying to get the entity_id? If so:

  - alias: Keypad set random code for one time use
    trigger:
      - platform: state
        to: 'Enabled'
        entity_id:
          - input_select.door_keypad_16_access_schedule
          - input_select.door_keypad_17_access_schedule
          - input_select.door_keypad_18_access_schedule
    action:
      - service: input_text.set_value
        data_template:
          entity_id: >-
                {% set object_id = trigger.entity_id %} #This is the entity_id
                {% set code_slot = "_".join(object_id.split("_")[2:-2]) %}
                {% set user_code_id = 'door_keypad_' ~ code_slot ~ '_code' %}
                {{ ['input_text'][user_code_id] }}
          value: '{{ range(1000, 9999) | random }}'

EDIT: JUst for your own edification, here is the docā€™s that cover triggers and their attributes. Itā€™s in an odd spot, took me a while to find:

@ptdalen
Try this:

                {% set object_id = trigger.to_state.object_id %}
                {% set code_slot = "_".join(object_id.split("_")[3:-1]) %}
                {% set user_code_id = 'door_keypad_' ~ code_slot ~ '_code' %}
                {{ ['input_text'][user_code_id] }}

Unfortunatelty, the same results. Iā€™ll keep poking around and see what I find

Iā€™m having troubles getting this to work.

This

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

receives the following error
Invalid service data for input_text.set_value: Entity ID [ā€˜input_text.door_keypad_16_codeā€™] is an invalid entity id for dictionary value @ data[ā€˜entity_idā€™]. Got ā€œ[ā€˜input_text.door_keypad_16_codeā€™]ā€ and input_text.door_keypad_16_code is what the entity ID I am trying to set a value for.

              {% set object_id = 'input_select.door_keypad_16_access_schedule' %}
              {% set code_slot = "_".join(object_id.split("_")[3:-2]) %}
              {% set user_code_id = 'door_keypad_' ~ code_slot ~ '_code' %}
              {{ ['input_text'][user_code_id] }}

This returns blank value.

Iā€™ve been playing a lot with the template test section of the UI, but cannot seem to figure it out.

Here is the the entire section

    - service: input_text.set_value
      data_template:
        entity_id: >-
              {% set object_id = trigger.to_state.entity_id %}
              {% set code_slot = "_".join(object_id.split("_")[3:-2]) %}
              {% set user_code_id = 'input_text.door_keypad_' ~ code_slot ~ '_code' %}
              {{ [user_code_id] }}
        value: '{{ range(1000, 9999) | random }}'