Trigger on value of either of two property keys (YAML)

I guess I have to learn this YAML stuff. I’m configuring some zwave js automations for multi-taps on switches. It seems like I shouldn’t have to have separate automations for ON and OFF, for instance, so I wondered if there’s a way to see if a switch has been tapped twice–either ON or OFF–then call the light.turn_on or light.turn_off, depending on which side was tapped?

Below is my current working ON script. Could I somehow make the script accept node 11, property_key 001 or property_key 002 having the value ‘KeyPressed2X’? Then, if it’s property_key 001 call light.turn_on, or if it’s 002 call light.turn_off?

As always, sorry if this is stuff I should have learned on Page 1.

trigger:
  - platform: event
    event_type: zwave_js_value_notification
    event_data:
      node_id: 11
      property_key: '001'
      value: KeyPressed2x
condition: []
action:
  - service: light.turn_on
    target:
      device_id: 0dba67f62b39dfc3ffffc249baec74e8
mode: single

You can remove the value from the trigger and check it in a template condition instead.

Thank you for the reply, but what about the property_key? I want to trigger on either property_key 001 or property_key 002 having value KeyPressed2X.

Sorry, I misread. Check the property_key in the condition, not the value. You can then also use a template in the service call to select turn_on or turn_off.

Are there any other scenes besides 001 and 002?

I think there are at least two ways to do this. You could use a template in the service call, or you can choose an action.

You can template the service call, however if there is another scene, such as 003, it will be incorrect.

trigger:
  - platform: event
    event_type: zwave_js_value_notification
    event_data:
      node_id: 11
      value: KeyPressed2x
action:
  - service: >
      light.{{ "turn_on" if trigger.event.data.property_key == "001" else "turn_off" }}
    target:
      device_id: 0dba67f62b39dfc3ffffc249baec74e8
mode: single

This one should do nothing for scenes other than 1 and 2. I generated this from the UI, so the details will be different from your example.

trigger:
  - platform: event
    event_type: zwave_js_value_notification
    event_data:
      node_id: 11
      value: KeyPressed2x
action:
  - choose:
      - conditions:
          - condition: template
            value_template: '{{ trigger.event.data.property_key == "001" }}'
        sequence:
          - type: turn_off
            device_id: 94c4de13ffdde4d4335b2c3fcc2a4d4e
            entity_id: light.dining_room
            domain: light
      - conditions:
          - condition: template
            value_template: '{{ trigger.event.data.property_key == "002" }}'
        sequence:
          - type: turn_on
            device_id: 94c4de13ffdde4d4335b2c3fcc2a4d4e
            entity_id: light.dining_room
            domain: light
            brightness_pct: 50
    default: []
1 Like

Hm, I’m not sure, actually. I mean, there’s just a rocker switch with up, down, and the possibility of holding up or down for dimming. It looks like property_key is always either 001 or 002, though…

Thank you so much for your time and effort. I’ll get back to it and see if I can make progress.