Radio streaming with Album Art, Artist and Track Name

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

Hi @sadek

You won’t be able to scrape that page because the data is loaded via scripts
(try to show the page source and search for the artist name, you won’t find it)

is this for all stations?
RTL2, Chill and Absolute Radio have changed their web page since I posted this.
I’ve also moved away from HA Scrape sensors and created my own script to retrieve the data more often (every 15sec) as opposed to every minute (default in HA)
I’ll try and create a package with the new data.

hello and thanks for the answer, yes for all the stations the code I posted is correct in your opinion? if you do some new package let me know that I’m interested

any help for me?

found what’s wrong. You don’t have the input_number in your package (which to be fair I think I forgot in my earlier posts)
Anyway I’ve updated your package file with the latest data from my current setup. I think I have everything.
Please note I’ve not created packages before so you probably will need to “personalise” some things

Package Code
#################################################################
#                                                               #
#                           Radio                               #
#                                                               #
#################################################################



#################################################################
automation:
  - alias: Chromecast - Set Radio Volume
    initial_state: true
    trigger:
      platform: state
      entity_id: input_number.volume_radio
    action:
      service: media_player.volume_set
      data_template:
        entity_id: >
          {% if is_state("input_select.chromecast_radio_speakers", "Conservatory") %} media_player.conservatory
          {% elif is_state("input_select.chromecast_radio_speakers", "Kitchen") %} media_player.kitchen
          {% elif is_state("input_select.chromecast_radio_speakers", "Onkyo_TX_NR656_2") %} media_player.onkyo_tx_nr656
          {% elif is_state("input_select.chromecast_radio_speakers", "House") %} media_player.house
          {% endif %}
        volume_level: '{{  states("input_number.volume_radio")  }}'

  - alias: Start RadioStream Scrape At Startup
    initial_state: true
    trigger:
      - platform: homeassistant
        event: start
    action:
    - service: shell_command.stop_radiostream_sensors
    - delay: 00:00:02
    - service: shell_command.start_radiostream_sensors

#################################################################
binary_sensor:
  - platform: template
    sensors:
      radio_is_streaming:
        entity_id:
          - media_player.conservatory
          - media_player.house
          - media_player.kitchen
          - media_player.onkyo
          - media_player.onkyo_tx_nr656_2
        value_template: >
          {% set myval = namespace(found=0) %}
          {%- for state in states.media_player -%}
          {%- if state.entity_id in ["media_player.conservatory", "media_player.house", "media_player.kitchen", "media_player.onkyo", "media_player.onkyo_tx_nr656_2"] -%}
          {% if state_attr(state.entity_id, "media_content_id") in ["http://streaming.radio.rtl2.fr:80/rtl2-1-44-96", "http://icy-e-bab-04-cr.sharp-stream.com/absoluteradio.mp3", "http://icy-e-bab-04-cr.sharp-stream.com/absoluteclassicrock.mp3", "http://broadcast.infomaniak.ch/hitwest-high.mp3", states("sensor.ha_podcast"), states("sensor.internet_of_things_podcast"), "http://media-the.musicradio.com/ChillMP3", "http://peridot.streamguys.com:7150/RFTwo?play", states("input_text.custom_station")] -%}{% set myval.found = myval.found + 1%}{%- endif -%}
          {%- endif -%}  
          {%- endfor %}
          {{ myval.found > 0 }}

#################################################################
input_number:
  volume_radio:
    name: Volume
    icon: mdi:volume-high
    initial: 0.4
    min: 0
    max: 1
    step: 0.05

#################################################################
input_select:
  chromecast_radio_station:
    name: 'Select Radio Station'
    options:
      - Absolute Radio
      - Absolute Radio Classic Rock
      - Chill
      - Hit West
      - HA Podcast
      - IoT Podcast
      - Navtarang
      - Radio Fiji Two
      - RTL2
      - Custom Station
    icon: mdi:radio

  chromecast_radio_speakers:
    name: 'Select Speakers'
    options:
      - Conservatory
      - House
      - Kitchen
      - Onkyo_TX_NR656_2
    icon: mdi:speaker-wireless

#################################################################
input_text:
  custom_station:
    name: Radio URL
    icon: mdi:link-variant

