Chromecast Radio with station and player selection

Nice!
Thanks for the config, sometimes you’re so stuck in trying to make tricky things work, you overlook the simplest things, which have more impact!

Exactly, that’s why I prefer to try and post two versions of the same file so you can see what has been changed to add a feature. I find it easier to learn that way.

2 Likes

Is this project working also with Sonos Media Players?
I am asking this because i just purchased a couple of Sonos One and after installing and configuring it inside HA and in this project, i tried to play some radios, but unsuccesfully the music doesn’t play on both the Sonos One.
Maybe i am wrong in something?

This should work on every media_player that’s capable of playing streams.
Try to start a working link directly on 1 of the players.

I configured the 2 in one stereo group, so i cannot send a link to only one… but strange is that the speakers do not send any sound…

For some reason, volume slider stopped working for me :frowning: I am using regular configuration which was posted by @wills106

Hi.
Where a I can see the all the media players compatibles?
The Alexa and Google Home are compatible?

Thanks in advance!

Like stated before, all media_players which are capable of playing streams should be compatible. You can simply try by sending a working stream to the player with a script for instance:

  radio_test:
    sequence:
      - service: media_player.play_media
        data_template:
           entity_id: media.player.<YOUR_MEDIA_PLAYER>
           media_content_id: http://playerservices.streamtheworld.com/api/livestream-redirect/RADIO538.mp3
           media_content_type: 'audio/mp4'

Hello

It is possible to stream url like this:

http://chi-kat-02.cdn.eurozet.pl:8902

?

No, you have to find a direct link to the stream. Something to keep in mind: if the link instantly starts playing from a browser without having to press a play buitton or other link, then it will work.

I found link http://78.46.246.97:9000/; working instant in browsery and vlc but via hs and google mini start play after ~ 10s :confused:

I edited the script so i can cast to my google home.
But when i push the play button it takes up to 5-10 minutes before the radio starts playing?
Anyone also has this problem?

I was going through this and I will test at home, but I managed to find something to extract urls for almost any stream online. Tunein etc. thanks to reddit user paulanerspezi

I’ve tested and found every station I needed within seconds.

  1. Open page in Chrome
    
  2. Open developer tools using F12
    
  3. Switch to "Network" section, filter by "media"
    
  4. Reload page
    
  5. Stream URL should show up being loaded in developer tools
    
  6. Copy URL
    

Step 7: I tested by just loading each link in a browser. Working

2 Likes

Romanian stations:

    media_content_id: >
     {% if is_state("input_select.radio_station", "Magic FM") %} http://live.magicfm.ro:9128/magicfm.aacp
     {% elif is_state("input_select.radio_station", "Guerilla") %} http://live.guerrillaradio.ro:8010/guerrilla.aac
     {% elif is_state("input_select.radio_station", "Europa FM") %} http://astreaming.europafm.ro:8000/europafm_aacp48k.m3u
     {% elif is_state("input_select.radio_station", "Rock FM") %} http://80.86.106.143:9128/rockfm.mp3
     {% elif is_state("input_select.radio_station", "Digi FM") %} http://edge76.rdsnet.ro:84/digifm/digifm.mp3
     {% elif is_state("input_select.radio_station", "Romantic FM") %} http://5.254.113.34:9123/romanticfm.aacp
     {% elif is_state("input_select.radio_station", "Radio Clasic") %} http://37.251.146.169:8000/stream
     {% elif is_state("input_select.radio_station", "Clasic Beethoven") %} http://37.251.146.169:7100/stream
     {% elif is_state("input_select.radio_station", "Clasic Blue Jazz") %} http://37.251.146.169:8048/stream
     {% elif is_state("input_select.radio_station", "Clasic Hits") %} http://37.251.146.169:7000/stream
     {% elif is_state("input_select.radio_station", "Clasic Jazz") %} http://37.251.146.169:7800/stream
     {% elif is_state("input_select.radio_station", "Clasic Love") %} http://37.251.146.169:8044/stream
     {% elif is_state("input_select.radio_station", "Red Radio") %} http://37.251.146.169:8012/stream
     {% elif is_state("input_select.radio_station", "Clasic Rock") %} http://37.251.146.169:7100/stream
     {% elif is_state("input_select.radio_station", "Clasic Relax") %} http://37.251.146.169:8020/stream
     {% endif %}
    media_content_type: 'audio/mp4'
