For each entity in group

Hi together. I need to build a really simple script automation but I’m stuggling with an error…

I have a group entity called group.as_trigger_array. This group entity gets filled with other entites by another automation with this action:

action: group.set
metadata: {}
data:
  object_id: as_trigger_array
  add_entities: <template which adds the entities>

This works as expected as I go into the develeper tools I get this result:

Now I want to build a script that repeats a specific action for each of these entities listed in the group. I’ve followed this existing community article but I get an error saying:

The full script looks like this:

sequence:
  - repeat:
      for_each: "{{ state_attr('group.as_trigger_array', 'entity_id') }}"
      sequence:
        - action: notify.mobile_app_pixel_8_pro
          metadata: {}
          data:
            message: TEST
            title: TEST
alias: Clear Alarm Notifications
description: ""

I would be very thankful if anyone could help me with this.

alias: Clear Alarm Notifications
description: ""
sequence:
  - repeat:
      type: for_each
      for_each: "{{ state_attr('group.as_trigger_array', 'entity_id') }}"
      sequence:
        - service: notify.mobile_app_pixel_8_pro
          data:
            message: "TEST"
            title: "TEST"

repeat in Home Assistant requires a type key when using for_each. Without it, it might not run correctly. You should specify type: for_each explicitly.

I’ve found it out myself. It needed | list at the end.

sequence:
  - repeat:
      for_each: "{{ state_attr('group.as_trigger_array', 'entity_id') | list }}"
      sequence:
        - action: notify.mobile_app_pixel_8_pro
          metadata: {}
          data:
            message: TEST
            title: TEST
alias: Clear Alarm Notifications
description: ""