Chromecast Radio with station and player selection

Just remember this only works with Chromecast Audios and Google Homes. You can’t group AndroidTVs, Chromecast Video devices or embedded Chromecasts. Though the news is that the embedded support should be rolling out over 2017 so at least that will resolve one problem.

Exactly, you can create a group in Hass with other players by adding them manually but then they will not play in sync.

I don’t understand, please clarify :slight_smile:

Ah, I always forget I’m on an international forum here! The phrase Bob’s your uncle basically means “it’s as easy as that” and is very common usage in the UK such that the two phrases are completely interchangeable.

So I did a play on words with your name as a compliment to how easy you have made this for everyone, and to thank you for your efforts.

Link explaining the phrase: https://en.m.wikipedia.org/wiki/Bob's_your_uncle

:slight_smile:

1 Like

Blinding explanation; I’m proper chuffed. You obviously know your onions.

1 Like

:smile: :smile: :smile:

In my defence, everybody’s English is so good here I forget that people won’t pick up on the idioms :stuck_out_tongue_closed_eyes:

Anyway, it was meant to be a compliment, @Bob_NL :grinning:

1 Like

To be fair, bob’s your uncle is a fairly well established UK idiom. If you have seen any DIY type program from the UK, you’d have to hear it at least once. But I love learning new idioms from other languages here… some of them can be quite funny.

And +1 on compliments to @Bob_NL - I use my radio a couple of times a week at least. I love it for nature sounds when I am taking a shower.

2 Likes

haha, ok thanks. Never heard that, I’ll remember now :wink:

2 Likes

Thanks Bob for making this. Is there a way to announce what station is going to be played? With local mp3 file or maybe with tts. I use xiaomi cube as remote control for input select and it would be nice if i know what station is going to be played.

2 Likes

@vladosam great idea. I’ll implement this next weekend ok?

1 Like

Sure.I think it would be nice addition to already great radio. Thanks.

For anyone that’s interested in iHeart Radio streams, I ran across these when looking for my local talk station. I’ve tried a couple and they seem to work fine.

https://pastebin.com/YYamKGgr
http://forums.slimdevices.com/showthread.php?90677-playing-iheartradio-individual-stations

3 Likes

For stop I added this as a script:

stop_playback:
  alias: Stop stream
  sequence:
    - service: media_player.media_stop
      data_template:
        entity_id: >
         {% if is_state("input_select.chromecast_radio", "Bedroom") %} media_player.castbedroom
         {% elif is_state("input_select.chromecast_radio", "Kitchen") %} media_player.castkitchen
         {% elif is_state("input_select.chromecast_radio", "Everywhere") %} media_player.flat
         {% endif %}

@Bob_NL it works really nice, except that I always need a few tries (click activate 3 times) to start streaming. In the states tab instead of “playing” the state is idle. Do you know what’s the problem there?

edit:
I tried it out a little more. It seems as if I’ve to change the station first. If I freshly started HA and just clicked on play, it goes into idle mode. If I choose another station, it plays the stream without problems

edit2:
So it seems as if we got a router update and some requests get blocked. Thus I guess it’s a router problem currently, not with the setup.

For people interested in adding tunein listed radius, there is quite an easy way to extract the url of tunein radio station decribed here.

Or if you’re using firefox, just start the station, pause it, at the bottom banner (where you control play / pause) rightclick and select “Sho siteinformation”, change to the media tab, then in the list there should be one item of type audio, that’s your stream.

I think I read this mozilla-guide somewhere here in the forum, but can’t find it anymore

1 Like

There is no way we could add Spotify playlists as a stream option right?

Any progress on radio announcement? :smiley:

Nope, sorry I’ve been very busy. I can make a simple TTS addition if you like. Hang on.