1 Like

I have a delay starting some streams, yet others (luckily my favourite) loads / plays instantly. I don’t know what / where the issue is

Same. I don’t remember it being like this months ago.

I have the same with 1 particular stream. It delays for about 30 seconds before starting. I guess it could have something to do with buffer settings on the server (?)

For whom it may concern I have updated the list of dutch radio stations in my config.

1 Like

Here is a bunch of swedish stations:

  media_content_id: >
    {% if is_state("input_select.radio_station", "Kiss FM") %} http://andromeda.shoutca.st:8396/;stream.mp3
    {% elif is_state("input_select.radio_station", "Europa FM") %} http://astreaming.europafm.ro:8000/europafm_aacp48k.m3u
    {% elif is_state("input_select.radio_station", "Rock FM") %} http://80.86.106.143:9128/rockfm.mp3
    {% elif is_state("input_select.radio_station", "Digi FM") %} http://edge76.rdsnet.ro:84/digifm/digifm.mp3
    {% elif is_state("input_select.radio_station", "Romantic FM") %} http://5.254.113.34:9123/romanticfm.aacp
    {% elif is_state("input_select.radio_station", "Radio Clasic") %} http://37.251.146.169:8000/stream
    {% elif is_state("input_select.radio_station", "P1") %} https://sverigesradio.se/topsy/direkt/132-hi-mp3
    {% elif is_state("input_select.radio_station", "P2") %} https://sverigesradio.se/topsy/direkt/2562-hi-mp3
    {% elif is_state("input_select.radio_station", "P3") %} https://sverigesradio.se/topsy/direkt/164-hi-mp3
    {% elif is_state("input_select.radio_station", "P4") %} https://sverigesradio.se/topsy/direkt/212-hi-mp3
    {% elif is_state("input_select.radio_station", "Ekot") %} https://sverigesradio.se/topsy/direkt/4540-hi-mp3
    {% elif is_state("input_select.radio_station", "RIX FM") %} http://fm01-icecast.mtg-r.net/fm01_aac
    {% elif is_state("input_select.radio_station", "Bandit Rock") %} http://fm02-icecast.mtg-r.net/fm02_aac
    {% elif is_state("input_select.radio_station", "Lugna Favoriter") %} http://fm03-icecast.mtg-r.net/fm03_aac
    {% elif is_state("input_select.radio_station", "STAR FM") %} http://fm05-icecast.mtg-r.net/fm05_aac
    {% elif is_state("input_select.radio_station", "Power Hit Radio") %} http://fm04-icecast.mtg-r.net/fm04_aac
    {% elif is_state("input_select.radio_station", "Bandit Ballads") %} http://wr21-ice.stream.mtgr.se/wr21_aac
    {% elif is_state("input_select.radio_station", "Bandit Classics") %} http://wr11-icecast.mtg-r.net/wr11_aac
    {% elif is_state("input_select.radio_station", "Bandit Metal") %} http://wr03-icecast.mtg-r.net/wr03_aac
    {% elif is_state("input_select.radio_station", "RIX FM FRESH") %} http://wr04-icecast.mtg-r.net/wr04_aac
    {% elif is_state("input_select.radio_station", "Power Club") %} http://wr06-icecast.mtg-r.net/wr06_aac
    {% elif is_state("input_select.radio_station", "Power Street") %} http://wr07-icecast.mtg-r.net/wr07_aac
    {% elif is_state("input_select.radio_station", "Indie 101") %} http://wr05-icecast.mtg-r.net/wr05_aac
    {% elif is_state("input_select.radio_station", "Svenska Favoriter") %} http://wr13-icecast.mtg-r.net/wr13_aac
    {% elif is_state("input_select.radio_station", "Dansbandsfavoriter") %} http://wr15-icecast.mtg-r.net/wr15_aac
    {% elif is_state("input_select.radio_station", "Country Classics") %} http://wr14-icecast.mtg-r.net/wr14_aac
    {% elif is_state("input_select.radio_station", "Star 90s") %} http://wr12-icecast.mtg-r.net/wr12_aac
    {% elif is_state("input_select.radio_station", "Star 80s") %} http://wr02-icecast.mtg-r.net/wr02_aac
    {% elif is_state("input_select.radio_station", "Star 70s") %} http://wr10-icecast.mtg-r.net/wr10_aac
    {% elif is_state("input_select.radio_station", "Star 60s") %} http://wr09-icecast.mtg-r.net/wr09_aac
    {% elif is_state("input_select.radio_station", "Electro Lounge") %} http://wr16-icecast.mtg-r.net/wr16_aac
    {% elif is_state("input_select.radio_station", "Soul Classics") %} http://wr08-icecast.mtg-r.net/wr08_aac
    {% elif is_state("input_select.radio_station", "One Hit Wonders") %} http://wr18-icecast.mtg-r.net/wr18_aac
    {% endif %}
