Chromecast Radio with station and player selection

in case that helps, I find that the built-in Cast function of the Onkyo is REALLY slow to connect/sync.
If I only use CC Audios, it’s almost instant. If I cast to a group that includes my Onkyo, it’s slower
Sometimes I have to trigger my action/script twice for the audio stream to actually start

Anyway this is how I’ve set up my onkyo under media_player in my config:

- platform: onkyo
  host: 192.168.0.26
  name: Onkyo TX-NR656
  sources:
    video6: 'Main PC'
    bluray: 'Blu-Ray'
    video2: 'Sky'
    network: 'ChromeCast'
    tv: 'TV'
    strm-box: 'Stream-Box/CC'

and this is what I can see in my list of entities:

B-UTIFUL! Tried to go through the forum, but I might have missed it.
Can you share your config for this?

What tablet do you use for this and does it response fast enough?

Check the Tileboard topic in Home assistant forum or visit below URL

I am using Insigna Windows 10 tablet, except for cameras I have no issue for any other IOT device. Its just refresh rate way it work in Tileboard.

Hi
Thanks about your scripts :grinning:

evrything work really great , excpet the “change speakers”

have some update to this issue ?

@henaa please share your current config so we can troubleshoot.

Already fixed it here :wink:

@Mariusthvdb - Thanks for sharing your code - adding it over here but struggling with the radio_pause and radio_resume. Like you, I have google minis that are used for door/window open/close alerts that I send via MP3/cast. That stops the radio and doesn’t resume.

Could you please share your pause and resume section of the code? Are you still using delays too? Trying to figure out how to allow for the alerts and then resume the radio if it was previously playing.

Thanks!!!

does this help?

  intercom_message:
    alias: 'Intercom message'
    sequence:
      - condition: template
        value_template: >
          {{ is_state('input_boolean.announce_intercom', 'on') }}
      - service: script.radio_paused_for_message
      - service: script.wakeup_radio_paused_for_message
      - service: script.spotify_paused_for_message
      - service: media_player.volume_set
        data_template:
          entity_id: >
            {{states('sensor.intercom')}}
          volume_level: >
            {{ states('input_number.intercom_volume')|float }}
#            # {{ states('sensor.intercom_volume')|float  }}
      - service: tts.google_say
        data_template:
          language: >
            {{states('input_select.intercom_language')|lower}}
          entity_id: >
            {{states('sensor.intercom')}}
          message: >
            {% set language = states('input_select.intercom_language') %}
            {% if language == 'En' %} {{message_en}}
            {% elif language == 'Nl' %} {{message_nl}}
            {% else %} {{message_en}}
            {% endif %}

#            {% set language = states('input_select.intercom_language') %}
#            {% if language in [ 'En', 'Nl'] %} {{ data['message_'+language|lower] }}
#            {% else %} {{message_en}}
#            {% endif %}

#            {% set language = states('input_select.intercom_language') %}
#            {% if language in [ 'En', 'Nl'] %} {{message_ + language|lower}}
#            {% else %} {{message_en}}
#            {% endif %}


      - service: script.resume_radio_paused_for_message
      - service: script.resume_wakeup_radio_paused_for_message
#      - condition: template
#        value_template: >
#          {{is_state('input_boolean.radio_paused','on')}}
#      - delay:
#          seconds: 20
##      - wait_template: >
##          {{states(states('sensor.intercom')) != 'playing'}}
#      - service: input_boolean.turn_off
#        entity_id: input_boolean.radio_paused
#      - service: input_boolean.turn_off
#        entity_id: input_boolean.wakeup_radio_paused
#      - condition: template
#        value_template: >
#          {{ not is_state('input_select.radio_station','Select') }}
#      - service: script.play_radio
#      - service: script.play_wakeup_radio

  radio_paused_for_message:
    alias: 'Radio paused for message'
    sequence:
      - condition: template
        value_template: >
          {{states('sensor.intercom') == states('sensor.media_player') }}
      - condition: template
        value_template: >
          {{states(states('sensor.media_player')) == 'playing'}}
      - service: input_boolean.turn_on
        entity_id: input_boolean.radio_paused

  wakeup_radio_paused_for_message:
    alias: 'Wakeup radio paused for message'
    sequence:
