ZWave-JS - Schlage Lock User Code Actions

I created a blueprint for automations based on the user that unlocks a Schlage (Allegion) lock in Zwave-JS

Edit: 21/14/02 – Added Manual lock and unlock operations
Edit: 21/23/07 – Updated based on changes made by @jsdphilly (totally forgot I had written this!)

blueprint:
  name: Schlage Lock Actions
  description: Perform action based on code slot that unlocked door
  domain: automation
  input:
    schlage_lock:
      name: Schlage Lock
      description: List of available Schlage Locks
      selector:
        device:
          integration: zwave_js
          manufacturer: Allegion
    manual_lock:
      name: Manual lock Operation
      description: Manually locking thumbturn
      default: []
      selector:
        action: {}
    manual_unlock:
      name: Manual unlock Operation
      description: Manually unlocking thumbturn
      default: []
      selector:
        action: {}
    user_1:
      name: User Code Slot 1
      description: First Usercode Slot
      default: []
      selector:
        action: {}
    user_2:
      name: User Code Slot 2
      description: Second Usercode Slot
      default: []
      selector:
        action: {}
    user_3:
      name: User Code Slot 3
      description: Third Usercode Slot
      default: []
      selector:
        action: {}
    user_4:
      name: User Code Slot 4
      description: Fourth Usercode Slot
      default: []
      selector:
        action: {}
    user_5:
      name: User Code Slot 5
      description: Fifth Usercode Slot
      default: []
      selector:
        action: {}
    user_6:
      name: User Code Slot 6
      description: Sixth Usercode Slot
      default: []
      selector:
        action: {}
    user_7:
      name: User Code Slot 7
      description: Seventh Usercode Slot
      default: []
      selector:
        action: {}
    user_8:
      name: User Code Slot 8
      description: Eighth Usercode Slot
      default: []
      selector:
        action: {}
    user_9:
      name: User Code Slot 9
      description: Ninth Usercode Slot
      default: []
      selector:
        action: {}
    user_10:
      name: User Code Slot 10
      description: Tenth Usercode Slot
      default: []
      selector:
        action: {}
    user_11:
      name: User Code Slot 11
      description: Eleventh Usercode Slot
      default: []
      selector:
        action: {}
    user_12:
      name: User Code Slot 12
      description: Twelfth Usercode Slot
      default: []
      selector:
        action: {}
    user_13:
      name: User Code Slot 13
      description: First Usercode Slot
      default: []
      selector:
        action: {}
    user_14:
      name: User Code Slot 14
      description: First Usercode Slot
      default: []
      selector:
        action: {}
    user_15:
      name: User Code Slot 15
      description: First Usercode Slot
      default: []
      selector:
        action: {}
    user_16:
      name: User Code Slot 16
      description: Sixteenth Usercode Slot
      default: []
      selector:
        action: {}
    user_17:
      name: User Code Slot 17
      description: Seventeenth Usercode Slot
      default: []
      selector:
        action: {}
    user_18:
      name: User Code Slot 18
      description: Eighteenth Usercode Slot
      default: []
      selector:
        action: {}
    user_19:
      name: User Code Slot 19
      description: Nineteenth Usercode Slot
      default: []
      selector:
        action: {}
    user_20:
      name: User Code Slot 20
      description: Twentieth Usercode Slot
      default: []
      selector:
        action: {}
    user_21:
      name: User Code Slot 21
      description: Twenty-first Usercode Slot
      default: []
      selector:
        action: {}
    user_22:
      name: User Code Slot 22
      description: Twenty-second Usercode Slot
      default: []
      selector:
        action: {}
    user_23:
      name: User Code Slot 23
      description: Twenty-third Usercode Slot
      default: []
      selector:
        action: {}
    user_24:
      name: User Code Slot 24
      description: Twenty-fourth Usercode Slot
      default: []
      selector:
        action: {}
    user_25:
      name: User Code Slot 25
      description: Twenty-fifth Usercode Slot
      default: []
      selector:
        action: {}
    user_26:
      name: User Code Slot 26
      description: Twenty-sixth Usercode Slot
      default: []
      selector:
        action: {}
    user_27:
      name: User Code Slot 27
      description: Twenty-seventh Usercode Slot
      default: []
      selector:
        action: {}
    user_28:
      name: User Code Slot 28
      description: Twenty-eigth Usercode Slot
      default: []
      selector:
        action: {}
    user_29:
      name: User Code Slot 29
      description: Twenty-ninth Usercode Slot
      default: []
      selector:
        action: {}
    user_30:
      name: User Code Slot 30
      description: Thirtieth Usercode Slot
      default: []
      selector:
        action: {}
