I’m brainfarting here and struggling to find a way to extract some event data to a single entity value. I.e. “User 1 Unlocked”, “User 1 Locked”, “User 2 Unlocked”, “User 2 Locked”, etc.
A lot of what I’ve found in the community is several years old now and doesn’t seem to work with the new Z-wave JS. I’m not sure if the event data is polling differently or if I’m making some mistake.
Should I be using an automation or an entity template?
What I’ve tried is:
breezeway_door_code:
friendly_name: 'Breezeway Door Code'
value_template: >
{% if is_state_attr("lock.breezway_door_deadbolt", "lock_status", "Unlocked with Keypad by user 1") %}
U1
{% elif is_state_attr("lock.breezway_door_deadbolt", "lock_status", "Unlocked with Keypad by user 2") %}
U2
{% elif is_state_attr("lock.breezway_door_deadbolt", "lock_status", "Locked with Keypad by user 1") %}
L1
{% elif is_state_attr("lock.breezway_door_deadbolt", "lock_status", "Locked with Keypad by user 2") %}
L2
{% endif %}
This returns nothing so I’m obviously not extracting the right information or it simply doesn’t exist as a state. Given what I see in the event information, the info coming in from Zwave_JS isn’t a state.
Below is what I see in the event data and all I’d like to do is have an entity that creates a unique value where U = “Label: keypad unlock operation”, L = “label: keypad lock operation”, and 1 = “userid: 1”, 2 = “userid: 2”, etc… So the entity value would be if “User 1 locked” = L1 and if “User 3 unlocked” = U3.
{
"event_type": "zwave_js_event",
"data": {
"type": "notification",
"domain": "zwave_js",
"node_id": 11,
"home_id": 4145725559,
"device_id": "cf5bbe35ec36a434c4e49769db54c717",
"label": "Keypad unlock operation",
"parameters": {
"userId": 2
}
},
"origin": "LOCAL",
"time_fired": "2021-03-14T14:59:07.196811+00:00",
"context": {
"id": "c89801868df24dab1f63d769df0d89c1",
"parent_id": null,
"user_id": null
}
}
Event 0 fired 10:58 AM:
{
"event_type": "zwave_js_event",
"data": {
"type": "notification",
"domain": "zwave_js",
"node_id": 11,
"home_id": 4145725559,
"device_id": "cf5bbe35ec36a434c4e49769db54c717",
"label": "Keypad lock operation",
"parameters": {
"userId": 1
}
},
"origin": "LOCAL",
"time_fired": "2021-03-14T14:58:48.928060+00:00",
"context": {
"id": "697230cd44b818898ead85bf3ca0ddd3",
"parent_id": null,
"user_id": null
}
The frontend device Id for the lock is “breezeway_door_deadbolt”
Thanks!