Schlage Connect Locks - HA Integration Needs Attention

Got it! Keeping old text just for refrence for others on what works and what did not work

    - 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 }}'

This is one of the last items, I cannot understand whatā€™s going. Just never seems to trigger. Overall I want it to trigger on any of these three entiys are a value ot 16, 17, or 18. I figure Iā€™d use a condition. I commented out the condition for testing, and it still did not run, so I figure there is something wrong with my trigger

  - alias: Keypad clear code after one time use code is used for 16 through 18
    trigger:
      - platform: state
        entity_id:
          - sensor.lock_front_door_deadbolt_alarm_level
          - sensor.lock_back_door_deadbolt_alarm_level
          - sensor.lock_garage_door_lock_alarm_level

    condition:
      - condition: template
        value_template: "{{ states.trigger.to_state.state in ['16', '17', '18'] }}"

    action:
      - service: script.turn_on
        data_template:
          entity_id: >
            {% set code_slot = states.trigger.to_state.state %}
            {{ 'script.door_keypad_' ~ code_slot ~ '_delete' }}

This is a similiar automation, and itā€™s working

  - alias: Keypad clear code after one time use is set to disabled for 16 through 18
    trigger:
      - platform: state
        to: 'Disabled'
        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: script.turn_on
        data_template:
          entity_id: >
                {% set object_id = trigger.to_state.entity_id %}
                {% set code_slot = "_".join(object_id.split("_")[3:-2]) %}
                {% set script_to_run = 'script.door_keypad_' ~ code_slot ~ '_delete' %}
                {{ script_to_run }}

Also Iā€™m not seeing any errors in the logs,

Iā€™ve looked at the state of these
- sensor.lock_front_door_deadbolt_alarm_level
- sensor.lock_back_door_deadbolt_alarm_level
- sensor.lock_garage_door_lock_alarm_level
and they are changing to 16. Not sure if the condition could use some work, but like I said for now, Iā€™ve commented it out just to make sure that was not my problem and it made no difference, so I can come back to that.

Same results with this

  - alias: Keypad clear code after one time use code is used for 16 through 18
    trigger:
      - platform: state
        entity_id:
          - sensor.lock_front_door_deadbolt_alarm_level
          - sensor.lock_back_door_deadbolt_alarm_level
          - sensor.lock_garage_door_lock_alarm_level
        to: '16'
      - platform: state
        entity_id:
          - sensor.lock_front_door_deadbolt_alarm_level
          - sensor.lock_back_door_deadbolt_alarm_level
          - sensor.lock_garage_door_lock_alarm_level
        to: '17'
      - platform: state
        entity_id:
          - sensor.lock_front_door_deadbolt_alarm_level
          - sensor.lock_back_door_deadbolt_alarm_level
          - sensor.lock_garage_door_lock_alarm_level
        to: '18'

    action:
      - service: script.turn_on
        data_template:
          entity_id: >
            {% set code_slot = states.trigger.to_state.state %}
            {{ 'script.door_keypad_' ~ code_slot ~ '_delete' }}

This is getting annoying, I can verify the value is changing to 16, but cannot see any evidince of this automation recoginizing it. Typos somewhere??

Remove the ā€œtoā€ in the trigger and add a log entry in the action to see whats going on? The equivalent of the old school printf for debuggingā€¦

Iā€™ve not done. The log entry before. How does that work? Do you have any examples?

Thanks!!

Here is a snipped that should give the general overview:

 - service: logbook.log
      data_template:
         name: >-
           EXIT DOOR: {{ trigger.to_state.attributes.friendly_name }}
         message: >-
           {{ trigger.to_state.state | replace("on","open") | replace("off","closed") }}
1 Like

Are you sure that the states on the to_state is a string?

EDIT: Also, remove the word ā€˜statesā€™ before trigger

I would think this is what you need:

    condition:
      - condition: template
        value_template: "{{ trigger.to_state.state in [16, 17, 18] }}"

EDIT: Now that Iā€™m looking at your other non-working automation, it appears the problem is most likey the word ā€˜statesā€™ before both your triggers. Triggers are not in your states. So when you use states first, you are saying I want the state from the trigger domain. Trigger domian doesnā€™t exist, trigger is an event.

Shouldnā€™t this have worked though?

      - platform: state
        entity_id:
          - sensor.lock_front_door_deadbolt_alarm_level
          - sensor.lock_back_door_deadbolt_alarm_level
          - sensor.lock_garage_door_lock_alarm_level
        to: '18'

Also I removed the condition totally, and never got this to run.

Well that may be related to the state. Try this:

      - platform: state
        entity_id:
          - sensor.lock_front_door_deadbolt_alarm_level
          - sensor.lock_back_door_deadbolt_alarm_level
          - sensor.lock_garage_door_lock_alarm_level
        to: 18

I also had this for the longest time and also never triggered

      - platform: state
        entity_id:
          - sensor.lock_front_door_deadbolt_alarm_level
          - sensor.lock_back_door_deadbolt_alarm_level
          - sensor.lock_garage_door_lock_alarm_level