mode: single
max_exceeded: silent
variables:
  device_id: !input "schlage_lock"
trigger:
  - platform: event
    event_type: zwave_js_notification
condition: "{{ trigger.event.data.device_id == device_id }}"
action:
  - variables:
      user_code: "{{ trigger.event.data.parameters.userId }}"
      lock_operation: "{{ trigger.event.data.event_label }}"
  - service: logbook.log
    data:
      name: User Code
      message: "{{ user_code }}"
  - service: logbook.log
    data:
      name: Device
      message: "{{ device_id }}"
  - choose:
      - conditions: '{{ trigger.event.data.event_label == "Manual lock operation" }}'
        sequence: !input "manual_lock"
      - conditions: '{{ trigger.event.data.event_label == "Manual unlock operation" }}'
        sequence: !input "manual_unlock"
      - conditions:
          '{{ user_code == 1 and lock_operation == "Keypad unlock operation"
          }}'
        sequence: !input "user_1"
      - conditions:
          '{{ user_code == 2 and lock_operation == "Keypad unlock operation"
          }}'
        sequence: !input "user_2"
      - conditions:
          '{{ user_code == 3 and lock_operation == "Keypad unlock operation"
          }}'
        sequence: !input "user_3"
      - conditions:
          '{{ user_code == 4 and lock_operation == "Keypad unlock operation"
          }}'
        sequence: !input "user_4"
      - conditions:
          '{{ user_code == 5 and lock_operation == "Keypad unlock operation"
          }}'
        sequence: !input "user_5"
      - conditions:
          '{{ user_code == 6 and lock_operation == "Keypad unlock operation"
          }}'
        sequence: !input "user_6"
      - conditions:
          '{{ user_code == 7 and lock_operation == "Keypad unlock operation"
          }}'
        sequence: !input "user_7"
      - conditions:
          '{{ user_code == 8 and lock_operation == "Keypad unlock operation"
          }}'
        sequence: !input "user_8"
      - conditions:
          '{{ user_code == 9 and lock_operation == "Keypad unlock operation"
          }}'
        sequence: !input "user_9"
      - conditions:
          '{{ user_code == 10 and lock_operation == "Keypad unlock operation"
          }}'
        sequence: !input "user_10"
      - conditions:
          '{{ user_code == 11 and lock_operation == "Keypad unlock operation"
          }}'
        sequence: !input "user_11"
      - conditions:
          '{{ user_code == 12 and lock_operation == "Keypad unlock operation"
          }}'
        sequence: !input "user_12"
      - conditions:
          '{{ user_code == 13 and lock_operation == "Keypad unlock operation"
          }}'
        sequence: !input "user_13"
      - conditions:
          '{{ user_code == 14 and lock_operation == "Keypad unlock operation"
          }}'
        sequence: !input "user_14"
      - conditions:
          '{{ user_code == 15 and lock_operation == "Keypad unlock operation"
          }}'
        sequence: !input "user_15"
      - conditions:
          '{{ user_code == 16 and lock_operation == "Keypad unlock operation"
          }}'
        sequence: !input "user_16"
      - conditions:
          '{{ user_code == 17 and lock_operation == "Keypad unlock operation"
          }}'
        sequence: !input "user_17"
      - conditions:
          '{{ user_code == 18 and lock_operation == "Keypad unlock operation"
          }}'
        sequence: !input "user_18"
      - conditions:
          '{{ user_code == 19 and lock_operation == "Keypad unlock operation"
          }}'
        sequence: !input "user_19"
      - conditions:
          '{{ user_code == 20 and lock_operation == "Keypad unlock operation"
          }}'
        sequence: !input "user_20"
      - conditions: '{{ user_code == 21 and lock_operation == "Keypad unlock operation"}}'
        sequence: !input "user_21"
      - conditions: '{{ user_code == 22 and lock_operation == "Keypad unlock operation"}}'
        sequence: !input "user_22"
      - conditions: '{{ user_code == 23 and lock_operation == "Keypad unlock operation"}}'
        sequence: !input "user_23"
      - conditions: '{{ user_code == 24 and lock_operation == "Keypad unlock operation"}}'
        sequence: !input "user_24"
      - conditions: '{{ user_code == 25 and lock_operation == "Keypad unlock operation"}}'
        sequence: !input "user_25"
      - conditions: '{{ user_code == 26 and lock_operation == "Keypad unlock operation"}}'
        sequence: !input "user_26"
      - conditions: '{{ user_code == 27 and lock_operation == "Keypad unlock operation"}}'
        sequence: !input "user_27"
      - conditions: '{{ user_code == 28 and lock_operation == "Keypad unlock operation"}}'
        sequence: !input "user_28"
      - conditions: '{{ user_code == 29 and lock_operation == "Keypad unlock operation"}}'
        sequence: !input "user_29"
      - conditions: '{{ user_code == 30 and lock_operation == "Keypad unlock operation"}}'
        sequence: !input "user_30"