#      - condition: template
#        value_template: >
#          {{states('sensor.intercom') == states('sensor.media_player') }}
      - condition: template
        value_template: >
          {{states(states('sensor.wakeup_radio')) == 'playing'}}
      - service: input_boolean.turn_on
        entity_id: input_boolean.wakeup_radio_paused

  spotify_paused_for_message:
    alias: 'Spotify paused for message'
    sequence:
      - condition: template
        value_template: >
          {{states(states('sensor.spotify_player')) == 'playing'}}
      - service: input_boolean.turn_on
        entity_id: input_boolean.spotify_paused

# {{states(states('sensor.media_player')) == 'playing'}}
# {{is_state(states('sensor.spotify_player'),'playing') }}

  resume_radio_paused_for_message:
    alias: Resume radio paused for message
    sequence:
      - condition: template
        value_template: >
          {{is_state('input_boolean.radio_paused','on')}}
      - delay:
          seconds: 20
#      - wait_template: >
#          {{states(states('sensor.intercom')) != 'playing'}}
      - service: input_boolean.turn_off
        entity_id: input_boolean.radio_paused
      - condition: template
        value_template: >
          {{ not is_state('input_select.radio_station','Select') }}
      - service: script.play_radio

Hi All,

what can be the problem of streams stop after 10 - 15 seconds?
All streams have same issue, on my tablet. They all work on iMac

EDIT:

Changed userangent in Fully Kiosk to chrome for windows. Now problems is gone

Hi could you please share the latest code with radio? :slight_smile: thanks in advance.

Will this also able without node-red? Add pictures to every channel and show them?

which code are you referring to? haven’t changed anything lately.

what is the reason to group the entities?

ah sorry I thought you modify your code in for several posts.

Don’t know if that’s possible. I recommend you to use node red, it is much easier when scripts/flows get more complicated.

How do you show this controls on Lovelace ui?

You should be able to use media control card;

Or the custom mini media player card;

Hi thanks, it looks like i had a miss configuration with the input selects.

Hi,

How would you tweak this one;
I went with the original code and everything seem to work perfectly, with my Google Home and my Chromecast. But one problem I came across, was when trying to stream audio to my chromecast that is connected to my AVR. When I select “media_player.denon_chromecast_audio” then it will try to stream to that device and probably also does. Unfortunately my AVR doesn’t turn on, nor the Zone where I want to “Living Room”.

If I add the media_player.turn_on in the script below, then it will just always turn it on, no matter what media player I select.

Does anyone have a good approach (sorry if I have missed a post where this already have been addressed).

script:

  afspil_radio:
    alias: Play Radio Audio Unit
    sequence:
      -  service: media_player.volume_set
         data:
           entity_id: media_player.home_assistant_stue
           volume_level: '0.20'
      -  service: media_player.play_media
         data_template:
           entity_id: >
            {% if is_state("input_select.chromecast_radio", "Living Room") %}  media_player.home_assistant_stue
            {% elif is_state("input_select.chromecast_radio", "Bathroomn") %} media_player.denon_chromecast_audio
            {% elif is_state("input_select.chromecast_radio", "All") %} media_player.all_rooms
            {% 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", "SLAM! Hardstyle") %} http://vip-icecast.538.lw.triple-it.nl/WEB17_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'

EDIT:

I solved it by putting in the below code just after the media_player.play_media

      - service: media_player.turn_on
        data_template:
          entity_id: >
            {% if is_state("input_select.chromecast_radio", "Stue") %} media_player.stue_kokken
            {% elif is_state("input_select.chromecast_radio", "Bade") %} media_player.badevaerelser
            {% elif is_state("input_select.chromecast_radio", "Alle Rum") %} media_player.stue_kokken, media_player.badevaerelser
            {% endif %}
1 Like

Cool, thanks for sharing. I’ve modified this to work with Node-RED :slight_smile: writeup coming.