My understanding is that should trigger with any state change, right?

yes it should

Thatā€™s what I thought. Thatā€™s why I was working on the condition, but when I could not get it to fire, I just removed the condition, and still nothing. I confirmed that the value of the senors changed, and there were no errors, it just never ran. Iā€™ll do some logging testing as suggested above.

Well it looks like it was an issue with state vs numberic state.

This worked

- alias: Keypad test for back door
  trigger:
    - platform: numeric_state
      entity_id:
        - sensor.lock_back_door_deadbolt_alarm_level
      above: 15
      below: 17
  action:
  - service: notify.pushbullet_notifications
    data:
      message: "door code entered"
      target:
      - email/[email protected]
      title: "Testing of back door keypad"

Got the delete script working too!! Thanks for the help

  - alias: Keypad clear code after one time use code is used for 16 through 18
    trigger:
      - platform: numeric_state
        entity_id:
          - sensor.lock_front_door_deadbolt_alarm_level
          - sensor.lock_back_door_deadbolt_alarm_level
          - sensor.lock_garage_door_lock_alarm_level
        above: 15
        below: 19
    condition:
    - condition: numeric_state
      entity_id: sensor.ha_runtime_in_minutes
      above: 1
    action:
      - service: notify.pushbullet_notifications
        data:
          message: "door delete test "
          target:
          - email/[email protected]
          title: "Testing of delete script door keypad"
      - service: script.turn_on
        data_template:
          entity_id: >
            {% set code_slot = trigger.to_state.state %}
            {{ 'script.door_keypad_' ~ code_slot ~ '_delete' }}

Iā€™m going to document a bit but hope to post the whole working package in the next day or so!

1 Like

OK, I feel like Iā€™m being lazy for asking, but either Iā€™m tired, or this is just not coming to me. This really is the last part of the script, which I hope to post tonight, I realized I missed one part.

here is what I have

  - alias: Notify who unlocked door with timestamp
    trigger:
    - platform: state
      entity_id:
        - sensor.frontdoor_action
        - sensor.backdoor_action
      to: 'Keypad Unlock'
# This is for an FE599 Schalge lock, they handle events differntly, this will only trigger if a differnt code is used to unlock the door.
    - platform: state
      entity_id:
        - sensor.garagedoor_code
#    condition:
#   - condition: state
#     entity_id: input_select.house_mode
#     state: 'Away'
    condition:
    - condition: numeric_state
      entity_id: sensor.ha_runtime_in_minutes
      above: 1
    action:
    - delay:
        seconds: 2
    - service: notify.pushbullet_notifications
      data_template:
        message: " At {{ as_timestamp (now()) | timestamp_custom('%I:%M %p') }} on {{ now().strftime('%d %b %Y') }} " 
        target:
        - email/[email protected]
        title: "{{ trigger.to_state.attributes.friendly_name }} unlocked by {{ states.sensor.backdoor_code.state }}"

Problem is with this

 title: "{{ trigger.to_state.attributes.friendly_name }} unlocked by {{ states.sensor.backdoor_code.state }}"

I need it to be backdoor code if sensor.backdoor_action was the triger, and frontdoor_code if sensor.frontdoor_action was the trigger, for garage the trigger IS sensor.garagedoor_code, so I guess I could just use the state of the trigger for that one. I feel like I need a template in a template in a tempalte, haha.

Like inception with HA.

Can I implement this for a windows installation of HA?

Iā€™d think so, but cannot say 100%. I cannot think of any reason why it would not work, there are no special installs needed, just standard zwave sensors, etc.

I mean you could do that hereā€¦ You could map your response based on the friend_name or entity_id:

      data_template:
        message: " At {{ as_timestamp (now()) | timestamp_custom('%I:%M %p') }} on {{ now().strftime('%d %b %Y') }} " 
        target:
        - email/[email protected]
        title: >
           {% mapper = { 'sensor.frontdoor_action': 'sensor.frontdoor_code',
                         'sensor.backdoor_action' : 'sensor.backdoor_code',
                         'sensor.garagedoor_code' : 'sensor.garagedoor_code' } %}
           {{ trigger.to_state.attributes.friendly_name }} unlocked by {{ mapper[trigger.entity_id] }}

Nice, I have not used the mapper yet. Thanks.

I posted this same comment in general formum and would like to delete it. Is there anyway to delete a post?

Edit: I see mapper is just a variable.

Should it be?

{% set mapper =

Thanks again,

I want to display the state of the _code sensor, so this should work, right?

          {% set mapper = { 'sensor.frontdoor_action': 'states.sensor.frontdoor_code.state',
                            'sensor.backdoor_action' : 'states.sensor.backdoor_code.state',
                            'sensor.garagedoor_code' : 'states.sensor.garagedoor_code.state' } %}
           {{ trigger.to_state.attributes.friendly_name }} unlocked by {{ mapper[trigger.entity_id] }}