Chromecast webradio (metadata, frontend)

Hi, im playing around with HA the last two days and now trying to implement a simple webradio player for my google cast enabled speakers.

Whats working so far: I have a script per station which plays a webradio URL on a cast speaker via “play_media” on the “media_player” component, automated or triggered manually.

But now i like to implement some enhancements but i dont know if they are possible:

  • populate the scripts out of some kind of array to avoid code duplication? (array of n URLS -> n scripts)
  • show the scripts as smaller buttons/images inside an webradio group instead of “script name - activate”? (like the ones on the top)
  • is it possible to specify metadata (image / station name) in addition to the url to get a nicer “now playing” info from the media_player? (if i cast from my phone, the info is displayed nicely in HA already) (have seen that pychromecast API supports a metadata argument, but have no idea how to route that through HA API)

just for interest:

  • Are there plans for some kind of media controller components for the HA frontend?
    in this case a webradio component configured with an “output media_player” and a list of stations which exposes controls on the frontend and handles the media_play calls?

thanks for reading and this great project!

Here is my webradio https://github.com/Danielhiversen/home-assistant_config/blob/master/automation/audio.yaml#L78

1 Like

This is my script for streaming radio to my Chromecast, it partially answers your questions:

input_select:
  radio_station:
    name: Radio Station
    options:
      - Radio 538
      - Q-Music
      - 3FM
      - 100% NL
      - Veronica
      - Sky Radio
    initial: Radio 538
    icon: mdi:radio

Script:

  radio:
    alias: Play Radio on Chromecast Audio
    sequence:
      - alias: Start stream
        service: media_player.play_media
        data_template:
          entity_id: media_player.cc_audio
          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
            {% endif %}
          media_content_type: 'audio/mp4'