3 Likes

Thanks! Looking forward to trying this out and finishing my migration from smart things

YES! So so good!!! Thank you for making this! This combined with the Keymaster Integration has finally accomplished everything I want!!

I can finally use my smart lock as my Alarmo Keypad.

Great work!!

Just dipping my toes into HA Zwave and had a couple of basic questions.

Is there any additional configuration needed for this after adding the blueprint + automation?

I have it installed, with my user code set in the Zwave JS User Code section. When I set an automation to the corresponding user code that I set up in the Zwave JS, I get the following error:

Error while executing automation automation.X: UndefinedError: ‘dict object’ has no attribute ‘event’

Thanks for making this and appreciate any help anyone can provide.

@hanerd is this still working as before? Looks like something broke it a little while back. I am having the same tracing error as the person above

Read the breaking changes for Z-Wave JS. The notification name changed to zwave_js_notification and the payload changed a little.

The payload has got me lost when I’m trying to fix this blueprint.

This is what I am getting from the event when I change the code with the keypad.

{
    "event_type": "zwave_js_notification",
    "data": {
        "domain": "zwave_js",
        "node_id": 20,
        "home_id": 4038473397,
        "device_id": "8805063c18be16b61306d18ccaa52853",
        "command_class": 113,
        "command_class_name": "Notification",
        "label": "Access Control",
        "type": 6,
        "event": 6,
        "event_label": "Keypad unlock operation",
        "parameters": {
            "userId": 1
        }
    },
    "origin": "LOCAL",
    "time_fired": "2021-04-17T01:56:49.201684+00:00",
    "context": {
        "id": "3f01b9955a0d295a0a1f99fd5333e0d8",
        "parent_id": null,
        "user_id": null
    }
}

This is what I am getting when I do the manual control

{
    "event_type": "zwave_js_notification",
    "data": {
        "domain": "zwave_js",
        "node_id": 20,
        "home_id": 4038473397,
        "device_id": "8805063c18be16b61306d18ccaa52853",
        "command_class": 113,
        "command_class_name": "Notification",
        "label": "Access Control",
        "type": 6,
        "event": 2,
        "event_label": "Manual unlock operation",
        "parameters": {}
    },
    "origin": "LOCAL",
    "time_fired": "2021-04-17T01:56:32.126940+00:00",
    "context": {
        "id": "a2da1c77096296b79866d448a65a01ba",
        "parent_id": null,
        "user_id": null
    }
}

Anyone who is better with Payloads/ZWave-JS able to help out?

I can’t seem to import this awesome blueprint. Import times out. Any clue?
Thanks
w

Not sure, but it’s broken at the moment. Doing my best to fix it and then I’ll post a new one if @hanerd doesn’t do it first

For anyone wondering, here is a fixed version that will work with the 2021.4 update. I dont want to start a new thread since this is almost all @hanerd’s work.

