Automation issue with Enbrighten Zwave

I don’t think this is an Enbrighten Zwave issue but more me doing something wrong in my automation. HA can detect through Z-Wave JS UI that a the momentary toggle is pressed up or down and will display it in the devices events. Because the up and down press are detected as different scenes in the switch I’m trying to use one automation to turn on or off other devices.

alias: My_Desk
description: ""
trigger:
  - platform: state
    entity_id:
      - event.in_wall_toggle_switch_qfsw_700s_scene_002_3
    attribute: event_type
    to: KeyPressed
    id: "2"
    enabled: true
  - platform: state
    entity_id:
      - event.in_wall_toggle_switch_qfsw_700s_scene_001_3
    attribute: event_type
    to: KeyPressed
    id: "1"
    enabled: true
condition: []
action:
  - choose:
      - conditions:
          - condition: trigger
            id:
              - "2"
        sequence:
          - type: turn_off
            device_id: b96c7f98f251d9fc9e4a7f350c0c3978
            entity_id: 154ca04c2b419d5f7774fcebe1eab958
            domain: light
          - type: turn_off
            device_id: 69d7cc95fde0b5502031738eef076344
            entity_id: 2c776df000b38f2c65eeee3643806afe
            domain: light
      - conditions:
          - condition: trigger
            id:
              - "1"
        sequence:
          - type: turn_on
            device_id: b96c7f98f251d9fc9e4a7f350c0c3978
            entity_id: 154ca04c2b419d5f7774fcebe1eab958
            domain: light
          - type: turn_on
            device_id: 69d7cc95fde0b5502031738eef076344
            entity_id: 2c776df000b38f2c65eeee3643806afe
            domain: light
mode: single

What’s the problem specifically?

I’m going to assume your trigger isn’t working reliabily. The problem is event entities don’t trigger like you would expect them to. If you add an attribute to the state trigger, it will only trigger if the attribute changes (according to the docs). So multiple KeyPressed events in a row will not trigger, but if you double press (changes attribute) and press again it will start to work. For event entities I find this very annoying and un-intuitive.

Delete the attribute from the trigger so that it triggers on the state (event timestamp). Then check the attribute value in the conditionals instead. It will look something like this, which I took from the example in the docs.

description: ""
mode: single
trigger:
  - platform: state
    entity_id:
      - event.family_room_ceiling_fan_switch_scene_001
condition: []
action:
  - choose:
      - conditions:
          - condition: state
            entity_id: event.family_room_ceiling_fan_switch_scene_001
            attribute: event_type
            state: KeyPressed
        sequence:
          - service: light.turn_off
            metadata: {}
            data: {}
            target:
              entity_id: light.dining_room

Also, it’s recommended to avoid device actions. https://community.home-assistant.io/t/why-and-how-to-avoid-device-ids-in-automations-and-scripts/605517

1 Like

And if you don’t care about the downsides of device automations, it’s easier to use the built-in central scene triggers, which work the way you expect, as events don’t rely on any kind of changing state, they just trigger.

description: ""
mode: single
trigger:
  - platform: device
    device_id: 04bda53653a30368375a1f956ada7320
    domain: zwave_js
    type: event.value_notification.central_scene
    property: scene
    property_key: "001"
    endpoint: 0
    command_class: 91
    subtype: Endpoint 0 Scene 001
    value: 0
    id: "1"
  - platform: device
    device_id: 04bda53653a30368375a1f956ada7320
    domain: zwave_js
    type: event.value_notification.central_scene
    property: scene
    property_key: "002"
    endpoint: 0
    command_class: 91
    subtype: Endpoint 0 Scene 002
    value: 0
    id: "2"
condition: []
action: []

Thank you for both options. I’ve been looking at using the Central Scene in Zwave only devices, it seems like it would reduce latency.

I’m new to anything more than basic automation and dashboards with HA. What kind of downsides are you referring to?

This one seems to have an issue as well if I do both of them like the below, I think that because the both keypressed event HAVE happened at some point in time it chooses the first one. I think if I add the ID back to the choice, it will then know which once triggered the automation.

alias: My_Desk
description: ""
trigger:
  - platform: state
    entity_id:
      - event.in_wall_toggle_switch_qfsw_700s_scene_002_3
    enabled: true
  - platform: state
    entity_id:
      - event.in_wall_toggle_switch_qfsw_700s_scene_001_3
    enabled: true
condition: []
action:
  - choose:
      - conditions:
          - condition: state
            entity_id: event.in_wall_toggle_switch_qfsw_700s_scene_002_3
            attribute: event_type
            state: KeyPressed
        sequence:
          - service: light.turn_off
            data: {}
            target:
              area_id: my_desk
      - conditions:
          - condition: state
            entity_id: event.in_wall_toggle_switch_qfsw_700s_scene_001_3
            attribute: event_type
            state: KeyPressed
        sequence:
          - service: light.turn_on
            target:
              area_id: my_desk
            data: {}
mode: single

Yeah, trigger ID is probably an easy way to solve that. Some kind of templating would work as well.