Executing a command for each member of an HA group?

I’m using the following to keep a google home speaker “alive” so it doesn’t make that annoying BRWAMP sound every time I push a sound to it. I’d like to extend this to every google device. I have a speaker group defined on Google Assistant called House which shows up in HA as media_player.house and tried using that, but unfortunately that didn’t work. Neither did creating a HA “universal” speaker group.

I created a HA group called google_home_devices and added each of my google devices to that. Is there a way of using templating to do a “for each X in google_home_devices” so that I can have an automation created for each device such that if the condition for X evaluates true, the action for X is executed? Or what about a simpler case where I just remove the condition entirely and just execute the command for each group member?

- alias: Keep Google Home Alive
  trigger:
    platform: time_pattern
    minutes: '/2'
    seconds: 00        
  condition:
    condition: or
    conditions:
      - condition: state
        entity_id: media_player.entryway_speaker
        state: 'off'
      - condition: state
        entity_id: media_player.entryway_speaker
        state: 'idle'
  action:
    - service: media_player.play_media
      entity_id: media_player.entryway_speaker
      data:
        media_content_id: https://homeassistant.example.com/local/1sec.mp3
        media_content_type: 'audio/mp3'
1 Like