Hi there,
I’m struggling a bit with an automation where I want to set a volume to all speakers with “on” state.
I have to create a template which gives me all speakers with “on” state, so I can set the volume on them.
First I’ve created a speaker group:
media_player:
- platform: group
name: Lautsprecher
entities:
- media_player.player1
- media_player.player2
- media_player.player3
- media_player.player4
- media_player.player5
- media_player.player6
- media_player.player7
According to the documentation (Working with Groups) I tried to create the following template:
{% for entity_id in expand('media_player.lautsprecher') %}
{% if is_state(entity_id.entity_id, 'on') %}
{{- entity_id.entity_id }}
{% endif %}
{% endfor %}
As a result I get media_player.lautsprecher
, although it’s not in the group and other media players have the “on” state.
For me it seems as if the expand()
function doesn’t work as stated in the documentation, but I have too less experience with templates to be sure. Can anybody help me to figure out what’s wrong here?
Many thanks in advance!