Extracting Event Data from Schlage ZWave Deadbolt to Useful Entity State

I was able to shorten it up a bit more. I don’t believe there would be any unwanted events that end with “lock operation” so this would cover it.

- id: lock_side_door_status_update
  alias: '[Lock] Side Door Status Update'
  description: Update side door lock status.
  trigger:
    - platform: event
      event_type: zwave_js_event

  condition: "{{ trigger.event.data.node_id == 52 and trigger.event.data.label.endswith('lock operation') }}"

  action:
    - service: input_text.set_value
      data:
        entity_id: input_text.side_door_lock_status
        value: >
          {% set users = ['Jason','Sheri','Dawn'] %}
          {% set userID = trigger.event.data.parameters['userId'] %}
          {% set user = 'Keypad' if userID == null else users[userID|int -1] %}
          {% if trigger.event.data.label == 'Manual unlock operation' %} Unlocked (Manual)
          {% elif trigger.event.data.label == 'Manual lock operation' %} Locked (Manual)
          {% elif trigger.event.data.label == 'RF unlock operation' %} Unlocked (Hassio)
          {% elif trigger.event.data.label == 'RF lock operation' %} Locked (Hassio)
          {% elif trigger.event.data.label == 'Keypad unlock operation' %} Unlocked ({{ user }})
          {% elif trigger.event.data.label == 'Keypad lock operation' %} Locked ({{ user }})
          {% else %} Unknown
          {% endif %}
3 Likes

This is awesome! I see now how you extracted the event data. It’s implemented and doing everything I’m looking for it to do thanks to you and @pnbruckner!

1 Like

Here’s another automation you might find useful for your lock. It changes the lock’s internal alarm mode with the house alarm mode.

Disarmed -> No chips (no alarm)
Armed Home -> Chirps when door opened
Armed Night/Away - Changes to forced entry mode.

Lock Alarm Mode Automation
- id: lock_side_door_alarm_mode
  alias: "[Lock] Side Door Alarm Mode"
  description: Set side door lock alarm mode.
  initial_state: true
  mode: queued
  trigger:
    - platform: state
      entity_id: alarm_control_panel.alarmo
      to:
        - armed_home
        - armed_night
        - armed_away
        - disarmed
  condition:
    - condition: or
      alias: Make sure door lock entity is connected (zwave).
      conditions:
        - condition: state
          entity_id: lock.side_door_lock
          state: locked
        - condition: state
          entity_id: lock.side_door_lock
          state: unlocked
  action:
    - choose:
        - conditions:
            - condition: state
              entity_id: alarm_control_panel.alarmo
              state: disarmed
          sequence:
            - service: zwave_js.set_config_parameter
              data:
                parameter: Alarm Mode
                value: Alarm Off
              target:
                entity_id: lock.side_door_lock
        - conditions:
            - condition: state
              entity_id: alarm_control_panel.alarmo
              state: armed_home
          sequence:
            - service: zwave_js.set_config_parameter
              data:
                parameter: Alarm Mode
                value: Alert
              target:
                entity_id: lock.side_door_lock
        - conditions:
            - condition: or
              conditions:
                - condition: state
                  entity_id: alarm_control_panel.alarmo
                  state: armed_night
                - condition: state
                  entity_id: alarm_control_panel.alarmo
                  state: armed_away
          sequence:
            - service: zwave_js.set_config_parameter
              data:
                parameter: Alarm Mode
                value: Forced Entry
              target:
                entity_id: lock.side_door_lock
2 Likes

I made one correction as it looks like a small typo in the even data for the “Locked (Manual)” The event data was duplicated from the “Unlocked (Manual)” Changed ‘unlock’ to ‘lock’

  action:
    - service: input_text.set_value
      data:
        entity_id: input_text.side_door_lock_status
        value: >
          {% set users = ['Jason','Sheri','Dawn'] %}
          {% set userID = trigger.event.data.parameters['userId'] %}
          {% set user = 'Keypad' if userID == null else users[userID|int -1] %}
          {% if trigger.event.data.label == 'Manual unlock operation' %} Unlocked (Manual)
          {% elif trigger.event.data.label == 'Manual lock operation' %} Locked (Manual)
          {% elif trigger.event.data.label == 'RF unlock operation' %} Unlocked (Hassio)
          {% elif trigger.event.data.label == 'RF lock operation' %} Locked (Hassio)
          {% elif trigger.event.data.label == 'Keypad unlock operation' %} Unlocked ({{ user }})
          {% elif trigger.event.data.label == 'Keypad lock operation' %} Locked ({{ user }})
          {% else %} Unknown
          {% endif %}

You are absolutely correct, I had to make the same correction in my config and forgot to make the change here. I’ve updated it now. Good catch!

1 Like

I found this automation useful, it also works for a Kwikset 888 and it may work for a 910 too (need to test this). I wanted to share some updates here for others, on the latest HA update two things changed, the event_type and event_label. I also changed the “else” line to be a catch all.

