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.
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’’
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.
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?
Write-Up: How to Capture Lock Events and Associate Them with User IDs in Home Assistant
If you’re looking to track lock events from a Z-Wave lock and want to know which user unlocked or locked the door, this guide will walk you through setting up an automation in Home Assistant that captures this information and displays it in a text entity. This is particularly useful for getting insights into who is operating the lock, especially when multiple users have their own unique codes.
Step 1: Set Up Input Text Entities
First, you’ll need to create an input text entity in Home Assistant to store the lock status updates. You can do this through the Home Assistant UI by navigating to Configuration > Helpers > + Add Helper > Text.
Name:Front Door Lock Status (or any name you prefer)
Entity ID:input_text.front_door_lock_status
Step 2: Create the Automation
Add the following automation to your automations.yaml file. This code listens for Z-Wave lock events and updates the input_text.front_door_lock_status entity with the operation type and the associated user (if applicable).
- alias: Front Door Lock Status Updater
id: 'front_door_lock_status_updater'
initial_state: true
trigger:
- platform: event
event_type: zwave_js_notification
condition:
- condition: template
# Replace 'your_node_id' with the actual node_id of your lock
value_template: '{{ trigger.event.data.node_id == your_node_id and trigger.event.data.command_class_name == "Notification" }}'
action:
- service: input_text.set_value
data:
# Replace 'input_text.front_door_lock_status' with the actual input_text entity ID you created
entity_id: input_text.front_door_lock_status
value: >
{% set users = ['User 1', 'User 2', 'User 3', 'User 4', 'User 5', 'User 6', 'User 7', 'User 8', 'User 9'] %}
{% 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 %}
Code Breakdown:
Alias: A descriptive name for the automation.
ID: A unique identifier for this automation.
Trigger: The automation listens for zwave_js_notification events from your lock.
Condition: Ensures the event is a notification from the specific lock. Replace 'your_node_id' with the actual node_id of your lock (found in Developer Tools > States).
Action: Updates the input_text entity with the operation type and user name based on the event data. The users list corresponds to User IDs assigned in your lock.
Step 3: Testing
Reload Automations: After saving the automation, reload your automations from the Home Assistant UI or restart Home Assistant.
Operate the Lock: Test the lock by performing different operations (manual, RF, and keypad).
Check the Status: The input_text.front_door_lock_status should update with the correct operation and user name.
Notes:
Customization: Adjust the users array in the code to match the actual users and their corresponding User IDs on your lock.
Troubleshooting: If the status doesn’t update correctly, ensure that the node_id matches the one in your Z-Wave configuration and that the automation is active.
By following these steps, you’ll be able to capture detailed lock events in Home Assistant, allowing you to know exactly who locked or unlocked your door, whether manually or via keypad.