@vladosam try this:

  radio538:
    alias: Play Radio on Chromecast Audio
    sequence:
      - service: media_player.volume_set
        data_template:
          entity_id: >
            {% if is_state("input_select.chromecast_radio", "Livingroom") %} media_player.ca_livingroom
            {% elif is_state("input_select.chromecast_radio", "Hall") %} media_player.ca_hall
            {% elif is_state("input_select.chromecast_radio", "Bedroom") %} media_player.bed_room
            {% elif is_state("input_select.chromecast_radio", "Bathroom") %} media_player.ca_bathroom
            {% elif is_state("input_select.chromecast_radio", "Everywhere") %} media_player.home_group
            {% endif %}
          volume_level: '{{  states.input_slider.volume_radio.state  }}' 
      - service: tts.amazon_polly_say
        data_template:
          entity_id: >
            {% if is_state("input_select.chromecast_radio", "Livingroom") %} media_player.ca_livingroom
            {% elif is_state("input_select.chromecast_radio", "Hall") %} media_player.ca_hall
            {% elif is_state("input_select.chromecast_radio", "Bedroom") %} media_player.bed_room
            {% elif is_state("input_select.chromecast_radio", "Bathroom") %} media_player.ca_bathroom
            {% elif is_state("input_select.chromecast_radio", "Everywhere") %} media_player.home_group
            {% endif %}
          message: "Next station: {{ states.input_select.radio_station.state  }}"
      - delay: '00:00:08'   
      -  service: media_player.play_media
         data_template:
           entity_id: >
            {% if is_state("input_select.chromecast_radio", "Livingroom") %} media_player.ca_livingroom
            {% elif is_state("input_select.chromecast_radio", "Hall") %} media_player.ca_hall
            {% elif is_state("input_select.chromecast_radio", "Bedroom") %} media_player.bed_room
            {% elif is_state("input_select.chromecast_radio", "Bathroom") %} media_player.ca_bathroom
            {% elif is_state("input_select.chromecast_radio", "Everywhere") %} media_player.home_group
            {% endif %}
           media_content_id: >
            {% if is_state("input_select.radio_station", "Radio 538") %} http://vip-icecast.538.lw.triple-it.nl:80/RADIO538_MP3
            {% elif is_state("input_select.radio_station", "Q-Music") %} http://icecast-qmusic.cdp.triple-it.nl/Qmusic_nl_live_96.mp3
            {% elif is_state("input_select.radio_station", "3FM") %} http://icecast.omroep.nl/3fm-bb-mp3
            {% elif is_state("input_select.radio_station", "100% NL") %} http://stream.100p.nl/100pctnl.mp3
            {% elif is_state("input_select.radio_station", "Veronica") %} http://8543.live.streamtheworld.com/VERONICACMP3
            {% elif is_state("input_select.radio_station", "Sky Radio") %} http://8623.live.streamtheworld.com:80/SKYRADIOAAC_SC
            {% elif is_state("input_select.radio_station", "Arrow Classic Rock") %} http://91.221.151.155/listen.mp3
            {% elif is_state("input_select.radio_station", "Classic FM") %} http://19143.live.streamtheworld.com/CLASSICFM_SC
            {% elif is_state("input_select.radio_station", "BNR Nieuwsradio") %} http://icecast-bnr.cdp.triple-it.nl/bnr_mp3_96_03
            {% elif is_state("input_select.radio_station", "Smooth Jazz Tampa") %} http://us3.internet-radio.com:8007/listen.mp3           
            {% elif is_state("input_select.radio_station", "Classic Rock Florida") %} http://listen.shoutcast.com/Classic-RockFlorida
            {% elif is_state("input_select.radio_station", "Bob Sinclar Radio") %} http://listen.shoutcast.com/prysmradio09-mp3            
            {% elif is_state("input_select.radio_station", "Chill Out Zone") %} http://air.chillout.zone:8000/radio           
            {% elif is_state("input_select.radio_station", "SLAM! Hardstyle") %} http://stream.radiocorp.nl/web11_mp3
            {% elif is_state("input_select.radio_station", "Sleep Radio") %} http://37.59.28.208:8722/stream
            {% elif is_state("input_select.radio_station", "Ambient Sleeping Pill") %} http://perseus.shoutca.st:8447/h
            {% elif is_state("input_select.radio_station", "Radio Art - Sleep") %} http://live.radioart.com/fSleep.mp3
            {% elif is_state("input_select.radio_station", "Ambi Nature Radio") %} http://94.23.252.14:8067/stream
            {% elif is_state("input_select.radio_station", "Calm Radio - Sleep") %} http://streams.calmradio.com/api/39/128/stream
            {% elif is_state("input_select.radio_station", "Dinamo.FM Sleep") %} http://channels.dinamo.fm/sleep-aac
            {% endif %}
           media_content_type: 'audio/mp4'

I you don’t have Amazin Polly setup, use Google TTS instead.
Also, the delay of 8 seconds is just an estimate, change if needed.

Update:
You can also try this for the delay:

      - delay: > 
            {% if is_state("input_select.chromecast_radio", "Livingroom") %} '00:00:{{ states.media_player.ca_livingroom.attributes.media_duration | int }}'
            {% elif is_state("input_select.chromecast_radio", "Hall") %}  '00:00:{{ states.media_player.ca_hall.attributes.media_duration | int }}'
            {% elif is_state("input_select.chromecast_radio", "Bedroom") %}  '00:00:{{ states.media_player.media_player.bed_room.attributes.media_duration | int }}'
            {% elif is_state("input_select.chromecast_radio", "Bathroom") %}  '00:00:{{ states.media_player.media_player.ca_bathroom.attributes.media_duration | int }}'
            {% elif is_state("input_select.chromecast_radio", "Everywhere") %}  '00:00:{{ states.media_player.media_player.home_group.attributes.media_duration | int }}'
            {% endif %}

I’m not sure if templating is possible in the delay section though.

2 Likes

Works like a charm with google tts. :smiley: Thanks Bob.

1 Like

I love this Chromecast Radio integration! Thanks @Bob_NL :+1:

I made a radio station list mixing in stations from my RTL-SDR using rtl_fm_streamer for some Internet-free streaming local radio stations.

It would be made even easier if input_select supported a data payload like in the Feature Request linked below. Consider voting on it to greatly simplify this type of scripting.

1 Like

Did you put script.radio538 in the group for viewing?