2 Likes

I was too lazy to change the script name :smiley:

script:
    radio538:
        sequence:
          - service: media_player.turn_on
            data_template:
              entity_id: >
                {% if is_state("input_select.chromecast_radio", "Soundbar") %} media_player.chromecastaudio1108
                {% elif is_state("input_select.chromecast_radio", "Stereo") %} media_player.chromecast_audio
                {% elif is_state("input_select.chromecast_radio", "Kitchen") %} media_player.kitchen
                {% elif is_state("input_select.chromecast_radio", "Bedroom") %}media_player.bedroom
                {% elif is_state("input_select.chromecast_radio", "Main speaker") %} media_player.living_room_speaker
                {% elif is_state("input_select.chromecast_radio", "Guest room") %} media_player.jbllink104191
                {% elif is_state("input_select.chromecast_radio", "Hallway") %} media_player.hallway
                {% endif %}
          - service: media_player.volume_set
            data_template:
              entity_id: >
                {% if is_state("input_select.chromecast_radio", "Soundbar") %} media_player.chromecastaudio1108
                {% elif is_state("input_select.chromecast_radio", "Stereo") %} media_player.chromecast_audio
                {% elif is_state("input_select.chromecast_radio", "Kitchen") %} media_player.kitchen
                {% elif is_state("input_select.chromecast_radio", "Bedroom") %}media_player.bedroom
                {% elif is_state("input_select.chromecast_radio", "Main speaker") %} media_player.living_room_speaker
                {% elif is_state("input_select.chromecast_radio", "Guest room") %} media_player.jbllink104191
                {% elif is_state("input_select.chromecast_radio", "Hallway") %} media_player.hallway
                {% endif %}
              volume_level: '{{  states.input_number.radio_volume.state }}'
          - service: media_player.play_media
            data_template:
              entity_id: >
                {% if is_state("input_select.chromecast_radio", "Soundbar") %} media_player.chromecastaudio1108
                {% elif is_state("input_select.chromecast_radio", "Stereo") %} media_player.chromecast_audio
                {% elif is_state("input_select.chromecast_radio", "Kitchen") %} media_player.kitchen
                {% elif is_state("input_select.chromecast_radio", "Bedroom") %}media_player.bedroom
                {% elif is_state("input_select.chromecast_radio", "Main speaker") %} media_player.living_room_speaker
                {% elif is_state("input_select.chromecast_radio", "Guest room") %} media_player.jbllink104191
                {% elif is_state("input_select.chromecast_radio", "Hallway") %} media_player.hallway
                {% endif %}
              media_content_id: >
                {% if is_state("input_select.radio_station", "Kiss FM") %} http://andromeda.shoutca.st:8396/;stream.mp3
                {% elif is_state("input_select.radio_station", "Europa FM") %} http://astreaming.europafm.ro:8000/europafm_aacp48k.m3u
                {% elif is_state("input_select.radio_station", "Rock FM") %} http://80.86.106.143:9128/rockfm.mp3
                {% elif is_state("input_select.radio_station", "Digi FM") %} http://edge76.rdsnet.ro:84/digifm/digifm.mp3
                {% elif is_state("input_select.radio_station", "Romantic FM") %} http://5.254.113.34:9123/romanticfm.aacp
                {% elif is_state("input_select.radio_station", "Radio Clasic") %} http://37.251.146.169:8000/stream
                {% elif is_state("input_select.radio_station", "P1") %} https://sverigesradio.se/topsy/direkt/132-hi-mp3
                {% elif is_state("input_select.radio_station", "P2") %} https://sverigesradio.se/topsy/direkt/2562-hi-mp3
                {% elif is_state("input_select.radio_station", "P3") %} https://sverigesradio.se/topsy/direkt/164-hi-mp3
                {% elif is_state("input_select.radio_station", "P4") %} https://sverigesradio.se/topsy/direkt/212-hi-mp3
                {% elif is_state("input_select.radio_station", "Ekot") %} https://sverigesradio.se/topsy/direkt/4540-hi-mp3
                {% elif is_state("input_select.radio_station", "RIX FM") %} http://fm01-icecast.mtg-r.net/fm01_aac
                {% elif is_state("input_select.radio_station", "Bandit Rock") %} http://fm02-icecast.mtg-r.net/fm02_aac
                {% elif is_state("input_select.radio_station", "Lugna Favoriter") %} http://fm03-icecast.mtg-r.net/fm03_aac
                {% elif is_state("input_select.radio_station", "STAR FM") %} http://fm05-icecast.mtg-r.net/fm05_aac
                {% elif is_state("input_select.radio_station", "Power Hit Radio") %} http://fm04-icecast.mtg-r.net/fm04_aac
                {% elif is_state("input_select.radio_station", "Bandit Ballads") %} http://wr21-ice.stream.mtgr.se/wr21_aac
                {% elif is_state("input_select.radio_station", "Bandit Classics") %} http://wr11-icecast.mtg-r.net/wr11_aac
                {% elif is_state("input_select.radio_station", "Bandit Metal") %} http://wr03-icecast.mtg-r.net/wr03_aac
                {% elif is_state("input_select.radio_station", "RIX FM FRESH") %} http://wr04-icecast.mtg-r.net/wr04_aac
                {% elif is_state("input_select.radio_station", "Power Club") %} http://wr06-icecast.mtg-r.net/wr06_aac
                {% elif is_state("input_select.radio_station", "Power Street") %} http://wr07-icecast.mtg-r.net/wr07_aac
                {% elif is_state("input_select.radio_station", "Indie 101") %} http://wr05-icecast.mtg-r.net/wr05_aac
                {% elif is_state("input_select.radio_station", "Svenska Favoriter") %} http://wr13-icecast.mtg-r.net/wr13_aac
                {% elif is_state("input_select.radio_station", "Dansbandsfavoriter") %} http://wr15-icecast.mtg-r.net/wr15_aac
                {% elif is_state("input_select.radio_station", "Country Classics") %} http://wr14-icecast.mtg-r.net/wr14_aac
                {% elif is_state("input_select.radio_station", "Star 90s") %} http://wr12-icecast.mtg-r.net/wr12_aac
                {% elif is_state("input_select.radio_station", "Star 80s") %} http://wr02-icecast.mtg-r.net/wr02_aac
                {% elif is_state("input_select.radio_station", "Star 70s") %} http://wr10-icecast.mtg-r.net/wr10_aac
                {% elif is_state("input_select.radio_station", "Star 60s") %} http://wr09-icecast.mtg-r.net/wr09_aac
                {% elif is_state("input_select.radio_station", "Electro Lounge") %} http://wr16-icecast.mtg-r.net/wr16_aac
                {% elif is_state("input_select.radio_station", "Soul Classics") %} http://wr08-icecast.mtg-r.net/wr08_aac
                {% elif is_state("input_select.radio_station", "One Hit Wonders") %} http://wr18-icecast.mtg-r.net/wr18_aac
                {% endif %}
              media_content_type: 'audio/mp4' 

