Choose & zwave_js_value_notification node_id

I have an automation that is triggered by a double-press of a zwave light switch:
— zwave_js_event_notification … command_class: 91

alias: zwave_js event 91
trigger: event
event_type: zwave_js_value_notification
event_data:
  command_class: 91

Now I want to take an action based on what switch was double-pressed using Node_ID.

I can write a trigger for every single light switch, which seems awful, but I have tested it using 3 switches and it works.

Ideally, I’d like to use CHOOSE and depending on the NODE_ID (the specific switch) take different actions. How would I do this?
Node_ID is an element of event_data, but I’m not sure how I evaluate it in the CHOOSE statement.

Thanks
Rob

Hi Rob Lowry

Trigger on what you want to select in a choose statement and add a trigger_id to it, then put the trigger_id into the choose statement.

Why and how to avoid device_ids in automations and scripts.

If you use an event trigger, the trigger variable will contain the event data which will therefore include the node ID.

So in a template condition inside a choose block you could use {{ trigger.event.data.node_id | int(0) == 25 }} to check if it is node 25.

To verify what the trigger data looks like, trigger the automation by double-tapping a switch and then look at the automation trace. The “changed variables” section will show what was in the trigger variable.

1 Like

Thanks for the response.
This method works, but it isn’t the path I want to take.
Since I already know the node_id as part of the zwave payload, it seems easier to me to create an evaluation at the CHOOSE instead of creating separate triggers and still create an evaluation at the CHOOSE.
Hope that makes sense.

This worked perfectly … thanks for the education!