Hi,
How would you tweak this one;
I went with the original code and everything seem to work perfectly, with my Google Home and my Chromecast. But one problem I came across, was when trying to stream audio to my chromecast that is connected to my AVR. When I select “media_player.denon_chromecast_audio” then it will try to stream to that device and probably also does. Unfortunately my AVR doesn’t turn on, nor the Zone where I want to “Living Room”.
If I add the media_player.turn_on in the script below, then it will just always turn it on, no matter what media player I select.
Does anyone have a good approach (sorry if I have missed a post where this already have been addressed).
script:
afspil_radio:
alias: Play Radio Audio Unit
sequence:
- service: media_player.volume_set
data:
entity_id: media_player.home_assistant_stue
volume_level: '0.20'
- service: media_player.play_media
data_template:
entity_id: >
{% if is_state("input_select.chromecast_radio", "Living Room") %} media_player.home_assistant_stue
{% elif is_state("input_select.chromecast_radio", "Bathroomn") %} media_player.denon_chromecast_audio
{% elif is_state("input_select.chromecast_radio", "All") %} media_player.all_rooms
{% endif %}
media_content_id: >
{% if is_state("input_select.radio_station", "Radio 538") %} http://vip-icecast.538.lw.triple-it.nl:80/RADIO538_MP3
{% elif is_state("input_select.radio_station", "Q-Music") %} http://icecast-qmusic.cdp.triple-it.nl/Qmusic_nl_live_96.mp3
{% elif is_state("input_select.radio_station", "3FM") %} http://icecast.omroep.nl/3fm-bb-mp3
{% elif is_state("input_select.radio_station", "100% NL") %} http://stream.100p.nl/100pctnl.mp3
{% elif is_state("input_select.radio_station", "Veronica") %} http://8543.live.streamtheworld.com/VERONICACMP3
{% elif is_state("input_select.radio_station", "Sky Radio") %} http://8623.live.streamtheworld.com:80/SKYRADIOAAC_SC
{% elif is_state("input_select.radio_station", "Arrow Classic Rock") %} http://91.221.151.155/listen.mp3
{% elif is_state("input_select.radio_station", "Classic FM") %} http://19143.live.streamtheworld.com/CLASSICFM_SC
{% elif is_state("input_select.radio_station", "BNR Nieuwsradio") %} http://icecast-bnr.cdp.triple-it.nl/bnr_mp3_96_03
{% elif is_state("input_select.radio_station", "SLAM! Hardstyle") %} http://vip-icecast.538.lw.triple-it.nl/WEB17_MP3
{% elif is_state("input_select.radio_station", "Sleep Radio") %} http://37.59.28.208:8722/stream
{% elif is_state("input_select.radio_station", "Ambient Sleeping Pill") %} http://perseus.shoutca.st:8447/h
{% elif is_state("input_select.radio_station", "Radio Art - Sleep") %} http://live.radioart.com/fSleep.mp3
{% elif is_state("input_select.radio_station", "Ambi Nature Radio") %} http://94.23.252.14:8067/stream
{% elif is_state("input_select.radio_station", "Calm Radio - Sleep") %} http://streams.calmradio.com/api/39/128/stream
{% elif is_state("input_select.radio_station", "Dinamo.FM Sleep") %} http://channels.dinamo.fm/sleep-aac
{% endif %}
media_content_type: 'audio/mp4'
EDIT:
I solved it by putting in the below code just after the media_player.play_media
- service: media_player.turn_on
data_template:
entity_id: >
{% if is_state("input_select.chromecast_radio", "Stue") %} media_player.stue_kokken
{% elif is_state("input_select.chromecast_radio", "Bade") %} media_player.badevaerelser
{% elif is_state("input_select.chromecast_radio", "Alle Rum") %} media_player.stue_kokken, media_player.badevaerelser
{% endif %}