I suppose if he doesnt come around to update his blueprint, Ill start a new one in a few days.

blueprint:
  name: Schlage Lock Actions
  description: Perform action based on code slot that unlocked door
  domain: automation
  input:
    schlage_lock:
      name: Schlage Lock
      description: List of available Schlage Locks
      selector:
        device:
          integration: zwave_js
          manufacturer: Allegion
    manual_lock:
      name: Manual lock Operation
      description: Manually locking thumbturn
      default: []
      selector:
        action: {}
    manual_unlock:
      name: Manual unlock Operation
      description: Manually unlocking thumbturn
      default: []
      selector:
        action: {}
    user_1:
      name: User Code Slot 1
      description: First Usercode Slot
      default: []
      selector:
        action: {}
    user_2:
      name: User Code Slot 2
      description: Second Usercode Slot
      default: []
      selector:
        action: {}
    user_3:
      name: User Code Slot 3
      description: Third Usercode Slot
      default: []
      selector:
        action: {}
    user_4:
      name: User Code Slot 4
      description: Fourth Usercode Slot
      default: []
      selector:
        action: {}
    user_5:
      name: User Code Slot 5
      description: Fifth Usercode Slot
      default: []
      selector:
        action: {}
    user_6:
      name: User Code Slot 6
      description: Sixth Usercode Slot
      default: []
      selector:
        action: {}
    user_7:
      name: User Code Slot 7
      description: Seventh Usercode Slot
      default: []
      selector:
        action: {}
    user_8:
      name: User Code Slot 8
      description: Eighth Usercode Slot
      default: []
      selector:
        action: {}
    user_9:
      name: User Code Slot 9
      description: Ninth Usercode Slot
      default: []
      selector:
        action: {}
    user_10:
      name: User Code Slot 10
      description: Tenth Usercode Slot
      default: []
      selector:
        action: {}
    user_11:
      name: User Code Slot 11
      description: Eleventh Usercode Slot
      default: []
      selector:
        action: {}
    user_12:
      name: User Code Slot 12
      description: Twelfth Usercode Slot
      default: []
      selector:
        action: {}
    user_13:
      name: User Code Slot 13
      description: First Usercode Slot
      default: []
      selector:
        action: {}
    user_14:
      name: User Code Slot 14
      description: First Usercode Slot
      default: []
      selector:
        action: {}
    user_15:
      name: User Code Slot 15
      description: First Usercode Slot
      default: []
      selector:
        action: {}
    user_16:
      name: User Code Slot 16
      description: Sixteenth Usercode Slot
      default: []
      selector:
        action: {}
    user_17:
      name: User Code Slot 17
      description: Seventeenth Usercode Slot
      default: []
      selector:
        action: {}
    user_18:
      name: User Code Slot 18
      description: Eighteenth Usercode Slot
      default: []
      selector:
        action: {}
    user_19:
      name: User Code Slot 19
      description: Nineteenth Usercode Slot
      default: []
      selector:
        action: {}
    user_20:
      name: User Code Slot 20
      description: Twentieth Usercode Slot
      default: []
      selector:
        action: {}
    user_21:
      name: User Code Slot 21
      description: Twenty-first Usercode Slot
      default: []
      selector:
        action: {}
    user_22:
      name: User Code Slot 22
      description: Twenty-second Usercode Slot
      default: []
      selector:
        action: {}
    user_23:
      name: User Code Slot 23
      description: Twenty-third Usercode Slot
      default: []
      selector:
        action: {}
    user_24:
      name: User Code Slot 24
      description: Twenty-fourth Usercode Slot
      default: []
      selector:
        action: {}
    user_25:
      name: User Code Slot 25
      description: Twenty-fifth Usercode Slot
      default: []
      selector:
        action: {}
    user_26:
      name: User Code Slot 26
      description: Twenty-sixth Usercode Slot
      default: []
      selector:
        action: {}
    user_27:
      name: User Code Slot 27
      description: Twenty-seventh Usercode Slot
      default: []
      selector:
        action: {}
    user_28:
      name: User Code Slot 28
      description: Twenty-eigth Usercode Slot
      default: []
      selector:
        action: {}
    user_29:
      name: User Code Slot 29
      description: Twenty-ninth Usercode Slot
      default: []
      selector:
        action: {}
    user_30:
      name: User Code Slot 30
      description: Thirtieth Usercode Slot
      default: []
      selector:
        action: {}
