@Mariusthvdb thanks a lot for this post!
I’m using this to not even/only create a group, but having a Symfonisk remote control whatever media players are currently playing in the house, with your entities list code directly in the entity_id.
Example for volume:
service: media_player.volume_set
target:
entity_id: >
{{expand('media_player.all_players') |selectattr('state','in',['playing','paused','buffering']) |map(attribute='entity_id')|list}}
data:
volume_level: "{{ state_attr('media_player.salon', 'volume_level') +0.01 }}"
I’m exploring whether it’s worth it for me to create/update a “Playing” group, if the remote/automation can directly target the running players each time (don’t need a UI for this scenario, which the group would cover).
Just posting in case it can be useful to someone in a similar situation