Hello ,
I am trying to dynamically set the source of my sonos one depending on a state given by a magic cube.
The automation doesn’t throw any errors. But it does not change the source of the media player. I have already added the stations as favorite in sonos app.
Any suggestions?
Here is the part that does not work.
- alias: Magic Cube Kueche Musiccontrol
initial_state: true
trigger:
- platform: state
entity_id: sensor.magiccube_kueche_faceup
action:
# - service: media_player.turn_on
# entity_id: media_player.sonos_kuche
- service: media_player.select_source
data_template:
entity_id: media_player.sonos_kuche
source: >
{% if is_state('sensor.magiccube_kueche_faceup', '1' ) %}
"Superfly.fm"
{%-elif is_state('sensor.magiccube_kueche_faceup', '2') %}
"BFBS Germany"
{%-elif is_state('sensor.magiccube_kueche_faceup', '3') %}
"Deluxe Lounge Radio"
{%-elif is_state('sensor.magiccube_kueche_faceup', '4') %}
"80s Flash"
{%-elif is_state('sensor.magiccube_kueche_faceup', '5') %}
"German Zeitgeist"
{%-elif is_state('sensor.magiccube_kueche_faceup', '6') %}
"pure fm Hamburg (House)"
{%-elif is_state('sensor.magiccube_kueche_faceup', '7') %}
"Cruise Control"
{%-elif is_state('sensor.magiccube_kueche_faceup', '8') %}
"Rare Grooves"
{%-elif is_state('sensor.magiccube_kueche_faceup', '9') %}
"Concert Hall"
{% else %}
"Superfly.fm"
{% endif %}