Automation to select new stream.

automation:
    - alias: Radio
      initial_state: 'on'
      hide_entity: true
      trigger:
        platform: state
        entity_id: input_select.radio_station
      action:
      - service: media_player.play_media
        data_template:
          entity_id: >
            {% if is_state("input_select.chromecast_radio", "Soundbar") %} media_player.chromecastaudio1108
            {% elif is_state("input_select.chromecast_radio", "Stereo") %} media_player.chromecast_audio
            {% elif is_state("input_select.chromecast_radio", "Kitchen") %} media_player.kitchen
            {% elif is_state("input_select.chromecast_radio", "Bedroom") %}media_player.bedroom
            {% elif is_state("input_select.chromecast_radio", "Main speaker") %} media_player.living_room_speaker
            {% elif is_state("input_select.chromecast_radio", "Guest room") %} media_player.jbllink104191
            {% elif is_state("input_select.chromecast_radio", "Hallway") %} media_player.hallway
            {% endif %}
          media_content_id: >
            {% if is_state("input_select.radio_station", "Kiss FM") %} http://andromeda.shoutca.st:8396/;stream.mp3
            {% elif is_state("input_select.radio_station", "Europa FM") %} http://astreaming.europafm.ro:8000/europafm_aacp48k.m3u
            {% elif is_state("input_select.radio_station", "Rock FM") %} http://80.86.106.143:9128/rockfm.mp3
            {% elif is_state("input_select.radio_station", "Digi FM") %} http://edge76.rdsnet.ro:84/digifm/digifm.mp3
            {% elif is_state("input_select.radio_station", "Romantic FM") %} http://5.254.113.34:9123/romanticfm.aacp
            {% elif is_state("input_select.radio_station", "Radio Clasic") %} http://37.251.146.169:8000/stream
            {% elif is_state("input_select.radio_station", "P1") %} https://sverigesradio.se/topsy/direkt/132-hi-mp3
            {% elif is_state("input_select.radio_station", "P2") %} https://sverigesradio.se/topsy/direkt/2562-hi-mp3
            {% elif is_state("input_select.radio_station", "P3") %} https://sverigesradio.se/topsy/direkt/164-hi-mp3
            {% elif is_state("input_select.radio_station", "P4") %} https://sverigesradio.se/topsy/direkt/212-hi-mp3
            {% elif is_state("input_select.radio_station", "Ekot") %} https://sverigesradio.se/topsy/direkt/4540-hi-mp3
            {% elif is_state("input_select.radio_station", "RIX FM") %} http://fm01-icecast.mtg-r.net/fm01_aac
            {% elif is_state("input_select.radio_station", "Bandit Rock") %} http://fm02-icecast.mtg-r.net/fm02_aac
            {% elif is_state("input_select.radio_station", "Lugna Favoriter") %} http://fm03-icecast.mtg-r.net/fm03_aac
            {% elif is_state("input_select.radio_station", "STAR FM") %} http://fm05-icecast.mtg-r.net/fm05_aac
            {% elif is_state("input_select.radio_station", "Power Hit Radio") %} http://fm04-icecast.mtg-r.net/fm04_aac
            {% elif is_state("input_select.radio_station", "Bandit Ballads") %} http://wr21-ice.stream.mtgr.se/wr21_aac
            {% elif is_state("input_select.radio_station", "Bandit Classics") %} http://wr11-icecast.mtg-r.net/wr11_aac
            {% elif is_state("input_select.radio_station", "Bandit Metal") %} http://wr03-icecast.mtg-r.net/wr03_aac
            {% elif is_state("input_select.radio_station", "RIX FM FRESH") %} http://wr04-icecast.mtg-r.net/wr04_aac
            {% elif is_state("input_select.radio_station", "Power Club") %} http://wr06-icecast.mtg-r.net/wr06_aac
            {% elif is_state("input_select.radio_station", "Power Street") %} http://wr07-icecast.mtg-r.net/wr07_aac
            {% elif is_state("input_select.radio_station", "Indie 101") %} http://wr05-icecast.mtg-r.net/wr05_aac
            {% elif is_state("input_select.radio_station", "Svenska Favoriter") %} http://wr13-icecast.mtg-r.net/wr13_aac
            {% elif is_state("input_select.radio_station", "Dansbandsfavoriter") %} http://wr15-icecast.mtg-r.net/wr15_aac
            {% elif is_state("input_select.radio_station", "Country Classics") %} http://wr14-icecast.mtg-r.net/wr14_aac
            {% elif is_state("input_select.radio_station", "Star 90s") %} http://wr12-icecast.mtg-r.net/wr12_aac
            {% elif is_state("input_select.radio_station", "Star 80s") %} http://wr02-icecast.mtg-r.net/wr02_aac
            {% elif is_state("input_select.radio_station", "Star 70s") %} http://wr10-icecast.mtg-r.net/wr10_aac
            {% elif is_state("input_select.radio_station", "Star 60s") %} http://wr09-icecast.mtg-r.net/wr09_aac
            {% elif is_state("input_select.radio_station", "Electro Lounge") %} http://wr16-icecast.mtg-r.net/wr16_aac
            {% elif is_state("input_select.radio_station", "Soul Classics") %} http://wr08-icecast.mtg-r.net/wr08_aac
            {% elif is_state("input_select.radio_station", "One Hit Wonders") %} http://wr18-icecast.mtg-r.net/wr18_aac
            {% endif %}

