Chromecast Radio with station and player selection

Show me some code and I can help. The example I provided uses a custom card so you can’t copy it completely, but you need to use the conditional part of it

Here are my Lovelace config

      - cards:
          - artwork: cover
          - entities: null
            entity: media_player.googlehomemini
            group: false
            hide:
              power: false
              volume: true
            info: scroll
            source: icon
            type: 'custom:mini-media-player'
          - card:
              entities:
                - entity: input_select.radio_speakers
                - entity: input_select.radio_station
                - artwork: none
                  entity: media_player.googlehomemini
                  group: false
                  hide:
                    controls: true
                    info: false
                    power: true
                    progress: true
                  icon: 'mdi:monitor-speaker'
                  type: 'custom:mini-media-player'
                - artwork: none
                  entity: media_player.mijn_chromecast
                  group: false
                  hide:
                    controls: true
                    info: true
                    power: false
                    progress: true
                  icon: 'mdi:mdi:cast-audio'
                  type: 'custom:mini-media-player'
              show_header_toggle: true
              type: entities
            conditions:
              - entity: media_player.googlehomemini
                state_not: 'off'
              - entity: media_player.googlehomemini
                state_not: unavailable
            type: conditional
        type: 'custom:vertical-stack-in-card'
      - entities:
          - entity: automation.set_radio_volume
          - entity: input_boolean.radio_play
        show_header_toggle: false
        type: entities

Hi ASNNetowrk,

Your last edit sounds good. This is what i’m looking for for playing my favorite spotify playlists.
i have spotcast and use now the custom spotify card but i’m not happy with the layout of it.
can you share your config how you have setup the spotify playlists instead of the radio streams?

Basically you just need to edit the service call used in the script and the service data, so it will envoke spotcast and the Spotify URI instead of radio streams.

spotify:
  alias: Start Spotify
  sequence:
    -  service: spotcast.start
       data_template:
         entity_id: >
          {% if is_state("input_select.google_cast", "Sony") %} media_player.sony_cast
          {% elif is_state("input_select.google_cast", "Badkamer") %} media_player.badkamer_cast
          {% elif is_state("input_select.google_cast", "Sony Stereo") %} media_player.sony_stereo_cast
          {% elif is_state("input_select.google_cast", "Multispeakers") %} media_player.multispeakers_cast
          {% elif is_state("input_select.google_cast", "Party Speakers") %} media_player.party_speakers
          {% elif is_state("input_select.google_cast", "Super Groep") %} media_player.super_groep
          {% endif %}
         uri: >
          {% if is_state("input_select.spotify_playlist", "Global Top 50") %} spotify:playlist:37i9dQZEVXbMDoHDwVN2tF
          {% elif is_state("input_select.spotify_playlist", "Today's Top Hits") %} spotify:playlist:37i9dQZEVXbMDoHDwVN2tF
          {% elif is_state("input_select.spotify_playlist", "New Music Friday") %} spotify:playlist:37i9dQZF1DX4JAvHpjipBk
          {% elif is_state("input_select.spotify_playlist", "Discover Weekly") %} spotify:playlist:37i9dQZEVXcQorVlmdOh35
          {% elif is_state("input_select.spotify_playlist", "Neef") %} spotify:playlist:0hbQY0xakFZ0o5Xf30rlph
          {% elif is_state("input_select.spotify_playlist", "Omelette du Frommage") %} spotify:playlist:3w16ohVvJwiYZ8N1Kz6tIz
          {% elif is_state("input_select.spotify_playlist", "Fissa") %} spotify:playlist:5WZ951CGTTuOeay4c7jMsb
          {% elif is_state("input_select.spotify_playlist", "Baila Reggaeton") %} spotify:playlist:37i9dQZF1DWY7IeIP1cdjF
          {% elif is_state("input_select.spotify_playlist", "Golden Era Music") %} spotify:playlist:1X8CLmPyo2dBLXgmOotqGb
          {% elif is_state("input_select.spotify_playlist", "Rock") %} spotify:playlist:5BI3eXjUNc7CmDTRQo8Eh2
          {% elif is_state("input_select.spotify_playlist", "Golden Oldies") %} spotify:playlist:3oqXop9kNZ1JCbJTyk9sJs
          {% elif is_state("input_select.spotify_playlist", "Lo-Fi Hip-Hop") %} spotify:playlist:37i9dQZF1DWWQRwui0ExPn
          {% elif is_state("input_select.spotify_playlist", "Supalonely Radio") %} spotify:playlist:37i9dQZF1E8BaEV2PtTgL1
          {% elif is_state("input_select.spotify_playlist", "Morning Dew Radio") %} spotify:playlist:37i9dQZF1E8AvabLLYZIuG
          {% elif is_state("input_select.spotify_playlist", "Winter Acoustic") %} spotify:playlist:4LFjFTv8HmijBmqVwIyxnb
          {% elif is_state("input_select.spotify_playlist", "Koffiehuis") %} spotify:playlist:37i9dQZF1DWYPwGkJoztcR
          {% endif %}
         random_song: 'true'     
         shuffle: 'true'

