Automation Scene Activated Event Multipe entity_id

This doesn’t seem to work for me… I thought events are ‘OR’, however, seems like written this way may be doing ‘and’ on entity_id?
Is there a faster way to write this rather than breaking it out?

- alias: Large Area Hold/On
  trigger:
  - event_data:
      entity_id: 
        - zwave.arena_large_row1
        - zwave.arena_large_row2
        - zwave.arena_large_row3
        - zwave.arena_large_row4
      scene_data: 7740
      scene_id: 1
    event_type: zwave.scene_activated
    platform: event
  condition: []
  action:
  - data:
      entity_id: group.large_arena
    service: homeassistant.turn_on

It’s doing and because you have 1 event with 4 entity ids. Change it to 4 events with 1 entity id.

- alias: Large Area Hold/On
  trigger:
  - event_data:
      entity_id: zwave.arena_large_row1
      scene_data: 7740
      scene_id: 1
    event_type: zwave.scene_activated
  - event_data:
      entity_id: zwave.arena_large_row2
      scene_data: 7740
      scene_id: 1
    event_type: zwave.scene_activated
  - event_data:
      entity_id: zwave.arena_large_row3
      scene_data: 7740
      scene_id: 1
    event_type: zwave.scene_activated
  - event_data:
      entity_id: zwave.arena_large_row4
      scene_data: 7740
      scene_id: 1
    event_type: zwave.scene_activated

No, not that I’m aware of.

I think you can do:

- alias: Large Area Hold/On
  trigger:
  - event_data:
      scene_data: 7740
      scene_id: 1
    event_type: zwave.scene_activated
    platform: event
  condition:
    condition: template
    value_template: >
      {{ trigger.event.data.entity_id.startswith('zwave.arena_large_row') and
         trigger.event.data.entity_id[-1] in ['1', '2', '3', '4'] }}
  action:
  - data:
      entity_id: group.large_arena
    service: homeassistant.turn_on
1 Like

Yah, that should work too. It would just “fire” more often, but not complete.

so cool these conditions with value_templates, made me have better automations in many situation already, this being another one.

btw, shouldn’t these indents be made on the trigger and action -'s:

- alias: Large Area Hold/On
  trigger:
    - event_data:
        scene_data: 7740
        scene_id: 1
      event_type: zwave.scene_activated
      platform: event
  condition:
    condition: template
    value_template: >
      {{ trigger.event.data.entity_id.startswith('zwave.arena_large_row') and
         trigger.event.data.entity_id[-1] in ['1', '2', '3', '4'] }}
  action:
    - data:
        entity_id: group.large_arena
      service: homeassistant.turn_on

Yamllint agrees on both, but i have had HA complain before on Yaml green lighted code?

Cheers,
Marius

Either way works. It’s a matter of opinion/style.

ok, good to know, thanks.

As a matter of opinion and style, I always try to avoid as many characters as possible… which in the case of only one item below either trigger, condition and action means no - at all…and if there’s no data to pass on others than the entity_id, leave out the data field. (in the action part)

in this case:

- alias: Large Area Hold/On
  trigger:
    event_data:
      scene_data: 7740
      scene_id: 1
    event_type: zwave.scene_activated
    platform: event
  condition:
    condition: template
    value_template: >
      {{ trigger.event.data.entity_id.startswith('zwave.arena_large_row') and
         trigger.event.data.entity_id[-1] in ['1', '2', '3', '4'] }}
  action:
    service: homeassistant.turn_on
    entity_id: group.large_arena

Yamllint greens it. not sure what HA thinks of it of course .
Anyways, lesson learnt on this day once more, thanks for enlightning me :+1:

1 Like

wow, thanks everyone! great read and ideas… can’t wait to try them out.