Select of Chromecast or Google Home Mini.

input_select:
  chromecast_radio:
    name: 'Speaker'
    icon: fas:volume-up
    options:
     - 'Soundbar'
     - 'Stereo'
     - 'Kitchen'
     - 'Bedroom'
     - 'Hallway'
     - 'Guest room'
     - 'Main speaker'
    initial: 'Main speaker'

Select of radio station

input_select:
  radio_station:
    name: 'Radio'
    icon: mdi:radio
    options:
     - 'Kiss FM'
     - 'Europa FM'
     - 'Rock FM'
     - 'Digi FM'
     - 'Romantic FM'
     - 'Radio Clasic'
     - 'P1'
     - 'P2'
     - 'P3'
     - 'P4'
     - 'Ekot'
     - 'RIX FM'
     - 'Bandit Rock'
     - 'Lugna Favoriter'
     - 'STAR FM'
     - 'Power Hit Radio'
     - 'Bandit Ballads'
     - 'Bandit Classics'
     - 'Bandit Metal'
     - 'RIX FM FRESH'
     - 'Power Club'
     - 'Power Street'
     - 'Indie 101'
     - 'Svenska Favoriter'
     - 'Dansbandsfavoriter'
     - 'Country Classics'
     - 'Star 90s'
     - 'Star 80s'
     - 'Star 70s'
     - 'Star 60s'
     - 'Electro Lounge'
     - 'Soul Classics'
     - 'One Hit Wonders'
    initial: 'P3'

Volume.
input_number:

#radio volume   
radio_volume:
        name: Volume
        icon: mdi:volume-high
        initial: '0.2'
        min: '0'
        max: '1'
        step: '0.05'
2 Likes