How to group input devices and use the group in a blueprint?

I have a bunch of Tuya Rotary buttons, for which I created a blueprint.

I have several scenarios where I want two or more of these to do exactly the same, for example one button at each end of a hallway (like a traditional three-way switch).

HA Groups seems like a good way to do this. I’ve used groups a fair bit with output devices (lights, active speakers) and sensors (windows open / closed), but this would be my first time grouping input devices.

The grouping works ok, but I seem to be unable to listen to events from any of the input devices in the group in the blueprint.

Here is my attempt:
blueprint:
  name: Tuya Rotary Switch
  description: Automate your Tuya rotary switch using ZHA events.
  domain: automation
  input:
    group_name:
      name: 'Group'
      default: 'Group Name'
    group_object_id:
      name: 'object_id to assign to the group. Example: all_lights'
      default: 'group_id'
    button_press:
      name: Toggle
      description: Push button
      default: []
      selector:
        action: {}
    rotate_right:
      name: Dim up
      description: Rotate right
      default: []
      selector:
        action: {}
    rotate_left:
      name: Dim down
      description: Rotate left
      default: []
      selector:
        action: {}
    button_press_right:
      name: Hold and rotate right
      description: Rotate right while holding
      default: []
      selector:
        action: {}
    button_press_left:
      name: Hold and rotate left
      description: Rotate left while holding
      default: []
      selector:
        action: {}
mode: restart
max_exceeded: silent

variables:
  input_group_name: !input 'group_name'
  input_group_group_object_id: !input 'group_object_id'

trigger:
- platform: event
  event_type: zha_event
  event_data:
    entity_id: input_group_group_object_id
action:
- variables:
    command: '{{ trigger.event.data.command }}'
    step_mode: '{{ trigger.event.data.params.step_mode }}'
- choose:
  - conditions: '{{ command == ''toggle'' }}'
    sequence: !input 'button_press'
  - conditions: '{{ command == ''step'' and step_mode == ''StepMode.Up'' }}'
    sequence: !input 'rotate_right'
  - conditions: '{{ command == ''step'' and step_mode == ''StepMode.Down'' }}'
    sequence: !input 'rotate_left'
  - conditions: '{{ command == ''step_color_temp'' and step_mode == ''StepMode.Up'' }}'
    sequence: !input 'button_press_right'
  - conditions: '{{ command == ''step_color_temp'' and step_mode == ''StepMode.Down'' }}'
    sequence: !input 'button_press_left'

This lets me assign a group (e.g. button.rotary_buttons_hallway), but then the blueprint never triggers.
How can I listen to the events from the buttons when they are in a group?

I don’t think that’s going to work… if these are Home Assistant groups, they aren’t going to post events of type zha_event to the Event bus, those events will be coming from the actual ZHA devices. You will need to use a template condition to see if the device that posted the event contains an entity in your group.

Is there something like a for loop, so I can check if any of the devices in the group triggered a zha event?

You shouldn’t need a loop… you should just be able to use the in test.

{{ 'a' in ['a', 'b', 'c'] }}

If you share an example or two of the events these devices produce and the groups you are using it would make it easier for us to provide more specific help… but you’ll need to set up an input and variable for the group’s entity id; then the template for the condition’s going to be something like:

{{ trigger.event.data.device_id in 
state_attr(group_entity_id_var, 'entity_id') | map('device_id') | list}}

Cool, will try that.
Events as follows:

Single Press

event_type: zha_event
data:
  device_ieee: a4:c1:38:ec:7a:54:ab:27
  unique_id: a4:c1:38:ec:7a:54:ab:27:1:0x0006
  device_id: 24649a18ec0cb8aade6a1eb621154d0d
  endpoint_id: 1
  cluster_id: 6
  command: toggle
  args: []
  params: {}
origin: LOCAL
time_fired: "2025-01-23T23:20:15.865994+00:00"
context:
  id: 01JJAQEQQSM8Z9M2XV6PFBW83M
  parent_id: null
  user_id: null   

Right turn

event_type: zha_event
data:
  device_ieee: a4:c1:38:ec:7a:54:ab:27
  unique_id: a4:c1:38:ec:7a:54:ab:27:1:0x0008
  device_id: 24649a18ec0cb8aade6a1eb621154d0d
  endpoint_id: 1
  cluster_id: 8
  command: step
  args:
    - 0
    - 13
    - 1
  params:
    step_mode: 0
    step_size: 13
    transition_time: 1
    options_mask: null
    options_override: null
origin: LOCAL
time_fired: "2025-01-23T23:28:55.575487+00:00"
context:
  id: 01JJAQYK8QSNEJNNYK61T7EV1F
  parent_id: null
  user_id: null

Left turn

event_type: zha_event
data:
  device_ieee: a4:c1:38:ec:7a:54:ab:27
  unique_id: a4:c1:38:ec:7a:54:ab:27:1:0x0008
  device_id: 24649a18ec0cb8aade6a1eb621154d0d
  endpoint_id: 1
  cluster_id: 8
  command: step
  args:
    - 1
    - 13
    - 1
  params:
    step_mode: 1
    step_size: 13
    transition_time: 1
    options_mask: null
    options_override: null
origin: LOCAL
time_fired: "2025-01-23T23:29:21.806346+00:00"
context:
  id: 01JJAQZCWECQ8ERV19R1QZANXF
  parent_id: null
  user_id: null