Loop through members of groups

I have multiple groups with multiple members. F.e. i have a group of covers and i want to close them. If i want to close each cover with a delay i dont have a chance to manage it. This could also be applied on lights etc…

It would therefore be very helpful if you could call up each member individually in an automation.

For example:
for each member of group.light do a delay of 5s and switch it off

A group’s members are listed in its entity_id attribute.

You can use a repeat for_each to iterate through a group’s members.

  - repeat:
      for_each: "{{ state_attr('group.light', 'entity_id') }}"
        - service: light.turn_off
            entity_id: "{{ repeat.item }}"
        - delay: "00:00:05"


Correction. Fixed second template.

1 Like

thanks, it works great!

is there also a mechanism that displays me all known members and their states of a group on a lovelace card? so i only select the group entity and it shows me all members?

It’s displayed in Developer Tools > States. Other than that, I’m unaware of a card that does the same thing.

Auto-Entities-Card can do this.