I have a Z-Wave switch with scenes. I want an automation that triggers on a double key press. I can do this with device_id’s, but I’m trying to purge all these from my system and use event_id’s instead. Here is the log when I double tap the switch:
MW Backlight fired Central Scene CC 'value notification' event for 'Scene 002': 'KeyPressed2x'
12:30:06 PM - 33 minutes ago
MW Backlight Scene 002 detected an event
Here is the automation that I have tried that doesn’t work:
Second, that event does not support an entity_id field in event_data, instead it does support device_id so you can just replace that. If you want to dynamically lookup device ID based on an entity ID instead, you can use the device_id helper template.
You can also use the event.media_wall_backlight_scene_002 with a state trigger instead. It’s a little more complicated to do so than an event IMO, but might be easier for others. An example is provided in the Event integration docs.
I can do this easily enough using device_id (and did you mean to change entity_id to device_id in the correction?). But I read that using entity id’s was better, so I was trying to get away from them.
The code I provided is using an entity by dynamically looking up the device id. The event doesn’t provide entity_id in the event data, only device_id or node_id, so it would be impossible to match on entity.
And here’s what the log entry looks like when it fires:
MW Backlight fired Central Scene CC 'value notification' event for 'Scene 002': 'KeyPressed2x'
2:30:31 PM - 14 minutes ago
MW Backlight Scene 002 detected an event
2:30:31 PM - 14 minutes ago
So, if I have to use device_id, I will, it just looked like there should be a way have the trigger fire on the event directly.
I don’t think I understand your concern. The YAML I posted, modified from your original, is triggering directly from the event. Then the device_id template helper is converting the entity ID into a device ID which matches the event data. You don’t use the device ID directly.
This one is the Event entity I described above, it’s not a Device. If you want to use that, follow the example in the docs:
MW Backlight fired Central Scene CC 'value notification' event for 'Scene 002': 'KeyPressed2x'
10:50:00 AM - In 1 second
MW Backlight Scene 002 detected an event`
I also tried entering the device_id directly, but that also didn’t work.
Are you sure property_key: "Scene 002" is correct?
I’d suggest using the Dev Tools → Event viewer to get the correct event data. Listen to zwave_js_value_notification and trigger the event, and you’ll see the data reported.
Based on the device trigger, It’s probably:
property: scene
property_key: '002'
The non-discoverability of the events is one reason why the Event entity was added, as it provides more information up front.