Chromecast Radio with station and player selection

thank you very much everything works! maybe one more question do I create a folder www/images in my config folder of home assistant?

Yep, exactly

Hi Bob,

Followed all your steps. My soundbar turns on when I press ‘Activate’ and I even managed to set the volume to a certain level. Unfortunately the soundbar doesn’t connect to the radio link I wrote in my script.

It’s a Samsung soundbar which works with Smartthing, it doesn’t work with a chromecast so I’m afraid that might be the problem.

Do you have any solutions?

very nice! thank you for this

  Hello all, i succeded making it work, the radio plays my favorite radio stations on my google home mini, but not on the alexa and not on my phone or tablet. I would like to be able to play the radio on the device that i open home assistant. Can this be achieved? Thank you Bob for your awesome work with this component.

I don’t use Amazon devices but I have seen threads talking about the difficulty in using them as media players from HA. You are best to search one of those threads.

As for playing the stream on the local device, the only way I know to do that is via the Media Browser menu, which isn’t something that is linked to this thread/ player config. You can however set something up which is similar which allows playback on the local device.

Hello Veto,

I have the script working perfectly without the addition for Sonos…

I edited the names from Living room to Sonos Living Room

I also added the extra % if sonos lines.

But it aint doing nothing for sonos…

Any hints?

thanks in advance!

K.

Hi everyone,

I was wondering if there is anyone working toward a HACKS component to get the all installed in a easy way?
I’m new to HASS and have no idea where to start in a tread that is 4 years long …
Hope any one can give me some good news :slight_smile:
Anyhow keep up the fantastic work!

This isn’t a component / integration so it will never be in HACS. It is simply a bunch of input_selects, automations etc to achieve a goal. It’s just regular HA coded YAML.

I posted a full working package further up the thread which works perfectly.

Thx @sparkydave I will have a look at it!

I have issue’s with radio stations to chromecast devices.
Created Scripts.yaml

radio_play:
  alias: Play Radio
  icon: mdi:play
  mode: restart
  sequence:
  - service: media_player.volume_set
    data:
      entity_id: >
        {% if is_state("input_select.radio_speaker", "Google nex hub") %} media_player.google_nex_hub
        {% elif is_state("input_select.radio_speaker", "Google assistant Nikki") %} media_player.slaapkamer_nikki
        {% endif %}
      volume_level: '{{ states("input_number.radio_volume.state") }}'
  - service: media_player.play_media
    data:
      entity_id: >
        {% if is_state("input_select.radio_speaker", "Google nex hub") %} media_player.google_nex_hub
        {% elif is_state("input_select.radio_speaker", "Google assistant Nikki") %} media_player.slaapkamer_nikki
        {% endif %}
      media_content_id: >
        {% if is_state(input_select.radio_station", "Bruut") %} http://icecast.vrtcdn.be/stubru_bruut-high.mp3
        {% elif is_state(input_select.radio_station", "Tijdloze") %} http://icecast.vrtcdn.be/stubru_tijdloze-high.mp3
        {% endif %}
      media_content_type: 'music'

Input_number.yaml

#radio volume
radio_volume:
  name: Volume
  icon: mdi:volume-high
  initial: 0.3
  min: 0
  max: 1
  step: 0.05
  mode: box

Input_select.yaml

#radio stations
radio_station:
    name: 'Select Radio Station:'
    options:
      - Bruut
      - Tijdloze
    initial: Bruut
    icon: mdi:radio
radio_speaker:
    name: 'Select Speaker:'
    options:
    - Google nex hub
    - Google assistant Nikki
    initial: Google nex hub
    icon: mdi:speaker-wireless

But in the log file I see a error on the scripts.yaml
“Invalid config for [script]: template value should be a string for dictionary value @ data[‘sequence’][1][‘data’]. Got None. (See /config/configuration.yaml, line 6).”

Anyone any idea?

Use data_template: instead of data: in your script.

It was a space issue. it was volume_level: ‘{{spacestates(“input_number.radio_volume.state”) }}’
But it should have been: volume_level: ‘{{space space states(“input_number.radio_volume.state”) }}’

That should make no difference. I have several templates running with double spaces (because I find it easier on the eye :)).

Hello m sorry but where is the package for download?

Here.

Just change the URL’s for the radio stations and entities for the media players that you have accordingly.

I run the radio by automation triggered by motion sensor. Is there anyway to start random radio from the list but not selected one?

1 Like

Yes, configure like this:

      media_content_id: 
        '{{ ["http://playerservices.streamtheworld.com/api/livestream-redirect/RADIO538.mp3",
               "http://icecast-qmusic.cdp.triple-it.nl/Qmusic_nl_live_96.mp3", 
               "http://91.221.151.155/listen.mp3",
               "http://icecast.omroep.nl/3fm-bb-mp3",
               "http://stream.100p.nl/100pctnl.mp3",
               "http://8543.live.streamtheworld.com/VERONICACMP3",
               "http://8623.live.streamtheworld.com:80/SKYRADIOAAC_SC",
               "http://19143.live.streamtheworld.com/CLASSICFM_SC",
               "http://icecast-bnr.cdp.triple-it.nl/bnr_mp3_96_03",
               "http://listen.shoutcast.com/prysmradio09-mp3",            
               "http://air.chillout.zone:8000/radio",           
               "http://stream.radiocorp.nl/web11_mp3",
               "http://us3.internet-radio.com:8007/listen.mp3",
               "http://listen.shoutcast.com/Classic-RockFlorida"] | random}}'
1 Like

This is exactly what i would love to do… are you able to share details of what you did?

Hi everyone,
how can i replace media_content_id with the following.
service: squeezebox.call_method

I’ve tried it, but it doesn’t work quite right.
Maybe you can help me.
Thank you.

service: squeezebox.call_method
data_template:
  entity_id: media_player.{{states.input_select.chromecast_radio_speakers.state}}
  command: favorites
  parameters: >
    {% if is_state('input_select.chromecast_radio_station', 'ProFM') %}
      ["playlist", "play", "item_id:0"]
    {% elif is_state('input_select.chromecast_radio_station', 'KissFM') %}
      ["playlist", "play", "item_id:1"]
    {% elif is_state('input_select.chromecast_radio_station', 'EuropaFM') %}
      ["playlist", "play", "item_id:2"]
    {% elif is_state('input_select.chromecast_radio_station', 'RadioZu') %}
      ["playlist", "play", "item_id:3"]
    {% elif is_state('input_select.chromecast_radio_station', 'DigiFM') %}
      ["playlist", "play", "item_id:4"]
    {% elif is_state('input_select.chromecast_radio_station', 'MagicFM') %}
      ["playlist", "play", "item_id:5"]
    {% elif is_state('input_select.chromecast_radio_station', 'VirginRadio') %}
      ["playlist", "play", "item_id:6"]
    {% elif is_state('input_select.chromecast_radio_station', 'Popular') %}
      ["playlist", "play", "item_id:7"]
    {% elif is_state('input_select.chromecast_radio_station', 'WefunkRadio') %}
      ["playlist", "play", "item_id:8"]
    {% elif is_state('input_select.chromecast_radio_station', 'FunkRadio') %}
      ["playlist", "play", "item_id:9"]
    {% endif %}