hello everyone I tried this fantastic solution to play music in my house, I created a PKG the volumes change, the mute works, the stop also but when I do Play it doesn’t play anything, I just changed my media players. how can i solve? thanks
I attach the code:
#################################################################
# #
# Radio #
# #
#################################################################
sensor:
#################################################################
- platform: scrape
resource: https://www.rtl2.fr/direct
name: RTL2_Pic
select: 'img[class="pic img-echo timeline-media--music__img"]'
attribute: data-src
- platform: scrape
resource: https://www.rtl2.fr/direct
name: RTL2_Artist
select: 'span[class="timeline-media--music__artist"]'
value_template: '{{ value | title }}'
- platform: scrape
resource: https://www.rtl2.fr/direct
name: RTL2_Track
select: 'strong[class="timeline-media--music__title"]'
value_template: '{{ value | title }}'
- platform: scrape
resource: https://absoluteradio.co.uk/classic-rock/music/
name: Absolute_Radio_CR_Pic
select: '.song-artist-image img'
attribute: src
- platform: scrape
resource: https://absoluteradio.co.uk/classic-rock/music/
name: Absolute_Radio_CR_Artist
select: '.song-artist-image img'
attribute: alt
- platform: scrape
resource: https://absoluteradio.co.uk/classic-rock/music/
name: Absolute_Radio_CR_Track
select: '.song-title a'
- platform: scrape
resource: https://absoluteradio.co.uk/absolute-radio/music/
name: Absolute_Radio_Pic
select: '.song-artist-image img'
attribute: src
- platform: scrape
resource: https://absoluteradio.co.uk/absolute-radio/music/
name: Absolute_Radio_Artist
select: '.song-artist-image img'
attribute: alt
- platform: scrape
resource: https://absoluteradio.co.uk/absolute-radio/music/
name: Absolute_Radio_Track
select: '.song-title a'
- platform: scrape
resource: https://hasspodcast.io/feed/podcast
name: ha_podcast
select: 'enclosure:nth-of-type(1)'
attribute: url
- platform: scrape
resource: https://hasspodcast.io/feed/podcast
name: ha_podcast_track
select: 'title:nth-of-type(3)'
- platform: scrape
resource: https://iotpodcast.com/feed/
name: internet_of_things_podcast
select: 'enclosure:nth-of-type(1)'
attribute: url
- platform: scrape
resource: https://iotpodcast.com/feed/
name: internet_of_things_podcast_track
select: 'title:nth-of-type(3)'
- platform: template
sensors:
stream_artist:
entity_id:
- sensor.rtl2_artist
- sensor.absolute_radio_cr_artist
- sensor.absolute_radio_artist
value_template: >
{% if is_state("input_select.radio_station", "RTL2") %} {{states.sensor.rtl2_artist.state}}
{% elif is_state("input_select.radio_station", "Absolute Radio") %} {{states.sensor.absolute_radio_artist.state}}
{% elif is_state("input_select.radio_station", "Absolute Radio Classic Rock") %} {{states.sensor.absolute_radio_CR_artist.state}}
{% elif is_state("input_select.radio_station", "Hit West") %} N/A
{% elif is_state("input_select.radio_station", "HA Podcast") %} Phil & Rohan
{% elif is_state("input_select.radio_station", "IoT Podcast") %} Stacey & Kevin
{% elif is_state("input_select.radio_station", "Chill") %} N/A
{% elif is_state("input_select.radio_station", "Custom Station") %} N/A
{% endif %}
friendly_name: Artist
icon_template: 'mdi:account'
stream_track:
entity_id:
- sensor.rtl2_track
- sensor.absolute_radio_track
- sensor.absolute_radio_cr_track
- sensor.ha_podcast_track
- sensor.internet_of_things_podcast_track
value_template: >
{% if is_state("input_select.radio_station", "RTL2") %} {{states.sensor.rtl2_track.state}}
{% elif is_state("input_select.radio_station", "Absolute Radio") %} {{states.sensor.absolute_radio_track.state}}
{% elif is_state("input_select.radio_station", "Absolute Radio Classic Rock") %} {{states.sensor.absolute_radio_CR_track.state}}
{% elif is_state("input_select.radio_station", "Hit West") %} N/A
{% elif is_state("input_select.radio_station", "HA Podcast") %} {{states.sensor.ha_podcast_track.state}}
{% elif is_state("input_select.radio_station", "IoT Podcast") %} {{states.sensor.internet_of_things_podcast_track.state}}
{% elif is_state("input_select.radio_station", "Chill") %} N/A
{% elif is_state("input_select.radio_station", "Custom Station") %} N/A
{% endif %}
friendly_name: Artist
icon_template: 'mdi:account'
camera:
#################################################################
- platform: generic
name: chromecast_radio_pic
still_image_url: >
{% if is_state("input_select.chromecast_radio_station", "RTL2") %} {{states.sensor.rtl2_pic.state}}
{% elif is_state("input_select.chromecast_radio_station", "Absolute Radio") %} {{states.sensor.absolute_radio_pic.state}}
{% elif is_state("input_select.chromecast_radio_station", "Absolute Radio Classic Rock") %} {{states.sensor.absolute_radio_CR_pic.state}}
{% elif is_state("input_select.chromecast_radio_station", "Hit West") %} https://upload.wikimedia.org/wikipedia/fr/b/bd/HitWestLogo.jpg
{% elif is_state("input_select.chromecast_radio_station", "HA Podcast") %} https://secureimg.stitcher.com/feedimageswide/480x270_176113.jpg
{% elif is_state("input_select.chromecast_radio_station", "IoT Podcast") %} https://is1-ssl.mzstatic.com/image/thumb/Music62/v4/b3/d6/64/b3d664ab-0560-f24d-2379-d01142267f94/source/1200x630bb.jpg
{% elif is_state("input_select.chromecast_radio_station", "Chill") %} http://images.radio.orange.com/radios/large_helpmechill.png
{% elif is_state("input_select.chromecast_radio_station", "Custom Station") %} https://www.holyscripturesandisrael.com/images/radio/radio-icon.png
{% endif %}
script:
#################################################################
play_chromecast_radio:
alias: Cast Selected Radio on Chromecast Speakers
sequence:
- service: media_player.volume_set
data_template:
entity_id: >
{% if is_state("input_select.chromecast_radio_speakers", "Salotto") %} media_player.googlehome3627
{% elif is_state("input_select.chromecast_radio_speakers", "Bagno") %} media_player.bagno
{% elif is_state("input_select.chromecast_radio_speakers", "Studio") %} media_player.googlehome5227
{% elif is_state("input_select.chromecast_radio_speakers", "Casa") %} media_player.gruppo_casa_3
{% endif %}
volume_level: '{{ states.input_number.volume_radio.state }}'
- service: media_player.play_media
data_template:
entity_id: >
{% if is_state("input_select.chromecast_radio_speakers", "Bagno") %} media_player.bagno
{% elif is_state("input_select.chromecast_radio_speakers", "Studio") %} media_player.googlehome5227
{% elif is_state("input_select.chromecast_radio_speakers", "Salotto") %} media_player.googlehome3627
{% elif is_state("input_select.chromecast_radio_speakers", "Casa") %} media_player.gruppo_casa_3
{% endif %}
media_content_id: >
{% if is_state("input_select.chromecast_radio_station", "RTL2") %} http://streaming.radio.rtl2.fr:80/rtl2-1-44-96
{% elif is_state("input_select.chromecast_radio_station", "Absolute Radio") %} http://icy-e-bab-04-cr.sharp-stream.com/absoluteradio.mp3
{% elif is_state("input_select.chromecast_radio_station", "Absolute Radio Classic Rock") %} http://icy-e-bab-04-cr.sharp-stream.com/absoluteclassicrock.mp3
{% elif is_state("input_select.chromecast_radio_station", "Hit West") %} http://broadcast.infomaniak.ch/hitwest-high.mp3
{% elif is_state("input_select.chromecast_radio_station", "HA Podcast") %} {{states.sensor.ha_podcast.state}}
{% elif is_state("input_select.chromecast_radio_station", "IoT Podcast") %} {{states.sensor.internet_of_things_podcast.state}}
{% elif is_state("input_select.chromecast_radio_station", "Chill") %} http://media-the.musicradio.com/ChillMP3
{% elif is_state("input_select.chromecast_radio_station", "Custom Station") %} {{states.input_text.custom_station.state}}
{% endif %}
media_content_type: 'audio/mp4'
stop_chromecast_radio:
alias: Stop Playing Radio on ChomeCast
sequence:
- service: media_player.turn_off
data_template:
entity_id: >
{% if is_state("input_select.chromecast_radio_speakers", "Salotto") %} media_player.googlehome3627
{% elif is_state("input_select.chromecast_radio_speakers", "Bagno") %} media_player.bagno
{% elif is_state("input_select.chromecast_radio_speakers", "Studio") %} media_player.googlehome5227
{% elif is_state("input_select.chromecast_radio_speakers", "Casa") %} media_player.gruppo_casa_3
{% endif %}
switch:
#################################################################
- platform: template
switches:
chromecast_radio_mute:
icon_template: '{% if states("switch.chromecast_radio_mute") %}mdi:volume-off{% else %}mdi:volume-high{% endif %}'
value_template: >
{% if is_state("input_select.chromecast_radio_speakers", "Salotto") %} {% if states.media_player.googlehome3627.attributes.is_volume_muted %}on{% else %}off{% endif %}
{% elif is_state("input_select.chromecast_radio_speakers", "Bagno") %} {% if states.media_player.bagno.attributes.is_volume_muted %}on{% else %}off{% endif %}
{% elif is_state("input_select.chromecast_radio_speakers", "Studio") %} {% if states.media_player.googlehome5227.attributes.is_volume_muted %}on{% else %}off{% endif %}
{% elif is_state("input_select.chromecast_radio_speakers", "Casa") %} {% if states.media_player.gruppo_casa_3.attributes.is_volume_muted %}on{% else %}off{% endif %}
{% else %}off
{% endif %}
turn_on:
service: media_player.volume_mute
data_template:
entity_id: >
{% if is_state("input_select.chromecast_radio_speakers", "Salotto") %} media_player.googlehome3627
{% elif is_state("input_select.chromecast_radio_speakers", "Bagno") %} media_player.bagno
{% elif is_state("input_select.chromecast_radio_speakers", "Studio") %} media_player.googlehome5227
{% elif is_state("input_select.chromecast_radio_speakers", "Casa") %} media_player.gruppo_casa_3
{% endif %}
is_volume_muted: true
turn_off:
service: media_player.volume_mute
data_template:
entity_id: >
{% if is_state("input_select.chromecast_radio_speakers", "Salotto") %} media_player.googlehome3627
{% elif is_state("input_select.chromecast_radio_speakers", "Bagno") %} media_player.bagno
{% elif is_state("input_select.chromecast_radio_speakers", "Studio") %} media_player.googlehome5227
{% elif is_state("input_select.chromecast_radio_speakers", "Casa") %} media_player.gruppo_casa_3
{% endif %}
is_volume_muted: false
chromecast_radio_vol_up:
icon_template: 'mdi:volume-plus'
value_template: 'on'
turn_on:
service: media_player.volume_up
data_template:
entity_id: >
{% if is_state("input_select.chromecast_radio_speakers", "Salotto") %} media_player.googlehome3627
{% elif is_state("input_select.chromecast_radio_speakers", "Bagno") %} media_player.bagno
{% elif is_state("input_select.chromecast_radio_speakers", "Studio") %} media_player.googlehome5227
{% elif is_state("input_select.chromecast_radio_speakers", "Casa") %} media_player.gruppo_casa_3
{% endif %}
turn_off:
service: media_player.volume_up
data_template:
entity_id: >
{% if is_state("input_select.chromecast_radio_speakers", "Salotto") %} media_player.googlehome3627
{% elif is_state("input_select.chromecast_radio_speakers", "Bagno") %} media_player.bagno
{% elif is_state("input_select.chromecast_radio_speakers", "Studio") %} media_player.googlehome5227
{% elif is_state("input_select.chromecast_radio_speakers", "Casa") %} media_player.gruppo_casa_3
{% endif %}
chromecast_radio_vol_down:
icon_template: 'mdi:volume-minus'
value_template: 'on'
turn_on:
service: media_player.volume_down
data_template:
entity_id: >
{% if is_state("input_select.chromecast_radio_speakers", "Salotto") %} media_player.googlehome3627
{% elif is_state("input_select.chromecast_radio_speakers", "Bagno") %} media_player.bagno
{% elif is_state("input_select.chromecast_radio_speakers", "Studio") %} media_player.googlehome5227
{% elif is_state("input_select.chromecast_radio_speakers", "Casa") %} media_player.gruppo_casa_3
{% endif %}
turn_off:
service: media_player.volume_down
data_template:
entity_id: >
{% if is_state("input_select.chromecast_radio_speakers", "Salotto") %} media_player.googlehome3627
{% elif is_state("input_select.chromecast_radio_speakers", "Bagno") %} media_player.bagno
{% elif is_state("input_select.chromecast_radio_speakers", "Studio") %} media_player.googlehome5227
{% elif is_state("input_select.chromecast_radio_speakers", "Casa") %} media_player.gruppo_casa_3
{% endif %}
chromecast_radio_play:
icon_template: 'mdi:play'
value_template: 'on'
turn_on:
service: script.turn_on
entity_id: script.play_chromecast_radio
turn_off:
service: script.turn_on
entity_id: script.play_chromecast_radio
chromecast_radio_stop:
icon_template: 'mdi:stop'
value_template: 'on'
turn_on:
service: script.turn_on
entity_id: script.stop_chromecast_radio
turn_off:
service: script.turn_on
entity_id: script.stop_chromecast_radio
input_select:
#################################################################
chromecast_radio_station:
name: 'Select Radio Station:'
options:
- Absolute Radio
- Absolute Radio Classic Rock
- Chill
- Hit West
- HA Podcast
- IoT Podcast
- RTL2
- Custom Station
icon: mdi:radio
chromecast_radio_speakers:
name: 'Select Speakers:'
options:
- Salotto
- Casa
- Bagno
- Studio
initial: Casa
icon: mdi:speaker-wireless
input_text:
#################################################################
custom_station:
name: Radio URL
icon: mdi:link-variant