Chromecast Radio with station and player selection

There are allready included (at least some of them). Just make sure they are connected to the same network. They should show up as media_players. To force discovery add this to your configuration.yaml:

  - platform: cast

I cannot find the error in this automation.
There is a slight error somewhere, but HA do not find any errors in the code.

  - alias: "Media: Vad ska spelas i köket"
      platform: state
      entity_id: input_select.chromecast_audio_kitchen
      service: media_player.play_media
        media_content_id: >
          {% if is_state("input_select.chromecast_audio_kitchen", "Sveriges Radio P1") %} 
          {% elif is_state("input_select.chromecast_audio_kitchen", "Sveriges Radio P2") %} 
          {% elif is_state("input_select.chromecast_audio_kitchen", "Sveriges Radio P3") %} 
          {% elif is_state("input_select.chromecast_audio_kitchen", "Sveriges Radio P4 Stockholm") %} 
          {% elif is_state("input_select.chromecast_audio_kitchen", "Sveriges Radio P4 PLUS") %} 
          {% elif is_state("input_select.chromecast_audio_kitchen", "Sveriges Radio Ekot direkt") %} 
          {% endif %}
        media_content_type: 'audio/mp4'

Here’s the corresponding input selector

    name: Vad ska spelas i köket
     - Tyst
     - Sveriges Radio P1
     - Sveriges Radio P2
     - Sveriges Radio P3
     - Sveriges Radio P4 Stockholm
     - Sveriges Radio P4 PLUS
     - Sveriges Radio Ekot direkt
    initial: Tyst
    icon: mdi:radio

When I change the input selector, nothing is streaming to my chromecast.
The device is working since I can cast to it from my phone.

Thanks for the list of Swedish radio stations. We live in the US and my Swedish wife will appreciate them!

1 Like

Happy to hear that @johnnyletrois.
More channels can be found here (in swedish, but she will understand):

Back to my problem, I did not specify the entity_id of the input_select. My bad.

You did not specify the entity_id of the player:

service: media_player.play_media
  entity_id: media_player.XXX
  media_content_id: >
1 Like

Great idea! I’ve implemented something similar for my multi-room audio setup. The way to do it without a bunch of if-else conditions is as follows:

service: media_player.play_media
  entity_id: media_player.casatunes
  media_content_id: "{{ {
    'Illinois Street Lounge' : '',
    'Secret Agent' : '',
    'Groove Salad' : '',
    'Sonic Universe' : '',
    'Left Coast 70s' : '',
    'Underground 80s' : '',
    'Beat Blender': '',
    'DEF CON Radio' : ''
  }[states('input_select.radio_station')] }}"
  media_content_type: "audio/mp4"

I haven’t listened to this station for years, thank you for reminding me of it, I’ll add it to my playlist too :+1:

1 Like

I did something similar but a little different as I didn’t like that you can neither set title nor image via the HA Google Cast component.


Will you share the code for this? I really am interested and i like it…

This looks great, would you mind sharing the code?

Hi. I found this web site with thousands url links to radio stations cataloged per country. Enjoy


Has anybody used this successfully? media_player.media_seek to seek through an mp3? Ideally I would have an input_number as a slider. I wasn’t able to seek successfully.

- service: media_player.media_seek
     entity_id: media_player.office_speaker
     seek_position: 50

Me three please!!! And what do the buttons do exactly?

@lkhdas I’m also interested in how you’ve got the media title, image, volume level, and controls all in one interface. Can you please share what you’re using to do this?

EDIT: I think I’ve found it. I assume this is it? Custom UI: Mini media player

Yes that’s it

cast = pychromecast.Chromecast(HOST, timeout=5, tries=2)
media_controller = cast.media_controller
media_controller.play_media(MEDIA, 'audio/mp3', title=TITLE, thumb=IMAGE, stream_type='LIVE')

This is the code to have media title and image for Chromecast

Thanks for sharing. Sorry for what may be a silly question but…where does this code go? Any additional details you can provide would be much appreciated.

I use it in appdaemon but it’d probably be easier to use it as python_script. Either way you will need to adjust it to your scenario.

Bob, although this feature is very popular me personally your script gave me lot of headache and it still does. Latest problem : Platform cast not ready yet. Retrying in 30 seconds and the music indeed start in 30 seconds
I am close to quitting this even if i invested a lot of time and money

I’m just wondering, on my version the script doesn’t appear the the same “block” as the other radio controls. It still works just sends my ocd into a spin…?

check your group setup