mode: single
max_exceeded: silent
variables:
  device_id: !input "schlage_lock"
trigger:
  - platform: event
    event_type: zwave_js_notification
condition: "{{ trigger.event.data.device_id == device_id }}"
action:
  - variables:
      user_code: "{{ trigger.event.data.parameters.userId }}"
      lock_operation: "{{ trigger.event.data.event_label }}"
  - service: logbook.log
    data:
      name: User Code
      message: "{{ user_code }}"
  - service: logbook.log
    data:
      name: Device
      message: "{{ device_id }}"
  - choose:
      - conditions: '{{ trigger.event.data.event_label == "Manual lock operation" }}'
        sequence: !input "manual_lock"
      - conditions: '{{ trigger.event.data.event_label == "Manual unlock operation" }}'
        sequence: !input "manual_unlock"
      - conditions:
          '{{ user_code == 1 and lock_operation == "Keypad unlock operation"
          }}'
        sequence: !input "user_1"
      - conditions:
          '{{ user_code == 2 and lock_operation == "Keypad unlock operation"
          }}'
        sequence: !input "user_2"
      - conditions:
          '{{ user_code == 3 and lock_operation == "Keypad unlock operation"
          }}'
        sequence: !input "user_3"
      - conditions:
          '{{ user_code == 4 and lock_operation == "Keypad unlock operation"
          }}'
        sequence: !input "user_4"
      - conditions:
          '{{ user_code == 5 and lock_operation == "Keypad unlock operation"
          }}'
        sequence: !input "user_5"
      - conditions:
          '{{ user_code == 6 and lock_operation == "Keypad unlock operation"
          }}'
        sequence: !input "user_6"
      - conditions:
          '{{ user_code == 7 and lock_operation == "Keypad unlock operation"
          }}'
        sequence: !input "user_7"
      - conditions:
          '{{ user_code == 8 and lock_operation == "Keypad unlock operation"
          }}'
        sequence: !input "user_8"
      - conditions:
          '{{ user_code == 9 and lock_operation == "Keypad unlock operation"
          }}'
        sequence: !input "user_9"
      - conditions:
          '{{ user_code == 10 and lock_operation == "Keypad unlock operation"
          }}'
        sequence: !input "user_10"
      - conditions:
          '{{ user_code == 11 and lock_operation == "Keypad unlock operation"
          }}'
        sequence: !input "user_11"
      - conditions:
          '{{ user_code == 12 and lock_operation == "Keypad unlock operation"
          }}'
        sequence: !input "user_12"
      - conditions:
          '{{ user_code == 13 and lock_operation == "Keypad unlock operation"
          }}'
        sequence: !input "user_13"
      - conditions:
          '{{ user_code == 14 and lock_operation == "Keypad unlock operation"
          }}'
        sequence: !input "user_14"
      - conditions:
          '{{ user_code == 15 and lock_operation == "Keypad unlock operation"
          }}'
        sequence: !input "user_15"
      - conditions:
          '{{ user_code == 16 and lock_operation == "Keypad unlock operation"
          }}'
        sequence: !input "user_16"
      - conditions:
          '{{ user_code == 17 and lock_operation == "Keypad unlock operation"
          }}'
        sequence: !input "user_17"
      - conditions:
          '{{ user_code == 18 and lock_operation == "Keypad unlock operation"
          }}'
        sequence: !input "user_18"
      - conditions:
          '{{ user_code == 19 and lock_operation == "Keypad unlock operation"
          }}'
        sequence: !input "user_19"
      - conditions:
          '{{ user_code == 20 and lock_operation == "Keypad unlock operation"
          }}'
        sequence: !input "user_20"
      - conditions: '{{ user_code == 21 and lock_operation == "Keypad unlock operation"}}'
        sequence: !input "user_21"
      - conditions: '{{ user_code == 22 and lock_operation == "Keypad unlock operation"}}'
        sequence: !input "user_22"
      - conditions: '{{ user_code == 23 and lock_operation == "Keypad unlock operation"}}'
        sequence: !input "user_23"
      - conditions: '{{ user_code == 24 and lock_operation == "Keypad unlock operation"}}'
        sequence: !input "user_24"
      - conditions: '{{ user_code == 25 and lock_operation == "Keypad unlock operation"}}'
        sequence: !input "user_25"
      - conditions: '{{ user_code == 26 and lock_operation == "Keypad unlock operation"}}'
        sequence: !input "user_26"
      - conditions: '{{ user_code == 27 and lock_operation == "Keypad unlock operation"}}'
        sequence: !input "user_27"
      - conditions: '{{ user_code == 28 and lock_operation == "Keypad unlock operation"}}'
        sequence: !input "user_28"
      - conditions: '{{ user_code == 29 and lock_operation == "Keypad unlock operation"}}'
        sequence: !input "user_29"
      - conditions: '{{ user_code == 30 and lock_operation == "Keypad unlock operation"}}'
        sequence: !input "user_30"