Just replace the names accordingly (also in the other places) to match everything and then create an entities card with Lovelace. I don’t use the script as an entity, but have created a button with button-card and linked that to the script. i didn’t like the script button (too small and on the side).

Thank you very much. That is easier than i thought.
The entities card in combination of de mini-media-player-card in en vertical-stack-card must be a very nice spotify card.
thank you.

Yes, that is what I have. Entities, with button card below it and mini media player (that only shows when playing). Wrap the whole stack inside a popup card using browsermod and you’re really cooking ;)!

3 Likes

How did you make the mediaplayer only visible when playing?

You can do that by using a conditional card. Then you need to wrap the mini media player card inside the conditional card. For instance:

              - card:
                  artwork: full-cover
                  entity: media_player.speaker
                  group: false
                  hide:
                    controls: false
                    power: false
                    progress: false
                    volume: true
                    source: true
                  icon: 'mdi:speaker'
                  info: scroll
                  style: ''
                  tap_action:
                    action: more-info
                  type: 'custom:mini-media-player'
                conditions:
                  - entity: media_player.speaker
                    state: playing
                type: conditional

The condition looks at the state of the entity and only shows it only when the condition is met. You can also use the multiple state_not variables if you want it to show not only when playing, but also when paused. If you chang the conditions to state_not: off it basically says show it always except when state is not. You can add multiple state_not variables.

In this case I advise you to not use state: playing but use state_not: off, otherwise you will only see the card when playing and it will disappear when you pause it :wink: I advise to read the documents I linked about the conditional card if you have any issues.

1 Like

@Bob_NL

Looks awesome. Can you give me some directions?. I’m trying to understand it, but what do i need to put were?.

Everytime i put

group:
 Residence Radio:
  name: Residentie Radio
  entities:
  - input_select.radio_station
  - input_select.chromecast_radio
  - script.radio538
  - input_slider.volume_radio

inside my groups.yaml i get an error saying:

  • Invalid config for [group]: [Radio] is an invalid option for [group]. Check: group->group->group->Radio. (See /config/configuration.yaml, line 12).
  • Invalid config for [group]: [Residence Radio] is an invalid option for [group]. Check: group->group->group->Residence Radio. (See /config/configuration.yaml, line 12).

change the group entity_id to remove the capital 'R’s and change the spare for an underscore… plus the indentation was off. You don’t use the domain when in a domain named yaml file either

# group:         <----since you are saving this in groups.yaml , you can't then use the domain heading group: (it's not required or allowed)
  residence_radio:
    name: Residentie Radio
    entities:
      - input_select.radio_station
      - input_select.chromecast_radio
      - script.radio538
      - input_slider.volume_radio
1 Like

After using this project for a long time now, I wanted to give some kind of RDS information for the current playing songs.

I am using the scrape sensor to pull the data from the Radio’s official website, or some other website that displays the current playing song.

For example in my sensor.yaml,

- platform: scrape   
  resource: https://onlineradiobox.com/gr/pepper/
  select: '#bodyW > div.page > div > div.page__wrapper-4right > div > section.station-onair > table > tbody > tr.active > td:nth-child(2) > a'
  name: Pepper RDS 

It takes some time to find out the right selectors, but then you can have something like this:

2 Likes

how to install it??

Create a package as per the package docs

@Bob_NL Thanks for your guide. I’ve set up everything but now I don’t know wich card shall I use to show the first picture of your post? I mean the main one with selectors you put under the Frontend: section. Is there a specific card to view the groups in Lovecale?

@Knot83 I created this topic long before lovelace excisted. I’m sure there are plenty of way better options than the oldschool method I’m using (to everybody: please feel free to share awesome lovelace cards in combination with the radio in this topic :slight_smile: ).
However, this is my lovelace config:

entities:
  - input_select.radio_station
  - input_select.chromecast_radio
  - action_name: Play Radio
    entity: script.radio538
  - entity: input_number.volume_master
  - sensor.radiovolume
  - input_text.stream_url
  - action_name: Play stream
    entity: script.play_stream
show_header_toggle: false
title: Residentie Radio
type: entities

Which looks like this:
image

3 Likes

Thanks for sharing (y). I missed that post. Will look into it.

Same here, I have a killer alarm clock (if I may say so myself) including lullabies, wakeup light and of course the radio which I use every day but it also became a very complex project. I did not find the time and desire to untangle the whole thing and make it usable for everyone who is interested.

This was the post btw: Chromecast Radio with station and player selection

I tied the Spotify playlist picker inside a vertical stack-in-card with conditional mini media player cards. If more speakers are active (with other streams) I can swipe between the mini media player cards and control the speakers. I also incorporated swiper card. Looks really clean :slight_smile:

1 Like

Came across this test of yours after I could not get my Google Home Minis to play anything. When I try your test in the dev-services panel or through any other method my speaker plays a tone which I presume to be an error tone. (It’s not the usual “Casting started tone”.)
Any idea what may be happening?
Thank you.

Welcome to the HA community :slight_smile:

I’ve never had an error tone played before that I can think of. Have you been able to cast to the Home mini from HA before? If this is your first attempt I’d suggest checking the config, but that stream link should work…