#################################################################
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", "Conservatory") %} media_player.conservatory
            {% elif is_state("input_select.chromecast_radio_speakers", "Kitchen") %} media_player.kitchen
            {% elif is_state("input_select.chromecast_radio_speakers", "Onkyo_TX_NR656_2") %} media_player.onkyo_tx_nr656_2
            {% elif is_state("input_select.chromecast_radio_speakers", "House") %} media_player.house
            {% endif %}
          volume_level: '{{  states("input_number.volume_radio")  }}' 
      - service: media_player.play_media
        data_template:
          entity_id: >
            {% if is_state("input_select.chromecast_radio_speakers", "Kitchen") %} media_player.kitchen
            {% elif is_state("input_select.chromecast_radio_speakers", "Onkyo_TX_NR656_2") %} media_player.onkyo_tx_nr656_2
            {% elif is_state("input_select.chromecast_radio_speakers", "Conservatory") %} media_player.conservatory
            {% elif is_state("input_select.chromecast_radio_speakers", "House") %} media_player.house
            {% 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")}}
            {% elif is_state("input_select.chromecast_radio_station", "IoT Podcast") %} {{states("sensor.internet_of_things_podcast")}}
            {% elif is_state("input_select.chromecast_radio_station", "Chill") %} http://media-the.musicradio.com/ChillMP3
            {% elif is_state("input_select.chromecast_radio_station", "Radio Fiji Two") %} http://peridot.streamguys.com:7150/RFTwo?play
            {% elif is_state("input_select.chromecast_radio_station", "Navtarang") %} http://192.111.142.176:8000/NAVTARANG
            {% elif is_state("input_select.chromecast_radio_station", "Custom Station") %} {{states("input_text.custom_station")}}
            {% 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", "Conservatory") %} media_player.conservatory
            {% elif is_state("input_select.chromecast_radio_speakers", "Kitchen") %} media_player.kitchen
            {% elif is_state("input_select.chromecast_radio_speakers", "Onkyo_TX_NR656_2") %} media_player.onkyo_tx_nr656_2
            {% elif is_state("input_select.chromecast_radio_speakers", "House") %} media_player.house
            {% endif %}

#################################################################
sensor:
  - platform: mqtt
    name: "RTL2_Pic"
    state_topic: "RadioStream/RTL2/pic_url"
    value_template: "{{ value }}"

  - platform: mqtt
    name: "RTL2_Artist"
    state_topic: "RadioStream/RTL2/artist"
    value_template: "{{ value }}"

  - platform: mqtt
    name: "RTL2_Track"
    state_topic: "RadioStream/RTL2/track"
    value_template: "{{ value }}"

  - platform: mqtt
    name: "Chill_Pic"
    state_topic: "RadioStream/Chill/pic_url"
    value_template: "{{ value }}"

  - platform: mqtt
    name: "Chill_Artist"
    state_topic: "RadioStream/Chill/artist"
    value_template: "{{ value }}"

  - platform: mqtt
    name: "Chill_Track"
    state_topic: "RadioStream/Chill/track"
    value_template: "{{ value }}"

  - platform: mqtt
    name: "Absolute_Radio_Pic"
    state_topic: "RadioStream/Absolute_Radio/pic_url"
    value_template: "{{ value }}"

  - platform: mqtt
    name: "Absolute_Radio_Artist"
    state_topic: "RadioStream/Absolute_Radio/artist"
    value_template: "{{ value }}"

  - platform: mqtt
    name: "Absolute_Radio_Track"
    state_topic: "RadioStream/Absolute_Radio/track"
    value_template: "{{ value }}"

  - platform: mqtt
    name: "Absolute_Radio_CR_Pic"
    state_topic: "RadioStream/Absolute_Radio_CR/pic_url"
    value_template: "{{ value }}"

  - platform: mqtt
    name: "Absolute_Radio_CR_Artist"
    state_topic: "RadioStream/Absolute_Radio_CR/artist"
    value_template: "{{ value }}"

  - platform: mqtt
    name: "ha_podcast"
    state_topic: "RadioStream/Hass Podcast/mp3_url"
    value_template: "{{ value }}"

  - platform: mqtt
    name: "ha_podcast_track"
    state_topic: "RadioStream/Hass Podcast/track"
    value_template: "{{ value }}"

  - platform: mqtt
    name: "Absolute_Radio_CR_Track"
    state_topic: "RadioStream/Absolute_Radio_CR/track"
    value_template: "{{ value }}"

  - platform: mqtt
    name: "internet_of_things_podcast"
    state_topic: "RadioStream/IoT Podcast/mp3_url"
    value_template: "{{ value }}"

  - platform: mqtt
    name: "internet_of_things_podcast_track"
    state_topic: "RadioStream/IoT Podcast/track"
    value_template: "{{ value }}"


  - platform: template
    sensors:
      stream_artist:
        entity_id:
          - sensor.rtl2_artist
          - sensor.absolute_radio_cr_artist
          - sensor.absolute_radio_artist
          - sensor.rtl2_track
          - sensor.absolute_radio_track
          - sensor.absolute_radio_cr_track
          - sensor.ha_podcast_track
          - sensor.rtl2_pic
          - sensor.absolute_radio_cr_pic
          - sensor.absolute_radio_pic
          - input_select.chromecast_radio_station
          - input_select.chromecast_radio_speakers
        value_template: >
          {% if is_state("input_select.chromecast_radio_station", "RTL2") %} {{states("sensor.rtl2_artist")}}
          {% elif is_state("input_select.chromecast_radio_station", "Absolute Radio") %} {{states("sensor.absolute_radio_artist")}}
          {% elif is_state("input_select.chromecast_radio_station", "Absolute Radio Classic Rock") %} {{states("sensor.absolute_radio_CR_artist")}}
          {% elif is_state("input_select.chromecast_radio_station", "Hit West") %} N/A
          {% elif is_state("input_select.chromecast_radio_station", "HA Podcast") %} Phil & Rohan
          {% elif is_state("input_select.chromecast_radio_station", "IoT Podcast") %} Stacey & Kevin
          {% elif is_state("input_select.chromecast_radio_station", "Chill") %} {{states("sensor.chill_artist")}}
          {% elif is_state("input_select.chromecast_radio_station", "Navtarang") %} N/A
          {% elif is_state("input_select.chromecast_radio_station", "Radio Fiji Two") %} N/A
          {% elif is_state("input_select.chromecast_radio_station", "Custom Station") %} N/A
          {% endif %}
        friendly_name: Artist
        icon_template: 'mdi:account'
      stream_track:
        entity_id:
          - sensor.rtl2_artist
          - sensor.absolute_radio_cr_artist
          - sensor.absolute_radio_artist
          - sensor.rtl2_track
          - sensor.absolute_radio_track
          - sensor.absolute_radio_cr_track
          - sensor.ha_podcast_track
          - sensor.rtl2_pic
          - sensor.absolute_radio_cr_pic
          - sensor.absolute_radio_pic
          - sensor.internet_of_things_podcast_track
          - input_select.chromecast_radio_station
          - input_select.chromecast_radio_speakers
        value_template: >
          {% if is_state("input_select.chromecast_radio_station", "RTL2") %} {{states("sensor.rtl2_track")}}
          {% elif is_state("input_select.chromecast_radio_station", "Absolute Radio") %} {{states("sensor.absolute_radio_track")}}
          {% elif is_state("input_select.chromecast_radio_station", "Absolute Radio Classic Rock") %} {{states("sensor.absolute_radio_CR_track")}}
          {% elif is_state("input_select.chromecast_radio_station", "Hit West") %} N/A
          {% elif is_state("input_select.chromecast_radio_station", "HA Podcast") %} {{states("sensor.ha_podcast_track")}}
          {% elif is_state("input_select.chromecast_radio_station", "IoT Podcast") %} {{states("sensor.internet_of_things_podcast_track")}}
          {% elif is_state("input_select.chromecast_radio_station", "Chill") %} {{states("sensor.chill_track")}}
          {% elif is_state("input_select.chromecast_radio_station", "Navtarang") %} N/A
          {% elif is_state("input_select.chromecast_radio_station", "Radio Fiji Two") %} N/A
          {% elif is_state("input_select.chromecast_radio_station", "Custom Station") %} N/A
          {% endif %}
        friendly_name: Artist
        icon_template: 'mdi:account'

#################################################################
shell_command:
  stop_radiostream_sensors: /config/shell_scripts/stop_radiostream_sensors.sh
  start_radiostream_sensors: /config/shell_scripts/start_radiostream_sensors.sh

#################################################################
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", "Conservatory") %} {% if state_attr("media_player.conservatory","is_volume_muted") %}on{% else %}off{% endif %}
          {% elif is_state("input_select.chromecast_radio_speakers", "Kitchen") %} {% if state_attr("media_player.kitchen","is_volume_muted") %}on{% else %}off{% endif %}
          {% elif is_state("input_select.chromecast_radio_speakers", "Onkyo") %} {% if state_attr("media_player.onkyo_tx_nr656","is_volume_muted") %}on{% else %}off{% endif %}
          {% elif is_state("input_select.chromecast_radio_speakers", "House") %} {% if state_attr("media_player.house","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", "Conservatory") %} media_player.conservatory
              {% elif is_state("input_select.chromecast_radio_speakers", "Kitchen") %} media_player.kitchen
              {% elif is_state("input_select.chromecast_radio_speakers", "Onkyo") %} media_player.onkyo_tx_nr656
              {% elif is_state("input_select.chromecast_radio_speakers", "House") %} media_player.house
              {% endif %}
            is_volume_muted: true
        turn_off:
          service: media_player.volume_mute
          data_template:
            entity_id: >
              {% if is_state("input_select.chromecast_radio_speakers", "Conservatory") %} media_player.conservatory
              {% elif is_state("input_select.chromecast_radio_speakers", "Kitchen") %} media_player.kitchen
              {% elif is_state("input_select.chromecast_radio_speakers", "Onkyo") %} media_player.onkyo_tx_nr656
              {% elif is_state("input_select.chromecast_radio_speakers", "House") %} media_player.house
              {% 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", "Conservatory") %} media_player.conservatory
              {% elif is_state("input_select.chromecast_radio_speakers", "Kitchen") %} media_player.kitchen
              {% elif is_state("input_select.chromecast_radio_speakers", "Onkyo") %} media_player.onkyo_tx_nr656
              {% elif is_state("input_select.chromecast_radio_speakers", "House") %} media_player.house
              {% endif %}
        turn_off:
          service: media_player.volume_up
          data_template:
            entity_id: >
              {% if is_state("input_select.chromecast_radio_speakers", "Conservatory") %} media_player.conservatory
              {% elif is_state("input_select.chromecast_radio_speakers", "Kitchen") %} media_player.kitchen
              {% elif is_state("input_select.chromecast_radio_speakers", "Onkyo") %} media_player.onkyo_tx_nr656
              {% elif is_state("input_select.chromecast_radio_speakers", "House") %} media_player.house
              {% 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", "Conservatory") %} media_player.conservatory
              {% elif is_state("input_select.chromecast_radio_speakers", "Kitchen") %} media_player.kitchen
              {% elif is_state("input_select.chromecast_radio_speakers", "Onkyo") %} media_player.onkyo_tx_nr656
              {% elif is_state("input_select.chromecast_radio_speakers", "House") %} media_player.house
              {% endif %}
        turn_off:
          service: media_player.volume_down
          data_template:
            entity_id: >
              {% if is_state("input_select.chromecast_radio_speakers", "Conservatory") %} media_player.conservatory
              {% elif is_state("input_select.chromecast_radio_speakers", "Kitchen") %} media_player.kitchen
              {% elif is_state("input_select.chromecast_radio_speakers", "Onkyo") %} media_player.onkyo_tx_nr656
              {% elif is_state("input_select.chromecast_radio_speakers", "House") %} media_player.house
              {% 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

You also need a few scripts. Mine are saved in the shell_scripts folder. Make sure you change the MQTT credentials in the python file…

start_radiostream_sensors.sh
cd /config/shell_scripts/ && python HA_Scrape.py
stop_radiostream_sensors.sh
pkill -f HA_Scrape &> /dev/null
HA_Scrape.py
#!/usr/bin/python
# -*- coding: utf-8 -*-

from bs4 import BeautifulSoup
from urllib.request import urlopen
import paho.mqtt.client as mqtt
import time
from threading import Thread

import secrets

MQTT_Host = secrets.MQTT_Host
MQTT_Port = secrets.MQTT_Port
MQTT_User = secrets.MQTT_User
MQTT_Password = secrets.MQTT_Password

client = mqtt.Client("HA_Scraper") # must be unique on MQTT network
client.username_pw_set(str(MQTT_User),str(MQTT_Password))
client.connect(MQTT_Host, port=MQTT_Port, keepalive=60)
client.loop_start()



class Radio:

	# Initializer / Instance Attributes
	def __init__(self, name, url, pic, pic_sel, pic_att, artist, artist_sel, artist_att, track, track_sel, track_att):
		self.name = name
		self.url = url
		self.pic = pic
		self.pic_sel = pic_sel
		self.pic_att = pic_att
		self.artist = artist
		self.artist_sel = artist_sel
		self.artist_att = artist_att
		self.track = track
		self.track_sel = track_sel
		self.track_att = track_att



class Podcast:

	# Initializer / Instance Attributes
	def __init__(self, name, url, track, track_sel, track_att, mp3_url, mp3_sel, mp3_att):
		self.name = name
		self.url = url
		self.track = track
		self.track_sel = track_sel
		self.track_att = track_att
		self.mp3_url = mp3_url
		self.mp3_sel = mp3_sel
		self.mp3_att = mp3_att


RTL2 = Radio("RTL2", "https://www.6play.fr/rtl2/quel-est-ce-titre", "", ".ecfper-2", "src", "", ".ecfper-6", "", "", ".ecfper-5", "")
Absolute_Radio_CR = Radio("Absolute_Radio_CR", "https://planetradio.co.uk/absolute-radio-60s/player/", "", ".station-cards .station-card:nth-of-type(2) a .main-img", "style", "", ".station-cards .station-card:nth-of-type(2) a .text-wrapper .text .artist", "", "", ".station-cards .station-card:nth-of-type(2) a .text-wrapper .text .track", "")
Absolute_Radio = Radio("Absolute_Radio", "https://planetradio.co.uk/absolute-radio-60s/player/", "", ".station-cards .station-card:nth-of-type(1) a .main-img", "style", "", ".station-cards .station-card:nth-of-type(1) a .text-wrapper .text .artist", "", "", ".station-cards .station-card:nth-of-type(1) a .text-wrapper .text .track", "")
IoT_Podcast = Podcast("IoT Podcast", "https://iotpodcast.com/feed/", "", "item:nth-of-type(1) title", "", "","enclosure:nth-of-type(1)", "url")
Hass_Podcast = Podcast("Hass Podcast", "https://hasspodcast.io/feed/podcast", "", "item:nth-of-type(1) title", "", "","enclosure:nth-of-type(1)", "url")
Chill = Radio("Chill", "https://www.smoothradio.com/chill/radio/playlist/", "", ".js-lazy", "data-src", "", ".now-playing__text-content__details__artist", "", "", ".now-playing__text-content__details__track", "")




def bs_get_value_radio(radio):
	content = urlopen(radio.url).read()

	try:
		raw_data = BeautifulSoup(content,"html.parser")
	except Exception as e:
		print("%s Unable to get BS from URL" % e)
	try:
		if(radio.pic != raw_data.select(radio.pic_sel)[0][radio.pic_att]):
			radio.pic = raw_data.select(radio.pic_sel)[0][radio.pic_att].replace("background-image:url(", "").replace(")", "")
			client.publish("RadioStream/"+radio.name+"/pic_url",radio.pic.encode('ascii'), qos=0, retain=True)

	except Exception as e:
		print ("Can't get "+radio.name+" Image")
	try:
		if (radio.artist_att):
			if(radio.artist != raw_data.select(radio.artist_sel)[0][radio.artist_att]):
				radio.artist = raw_data.select(radio.artist_sel)[0][radio.artist_att]
				client.publish("RadioStream/"+radio.name+"/artist",radio.artist, qos=0, retain=True)
		else:
			if(radio.artist != raw_data.select(radio.artist_sel)[0].text.title()):
				radio.artist = raw_data.select(radio.artist_sel)[0].text.title().strip()
				client.publish("RadioStream/"+radio.name+"/artist",radio.artist, qos=0, retain=True)
	except Exception as e:
		print ("Can't get "+radio.name+" Artist")

	try:
		if (radio.track_att):
			if(radio.track != raw_data.select(radio.track_sel)[0][radio.track_att]):
				radio.track = raw_data.select(radio.track_sel)[0][radio.track_att]
				client.publish("RadioStream/"+radio.name+"/track",radio.track, qos=0, retain=True)
		else:
			if(radio.track != raw_data.select(radio.track_sel)[0].text.title()):
				radio.track = raw_data.select(radio.track_sel)[0].text.title().strip()
				client.publish("RadioStream/"+radio.name+"/track",radio.track, qos=0, retain=True)
	except Exception as e:
		print ("Can't get "+radio.name+" Track")

def bs_get_value_podcast(podcast):
	content = urlopen(podcast.url).read()

	try:
		raw_data = BeautifulSoup(content,"html.parser")
	except Exception as e:
		print("%s Unable to get BS from URL" % e)

	try:
		if (podcast.mp3_att):
			if(podcast.mp3_url != raw_data.select(podcast.mp3_sel)[0][podcast.mp3_att]):
				podcast.mp3_url = raw_data.select(podcast.mp3_sel)[0][podcast.mp3_att]
				client.publish("RadioStream/"+podcast.name+"/mp3_url",podcast.mp3_url, qos=0, retain=True)
		else:
			if(podcast.mp3_url != raw_data.select(podcast.mp3_sel)[0].text.title()):
				podcast.mp3_url = raw_data.select(podcast.mp3_sel)[0].text.title().strip()
				client.publish("RadioStream/"+podcast.name+"/mp3_url",podcast.mp3_url, qos=0, retain=True)
	except Exception as e:
		print ("Can't get "+podcast.name+" MP3 URL")

	try:
		if (podcast.track_att):
			if(podcast.track != raw_data.select(podcast.track_sel)[0][podcast.track_att]):
				podcast.track = raw_data.select(podcast.track_sel)[0][podcast.track_att]
				client.publish("RadioStream/"+podcast.name+"/track",podcast.track, qos=0, retain=True)
		else:
			if(podcast.track != raw_data.select(podcast.track_sel)[0].text.title()):
				podcast.track = raw_data.select(podcast.track_sel)[0].text.title().strip()
				client.publish("RadioStream/"+podcast.name+"/track",podcast.track, qos=0, retain=True)
	except Exception as e:
		print ("Can't get "+podcast.name+" Track")

Refresh_Timer = 0
while(True):

	Thread(target=bs_get_value_radio, args=[RTL2]).start()
	Thread(target=bs_get_value_radio, args=[Absolute_Radio_CR]).start()
	Thread(target=bs_get_value_radio, args=[Absolute_Radio]).start()
	Thread(target=bs_get_value_podcast, args=[IoT_Podcast]).start()
	if(Refresh_Timer == 240):
		Thread(target=bs_get_value_podcast, args=[Hass_Podcast]).start()
		Refresh_Timer = 0
	Thread(target=bs_get_value_radio, args=[Chill]).start()
	time.sleep(15)
	Refresh_Timer = Refresh_Timer + 1

Lovelace Card
  - type: custom:vertical-stack-in-card
    cards:
    - type: picture-glance
      camera_image: camera.chromecast_radio_pic
      entities:
        - entity: input_select.chromecast_radio_station
        - entity: input_text.custom_station
        - entity: input_select.chromecast_radio_speakers
        - entity: switch.chromecast_radio_vol_down
        - entity: switch.chromecast_radio_mute
        - entity: switch.chromecast_radio_vol_up
        - entity: switch.chromecast_radio_stop
        - entity: switch.chromecast_radio_play
    - type: conditional
      conditions:
        - entity: binary_sensor.radio_is_streaming
          state: "on"
      card:
        type: entities
        show_header_toggle: false
        entities:
          - entity: sensor.stream_artist
            name: Artist
            icon: mdi:account
          - entity: sensor.stream_track
            name: Track
            icon: mdi:disc

I think that’s everything…

Hi.
I have a problem with your exemple:

Error running command: `/config/script/stop_radiostream_sensors.sh`, return code: 1
0:00:09 – shell_command (ERROR) - message first occurred at 0:00:05 and shows up 2 times
Log Details (ERROR)
Logger: homeassistant.components.shell_command
Source: /usr/src/homeassistant/homeassistant/components/shell_command/__init__.py:97
Integration: shell_command (documentation, issues)
First occurred: 23:49:58 (2 occurrences)
Last logged: 23:50:03

Error running command: `/config/script/stop_radiostream_sensors.sh`, return code: 1
Error running command: `/config/script/start_radiostream_sensors.sh`, return code: 1
NoneType: None

Could you help me?

I have not mentioned it but you need to make sure the bash scripts are set to be executables
sudo chmod +x [filename]

I already ran this command on the 3 files … But without success.
I tried to run the file HA_Scrape.py by ssh and it gives me the following error:

pi@hassio:/usr/share/hassio/homeassistant/script $ python HA_Scrape.py
Traceback (most recent call last):
  File "HA_Scrape.py", line 4, in <module>
    from bs4 import BeautifulSoup
ImportError: No module named bs4

Bs4 is BeautifulSoup which is used by the Scrape integration, should already be installed…
You need to make sure this runs under ha, not just via ssh as indeed it won’t work as you’re outside the container…

thank you very much for your support! you did a fantastic job. In the end I customized your package that I am attaching … it is a simplified version without being able to view the artist and the track but equally functional …
I just changed the fact that when you press the Stop the boolean input goes directly off and eliminated the Scrap, then as regards the reproduction instead of audio / mp4 I had to put music otherwise some radio stations did not work me. I attach the package if could be of interest to someone else

Package Radio v1.0

#################################################################
#                                                               #
#                           Radio                               #
#                                                               #
#################################################################

homeassistant:
  customize:
    input_number.initial_volume_radio:
      icon: mdi:volume-high
    input_select.chromecast_radio_station:
      icon: mdi:radio
    sensor.radio_selected:
      icon: mdi:radio
    input_select.chromecast_radio_speakers:
      icon: mdi:speaker-wireless
    sensor.speaker_selected:
      icon: mdi:speaker-wireless
    input_text.custom_station:
      icon: mdi:link-variant

#################################################################
sensor:
  - platform: template
    sensors:
      radio_selected:
        value_template: '{{ states.input_select.chromecast_radio_station.state }}'
        friendly_name: 'Stazione selezionata'

  - platform: template
    sensors:
      speaker_selected:
        value_template: '{{ states.input_select.chromecast_radio_speakers.state }}'
        friendly_name: 'Speaker selezionato'


#################################################################
input_number:
  initial_volume_radio:
    name: Volume iniziale
    initial: 0.3
    min: 0
    max: 1
    step: 0.05
    mode: box


#################################################################
input_select:
  chromecast_radio_station:
    name: 'Select Radio Station'
    options:
      - RDS Radio
      - Radio 105
      - Virgin Radio
      - Radio freccia
      - Custom Station
      - Spenta

  chromecast_radio_speakers:
    name: 'Select Speakers'
    options:
      - Salotto
      - Bagno
      - Studio
      - Gruppo Casa


#################################################################
input_text:
  custom_station:
    name: Radio URL


#################################################################
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", "Studio") %} media_player.googlehome5227
            {% elif is_state("input_select.chromecast_radio_speakers", "Gruppo Casa") %} media_player.gruppo_casa_3
            {% elif is_state("input_select.chromecast_radio_speakers", "Bagno") %} media_player.bagno
            {% endif %}
          volume_level: '{{  states("input_number.initial_volume_radio")  }}' 
      - service: media_player.play_media
        data_template:
          entity_id: >
            {% if is_state("input_select.chromecast_radio_speakers", "Studio") %} media_player.googlehome5227
            {% elif is_state("input_select.chromecast_radio_speakers", "Gruppo Casa") %} media_player.gruppo_casa_3
            {% elif is_state("input_select.chromecast_radio_speakers", "Salotto") %} media_player.googlehome3627
            {% elif is_state("input_select.chromecast_radio_speakers", "Bagno") %} media_player.bagno
            {% endif %}
          media_content_id: >
            {% if is_state("input_select.chromecast_radio_station", "RDS Radio") %} https://icstream.rds.radio/rds
            {% elif is_state("input_select.chromecast_radio_station", "Radio 105") %} http://icecast.unitedradio.it/Radio105.mp3
            {% elif is_state("input_select.chromecast_radio_station", "Virgin Radio") %} http://icecast.unitedradio.it/Virgin.mp3
            {% elif is_state("input_select.chromecast_radio_station", "Radio freccia") %} https://streamingv2.shoutcast.com/radiofreccia
            {% elif is_state("input_select.chromecast_radio_station", "Custom Station") %} {{states("input_text.custom_station")}}
            {% endif %}
          media_content_type: music

  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", "Studio") %} media_player.googlehome5227
            {% elif is_state("input_select.chromecast_radio_speakers", "Gruppo Casa") %} media_player.gruppo_casa_3
            {% elif is_state("input_select.chromecast_radio_speakers", "Bagno") %} media_player.bagno
            {% endif %}
      - service: input_select.select_option
        data:
          entity_id: input_select.chromecast_radio_station
          option: Spenta


#################################################################
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 state_attr("media_player.googlehome3627","is_volume_muted") %}on{% else %}off{% endif %}
          {% elif is_state("input_select.chromecast_radio_speakers", "Studio") %} {% if state_attr("media_player.googlehome5227","is_volume_muted") %}on{% else %}off{% endif %}
          {% elif is_state("input_select.chromecast_radio_speakers", "Gruppo Casa") %} {% if state_attr("media_player.gruppo_casa_3","is_volume_muted") %}on{% else %}off{% endif %}
          {% elif is_state("input_select.chromecast_radio_speakers", "Bagno") %} {% if state_attr("media_player.bagno","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", "Studio") %} media_player.googlehome5227
              {% elif is_state("input_select.chromecast_radio_speakers", "Gruppo Casa") %} media_player.gruppo_casa_3
              {% elif is_state("input_select.chromecast_radio_speakers", "Bagno") %} media_player.bagno
              {% 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", "Studio") %} media_player.googlehome5227
              {% elif is_state("input_select.chromecast_radio_speakers", "Gruppo Casa") %} media_player.gruppo_casa_3
              {% elif is_state("input_select.chromecast_radio_speakers", "Bagno") %} media_player.bagno
              {% 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", "Studio") %} media_player.googlehome5227
              {% elif is_state("input_select.chromecast_radio_speakers", "Gruppo Casa") %} media_player.gruppo_casa_3
              {% elif is_state("input_select.chromecast_radio_speakers", "Bagno") %} media_player.bagno
              {% 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", "Studio") %} media_player.googlehome5227
              {% elif is_state("input_select.chromecast_radio_speakers", "Gruppo Casa") %} media_player.gruppo_casa_3
              {% elif is_state("input_select.chromecast_radio_speakers", "Bagno") %} media_player.bagno
              {% 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", "Studio") %} media_player.googlehome5227
              {% elif is_state("input_select.chromecast_radio_speakers", "Gruppo Casa") %} media_player.gruppo_casa_3
              {% elif is_state("input_select.chromecast_radio_speakers", "Bagno") %} media_player.bagno
              {% 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", "Studio") %} media_player.googlehome5227
              {% elif is_state("input_select.chromecast_radio_speakers", "Gruppo Casa") %} media_player.gruppo_casa_3
              {% elif is_state("input_select.chromecast_radio_speakers", "Bagno") %} media_player.bagno
              {% 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

Lovelace UI

cards:
  - entities:
      - entity: input_select.chromecast_radio_station
      - entity: input_text.custom_station
      - entity: input_select.chromecast_radio_speakers
      - entity: switch.chromecast_radio_vol_down
      - entity: switch.chromecast_radio_mute
      - entity: switch.chromecast_radio_vol_up
      - entity: switch.chromecast_radio_stop
      - entity: switch.chromecast_radio_play
    entity: input_select.chromecast_radio_station
    state_image:
      Custom Station: /local/immagini/radio/customstation.jpg
      RDS Radio: /local/immagini/radio/rds.jpg
      Radio 105: /local/immagini/radio/105.jpg
      Radio freccia: /local/immagini/radio/freccia.jpg
      Spenta: /local/immagini/radio/spenta.jpg
      Virgin Radio: /local/immagini/radio/virgin.jpg
    type: picture-glance
  - entities:
      - entity: sensor.radio_selected
      - entity: sensor.speaker_selected
      - entity: input_number.initial_volume_radio
    show_header_toggle: false
    type: entities
type: vertical-stack
2 Likes

the only thing that I couldn’t manage was the custom radio station … when I insert the link like this: http://icecast.unitedradio.it/Virgin.mp3 and I want to try some others but nothing starts. … Can you please check if it works for you? Thanks

1 Like

@lolouk44 Good morning, could you help me with this integration? I don’t understand much and I’m not getting the information about the album and the artist, although on the website that information appears there. Thanks in advance for the help you can give me …

The website is…
https://m.radiocomercial.iol.pt/player/emissaofm

I have tried all the codes shared here but have not been able to. Thank you very much for the help you can give.

Hi @maxcalavera

I moved away from the above code because it kept failing
You really need to find out if your radio provides json data. Scraping is bound to fail as at some stage they will change the interface and your sensor will fail.
I have an updated code if that helps you, check this post:

3 posts above I’ve also shared my lovelace card

Hi, I would like to use this solution. I installed HA on a VM so the install is ‘Home Assistant OS’. Should I be able to get it up and running or is it only for the experts in HA container or HA supervised?

It is not only for the experts in HA container or HA supervisor, so follow the several guides posted in the previous comments and it should help you get started, but depending on your skills and what you want, it may be a bit of a learning curve…

Thanks, will start and build my experience :wink:

help me to scrape this src link on this site, please: Image of the Day

image

Please note this is not related to this thread.
In addition there are various guides on this community on how to scrape data.

Ok, no problem. I just solve that.