If you followed the above you would have created a script. The script is what turns the radio on, so you need to expose it.
Then you can’t just say rien the radio on, you’ll have to turn the script on. I’ve not exposed any script yet but I strongly suspect it’ll have to be something like "turn the script [script name] on ". You should however be able to create a routine with a special voice command to call the script though
Do i only need to add - script to exposed domains?
And then say hey google turn on script.radio_start on?
Here are my Scripts file.
radio_start:
alias: Play Radio on Chromecast Audio
sequence:
- service: media_player.volume_set
data:
entity_id: media_player.mijn_chromecast
volume_level: '0.30'
- service: media_player.volume_set
data:
entity_id: media_player.googlehomemini
volume_level: '0.30'
- service: media_player.play_media
data_template:
entity_id: >
{% if is_state("input_select.radio_speakers", "GoogleHomeMini") %} media_player.googlehomemini
{% elif is_state("input_select.radio_speakers", "mijn_chromecast") %} media_player.mijn_chromecast
{% elif is_state("input_select.radio_speakers", "Everywhere") %} media_player.home_group
{% endif %}
media_content_id: >
{% if 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", "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", "Classic FM") %} http://19143.live.streamtheworld.com/CLASSICFM_SC
{% elif is_state("input_select.radio_station", "SLAM! Hardstyle") %} http://vip-icecast.538.lw.triple-it.nl/WEB17_MP3
{% endif %}
media_content_type: 'audio/mp4'
yes unless you also want to be able to change the radio station / speaker via voice
by default it would be “turn radio start script on” or similar, but like I said you can create a routine so that when you say “turn the radio on” it actually behaves as if you said “turn on script.radio_start on”
Dear Bob_nl, is there anywhere a card to install? from Hacs or HA? And where do you place the view, group, scripts and selectors?
Hi, completely new to Hassio and this forum. New to home automation. And therefor not sure how things work around here… I am overwhelmed by the amount of information and knowledge here: hopefully someone can help me.
I’ve read the initial post and started scrolling through the 580+ posts afterwards, looking for the answer to my question: should all code go into configuration.yaml? Or are different parts of the code go into different files? Couldn’t find the answer so far.
put all of it in one file saved under \config\packages and then include packages to your config.yaml
Hi, I tried what you meant but had no luck. I think I’m skipping something.
I have added this in configuration.yaml
homeassistant:
packages: !include_dir_named packages
I put all the information from the first post in /config/packages/chromecast_radio.yaml
and changed the media_player entities to my owns. But now I get an invalid config error. I think I’m not supposed to put all in one .yaml file? The first post mentions View, Selectors, Script and Customize script name. Can you explain to me where to put what?
This is the config error btw:
Invalid config for [input_select]: [alias] is an invalid option for [input_select]. Check: input_select->input_select->radio538->alias. (See /config/configuration.yaml, line 104).
Invalid config for [group]: [input_select] is an invalid option for [group]. Check: group->group->Woning Radio->input_select. (See /config/configuration.yaml, line 123).
Edit: I put all the codes manually in each section myself. Somehow, I keep getting the error that alias is an invalid option for input select, but I have NO alias mentioned anywhere. This is very weird.
Edit 2: I removed everything and placed them manually instead of using a package. I think the identations were not correctly in the example, which cauased these weird issues in my setup. I can see the entities now, gonna try it with a card.
Edit 3: Unfortunately the streams don’t work (probably have to change those). But that doesn’t matter anymore. I fully understand the setup now, so have edited everyhting to use with Spotify playlists (using spotcast service). Works like a charm and is a lot cleaner than my previous Spotify playlist selector.
Guys how can i hide the Chromecast or GoogleHome mini on the lovelace when not in using? When it is using such as when you start the radio i want to be appear automatically in lovelace on the top.
Use a conditional card.
here is an example from part of my lovelace code
entity: media_player.lounge_speakers
group: false
hide:
controls: true
icon_state: false
power_state: false
progress: true
icon: 'mdi:speaker-wireless'
type: 'custom:mini-media-player'
conditions:
- entity: media_player.lounge_speakers
state_not: 'off'
type: conditional
Did not work for me
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 ;)!
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 I advise to read the documents I linked about the conditional card if you have any issues.
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).