Hello,
my objective is to use 3 soundtouch speakers to broadcast messages via the tts command. In an automation I generate fields for the number of devices switched on, the status of the spotify player and lists for switched on/off devices. I pass those field to a script. After the tts sequence, I want to switch off those media_players, which were not on at the beginning (mediaplayer_off). This works fine with
service_template: |-
{% if count_off != 0 %}
media_player.turn_off
{% endif %}
data:
entity_id: ‘{{mediaplayer_off}}’
unless all media_players are on. Then mediaplayer_off is an empty list. I also restart spotify, if the spotify player played before with the following sequence:
service_template: |-
{% if spotify_on == true %}
media_player.media_play_pause
{% endif %}
data:
entity_id: media_player.spotify_player
If now all 3 media_players (soundtouch) are on I simply want to combine both sequences into
service_template: |-
{% if count_off != 0 %}
media_player.turn_off
{% elif spotify_on == true %}
media_player.media_play_pause
{% endif %}
data_template:
entity_id: |-
{% if count_off != 0 %}
‘{{mediaplayer_off}}’
{% elif spotify_on == true %}
media_player.spotify_player
{% endif %}
but this sequence is not executed. I tried the sequence in the developer_tools → templates and got in my opinion the right output, which would restart spotify, when all 3 mediaplayers (soundtouch) are on. Any idea, why the combination of service_template and data_template is not working?
Regards,
Volker