1 Like

Been testing this and it works great (thanks)!!! The only issue I’m seeing is when I manually unlock I see this warning message:

Template variable warning: 'dict object' has no attribute 'userId' when rendering '{{ trigger.event.data.parameters.userId }}'

I fired off a listener for zwave_js_notification and when manually unlocking the user is null ("user_id": null) and seems to be the cause for this warning message but I can’t figure out how to fix it.

Anyone else seeing it and figured it out?

Try: trigger.event.data.parameters.userid

No luck. When I tried that, I didn’t get any notifications (I assume because the parameter does have a capital “I”).

It seems pretty clear that the missing “userId” parameter is what is causing the error:

(zwave_js_notification event parameter when using a code)

    "type": 6,
    "event": 6,
    "event_label": "Keypad unlock operation",
    "parameters": {
        "userId": 1
    }

(zwave_js_notification event parameter when manually unlocked)

    "type": 6,
    "event": 2,
    "event_label": "Manual unlock operation",
    "parameters": {}
},

One option might be to only look for the userId when the event “type” is 6 and the “event” is 6 (I’m not sure where these type codes are documented though).

I hope someone here can answer my question
I have a Schlage E469 lock integrated with smartthings. I want to know if the manually locked and unlocked state issue that was reported before has been resolved and whether the manually locked/unlocked state is automatically updated in HA before I migrate the lock.
Thank you

Lock states update fine.

In case anyone was wondering how to trigger a sequence not only on unlock but also lock events: zwave-js-schlage-lock-user-code-actions.yaml · GitHub

With this I set my lock to arm my alarm when I lock the door using the code (instead of just hitting the Schlage button) and disarm if I unlock with my code:

Automation:

    user_1:
      - choose:
          - conditions:
              - condition: template
                value_template: >-
                  {{ trigger.event.data.event_label == 'Keypad unlock operation'
                  }}
            sequence:
              - service: alarm_control_panel.alarm_disarm
                data:
                  code: 'XXXX'
                target:
                  entity_id: alarm_control_panel.alarm
          - conditions:
              - condition: template
                value_template: >-
                  {{ trigger.event.data.event_label == 'Keypad lock operation'
                  }}
            sequence:
              - service: alarm_control_panel.alarm_arm_away
                target:
                  entity_id: alarm_control_panel.alarm

I’m wanting to do this too! Where exactly do you add this automation to be able to arm with the code? I have the blueprint working for disarm on unlock only.

You’d first need to use my modified version of the Blueprint I linked above (the original version does not cover lock events, only unlock events). The automation would go with all your other automations in the automations.yaml as part of the blueprint:

  use_blueprint:
    path: kaechele/zwave-js-schlage-lock-user-code-actions.yaml
    input:
      schlage_lock: ...
      user_1:
        [...] 

If you use the graphical interface the relevant part looks like this:

Can anyone tell me what hub I should use today in 2022 to add an old Shlage connect from 2014, now that smartthings and wink dont make hubs anymore? Somthing compatible for Home assistant?

(Dont want to use USB stick with synology 7.0 to avoid headache.)

What about for digital unlock events?