- alias: Alarm - Front Door Lock Sensor Updater
  id: 'alarm_-_front_door_lock_sensor_updater'
  initial_state: true
  trigger:
  - platform: event
    event_type: zwave_js_notification
  condition:
  - condition: template
    value_template: '{{ trigger.event.data.node_id == 66 and trigger.event.data.command_class_name == ''Notification'' }}'
  action:
  - service: input_text.set_value
    data:
      entity_id: input_text.front_door_lock_status
      value: >
        {% set users = ['Chris','Violet','Pat or Bob','Melanie','Amelia'] %}
        {% set userID = trigger.event.data.parameters['userId'] %}
        {% set user = 'Keypad' if userID == null else users[userID|int -1] %}
        {% if trigger.event.data.event_label == 'Manual unlock operation' %} Manual Unlock
        {% elif trigger.event.data.event_label == 'Manual lock operation' %} Manual Lock
        {% elif trigger.event.data.event_label == 'RF unlock operation' %} RF Unlock
        {% elif trigger.event.data.event_label == 'RF lock operation' %} RF Lock
        {% elif trigger.event.data.event_label == 'Keypad unlock operation' %} Keypad Unlock ({{ user }})
        {% elif trigger.event.data.event_label == 'Keypad lock operation' %} Keypad Lock ({{ user }})
        {% else %} {{trigger.event.data.event_label}}
        {% endif %}

Thank you! I meant to post an update last week when I saw these changes with the core update. You caught them all.

To summarize for those just catching up, because of the “Breaking ZwaveJS changes” on core-2021.04.00, Zwave_JS_event changed to Zwave_JS_notification and the “label” tag changed to “event_label”

Cheers!

For some reason when I lock/unlock through Home Assistant, there is no event created. Events are only generated when I manually interact with the lock. Is this expected? If not, does anyone know why that would be? I basically never see the “RF (un)lock operation” event_label. I was able to see that with the sensor before moving to zwavejs2mqtt.

What event topic are you listening to?

I subscribed to zwave_js_notification and when I manually lock the door I see an event with event_label ‘Manual lock operation’. But, if I unlock or lock in Home Assistant, no zwave_js_notification event is fired at all.

Interesting. On my end, I see “RF lock operation” or “RF unlock operation” under event_label like you stated. Are you viewing the event data from the Developer Tools ->Events tab when you subscribe to zwave_js_notification?

What events are fired if you lock/unlock via the keypad?

Also, when you moved to zwaveJS2mqtt, did you update the ZwaveJS integration with the proper server address? It should look something like this when you go to Integrations->ZwaveJS->configure.

Yep, I am subscribing to the events from Developer Tools > Events. The ZwaveJS integration is showing connected and I can lock and unlock without issue.

When I use the keypad, I see the correct event showing: “event_label”: “Keypad lock operation”. For whatever reason, only remote commands do not trigger any events even though the lock locks/unlocks as expected.

What about the server address in the ZwaveJS integration? Look at the second part of my previous reply for details. This has caused strange integration issues for me in the past when setup wrong. Especially since you mentioned a recent switch to ZwaveJS2mqtt, a confirmation that this is setup correctly would eliminate a multitude of t/s-ing steps.

Also, what lockset are you using?

I’m using BE469. The ZwaveJS configuration looks good to me.

Screen Shot 2021-04-21 at 10.41.02 PM

Are you running a supervised add-on version of ZwaveJSmqtt?

No, I am running Home Assistant core and the zwavejs2mqtt dockers on Unraid.

hi Chris, I’m new to HA - I copied the code snippet and put it in automations.yaml, created the input_text variable and just changed out the node_id to one of my lock nodes. for some reason, when I do a ‘run actions’ on the automations page, I get ‘Error: Error rendering data template: UndefinedError: ‘dict object’ has no attribute ‘event’’

Am I not supposed to try to test it from there?

alias: Alarm - Front Door Lock Sensor Updater
initial_state: true
trigger:
  - platform: event
    event_type: zwave_js_notification
condition:
  - condition: template
    value_template: >-
      {{ trigger.event.data.node_id == 22 and
      trigger.event.data.command_class_name == 'Notification' }}
action:
  - service: input_text.set_value
    data:
      entity_id: input_text.front_door_lock_status
      value: >
        {% set users = ['Chris','Violet','Pat or Bob','Melanie','Amelia'] %} {%
        set userID = trigger.event.data.parameters['userId'] %} {% set user =
        'Keypad' if userID == null else users[userID|int -1] %} {% if
        trigger.event.data.event_label == 'Manual unlock operation' %} Manual
        Unlock {% elif trigger.event.data.event_label == 'Manual lock operation'
        %} Manual Lock {% elif trigger.event.data.event_label == 'RF unlock
        operation' %} RF Unlock {% elif trigger.event.data.event_label == 'RF
        lock operation' %} RF Lock {% elif trigger.event.data.event_label ==
        'Keypad unlock operation' %} Keypad Unlock ({{ user }}) {% elif
        trigger.event.data.event_label == 'Keypad lock operation' %} Keypad Lock
        ({{ user }}) {% else %} {{trigger.event.data.event_label}} {% endif %}
mode: single

thanks,

Is/was there ever a plan by the developers to actually extract this information and make it an attribute or entity? I just switched over to zwave js and for me it luckily only broke just one automation, but I was planning on eventually making a number of automations based on the user codes. It looks like a pain to get that information in a usable form now.

Thanks for this! Got it up and running. I’d like to pass a notification when a user unlocks the door via code how would I accomplish this?

Hi All,

I’m looking to accomplish the same - reading in unlock / user pin data from a Schlage lock.

Basically following everything in this tutorial - Z-Wave JS Locks in Home Assistant - Now See Who Opened The Door - YouTube

I’m running a raspberry pi externally to Home Assistant, running Zwave JS (latest) and websockets to a Home Assistant VM I have on my virtual infrastructure.

I can’t seem to view any zwave_js_notification event data.

I have not configured MQTT or Gateway on the Zwave JS on the rpi, is that something I need to do?
If so could you provide an exmaple of the configs?

I’ve been googling for hours!

Much Appreciated!