How to configure a radio stations player
Emiliano Guerzoni
Project Manager / Technical Manager renewables/energy efficiency projects | Demand Manager digital energy domain at algoWatt
Hi guys,
In this article I introduced how to use Home Assistant to listen to internet radio stations.
What described in that article was something super basic. Nothing was created, I had just simply used what Home Assistant provides by default.?
Today I want to go a little bit deeper.
Recetly I've created some things to be able to:
Software configuration
Home Assistant code (yaml) / procedure
I've created the following objects described below:
Dropdown list to select the Radio station you want to listen to
领英推荐
Another dropdown list to select the speaker on which playing the radio station
A button to start playing
A control area to pause / stop playing and set the volume on the selected device
Please refer to this video to get in touch with the feature:
Are you curious to see the code written to do this?
Well, this is the code - as Script - I've written to manage everything:
sequence:
? - service: media_player.volume_set
? ? data_template:
? ? ? entity_id: |
? ? ? ? {%- if is_state("input_select.google_speaker_radio", "Casa") -%}
? ? ? ? ? group.multimedia
? ? ? ? {%- elif is_state("input_select.google_speaker_radio", "Cucina") -%}
? ? ? ? ? media_player.cucina
? ? ? ? {%- elif is_state("input_select.google_speaker_radio", "Cameretta") -%}
? ? ? ? ? media_player.camera_matrimoniale
? ? ? ? {%- elif is_state("input_select.google_speaker_radio", "Soggiorno") -%}
? ? ? ? ? media_player.soggiorno
? ? ? ? {%- elif is_state("input_select.google_speaker_radio", "Studio") -%}
? ? ? ? ? media_player.studio
? ? ? ? {%- endif -%}
? ? ? volume_level: 0.15
? - delay: 0.5
? - service: media_player.play_media
? ? target:
? ? ? entity_id: |
? ? ? ? {%- if is_state("input_select.google_speaker_radio", "Casa") -%}
? ? ? ? ? group.multimedia
? ? ? ? {%- elif is_state("input_select.google_speaker_radio", "Cucina") -%}
? ? ? ? ? media_player.cucina
? ? ? ? {%- elif is_state("input_select.google_speaker_radio", "Cameretta") -%}
? ? ? ? ? media_player.camera_matrimoniale
? ? ? ? {%- elif is_state("input_select.google_speaker_radio", "Soggiorno") -%}
? ? ? ? ? media_player.soggiorno
? ? ? ? {%- elif is_state("input_select.google_speaker_radio", "Studio") -%}
? ? ? ? ? media_player.studio
? ? ? ? {%- endif -%}
? ? data:
? ? ? media_content_id: >
? ? ? ? {%- if is_state("input_select.radio_stations_list", "One Dance") -%}
? ? ? ? ? media-source://radio_browser/7a67fe09-ab18-11e9-88f4-52543be04c81
? ? ? ? {%- elif is_state("input_select.radio_stations_list", "R101 La Banda di
? ? ? ? R101") -%}
? ? ? ? ? media-source://radio_browser/b34742d3-7fad-11e8-a43d-52543be04c81
? ? ? ? {%- elif is_state("input_select.radio_stations_list", "R101 Enjoy The
? ? ? ? Music") -%}
? ? ? ? ? media-source://radio_browser/96262cd1-0601-11e8-ae97-52543be04c81
? ? ? ? {%- elif is_state("input_select.radio_stations_list", "R101 '90") -%}
? ? ? ? ? media-source://radio_browser/9639f338-0601-11e8-ae97-52543be04c81
? ? ? ? {%- elif is_state("input_select.radio_stations_list", "R101 '00") -%}
? ? ? ? ? media-source://radio_browser/9624a5a0-0601-11e8-ae97-52543be04c81
? ? ? ? {%- elif is_state("input_select.radio_stations_list", "Radio 105
? ? ? ? Network") -%}
? ? ? ? ? media-source://radio_browser/9619ea14-0601-11e8-ae97-52543be04c81
? ? ? ? {%- elif is_state("input_select.radio_stations_list", "Radio Kiss Kiss
? ? ? ? Italia")-%}
? ? ? ? ? media-source://radio_browser/961756e4-0601-11e8-ae97-52543be04c81
? ? ? ? {%- elif is_state("input_select.radio_stations_list", "Radio Babboleo
? ? ? ? Suono")-%}
? ? ? ? ? media-source://radio_browser/af6fdb6a-a57b-4cc9-ab92-53c826041aef
? ? ? ? {%- endif -%}
? ? ? extra:
? ? ? ? thumb: >
? ? ? ? ? {%- if is_state("input_select.radio_stations_list", "One Dance") -%}
? ? ? ? ? ? ?https://onedance.fm/img/apple-touch-icon-114x114.png
? ? ? ? ? {%- elif is_state("input_select.radio_stations_list", "R101 La Banda
? ? ? ? ? di R101")-%}
? ? ? ? ? ? ?https://www.r101.it/favicon_7.ico?v=1561631502000
? ? ? ? ? {%- elif is_state("input_select.radio_stations_list", "R101 Enjoy The
? ? ? ? ? Music") -%}
? ? ? ? ? ? ?https://www.r101.it/favicon_7.ico?v=1561631502599
? ? ? ? ? {%- elif is_state("input_select.radio_stations_list", "R101 '90") -%}
? ? ? ? ? ? ?https://www.r101.it/favicon_7.ico?v=1561631502000
? ? ? ? ? {%- elif is_state("input_select.radio_stations_list", "R101 '00") -%}
? ? ? ? ? ? ?https://www.r101.it/favicon_7.ico?v=1561631502599
? ? ? ? ? {%- elif is_state("input_select.radio_stations_list", "Radio 105
? ? ? ? ? Network") -%}
? ? ? ? ? ? ?https://upload.wikimedia.org/wikipedia/it/0/01/105.png
? ? ? ? ? {%- elif is_state("input_select.radio_stations_list", "Radio Kiss Kiss
? ? ? ? ? Italia") -%}
? ? ? ? ? ? ?https://kisskissitalia.it/wp-content/uploads/2021/07/cropped-favicon-kisskissitalia-180x180.png?
? ? ? ? ? {%- elif is_state("input_select.radio_stations_list", "Radio Babboleo
? ? ? ? ? Suono") -%}
? ? ? ? ? ? ?https://players.fluidstream.it/RadioBabboleo/images/babboleo_suono.png
? ? ? ? ? {%- endif -%}
? ? ? media_content_type: audio/aac
? ? metadata:
? ? ? title: >
? ? ? ? {%- if is_state("input_select.radio_stations_list", "One Dance") -%}
? ? ? ? ? One Dance
? ? ? ? {%- elif is_state("input_select.radio_stations_list", "R101 La Banda di
? ? ? ? R101") -%}
? ? ? ? ? R101 La Banda di R101
? ? ? ? {%- elif is_state("input_select.radio_stations_list", "R101 Enjoy The
? ? ? ? Music") -%}
? ? ? ? ? R101 Enjoy The Music
? ? ? ? {%- elif is_state("input_select.radio_stations_list", "R101 '90") -%}
? ? ? ? ? R101 90
? ? ? ? {%- elif is_state("input_select.radio_stations_list", "R101 '00") -%}
? ? ? ? ? R101 00
? ? ? ? {%- elif is_state("input_select.radio_stations_list", "Radio 105
? ? ? ? Network") -%}
? ? ? ? ? Radio 105 Network
? ? ? ? {%- elif is_state("input_select.radio_stations_list", "Radio Kiss Kiss
? ? ? ? Italia") -%}
? ? ? ? ?Radio Kiss Kiss Italia
? ? ? ? {%- elif is_state("input_select.radio_stations_list", "Radio Babboleo
? ? ? ? Suono") -%}
? ? ? ? ?Radio Babboleo Suono
? ? ? ? {%- endif -%}
mode: single
icon: mdi:radio
alias: AscoltaRadio
Some specifics about the code / steps above
Thank you for reading and watching. ?? I hope you have enjoyed this article and video too.
I'm available for any feedback so, feel free to contact me or share your thoughts in the comments section below.
Your feedbacks will be very appreciated!
Meanwhile,?if you liked this article share it or?subscribe?to my newsletter?about?Home Assistant?to read all previous episodes and still up to date on latest news.
Expert team manager and hungry for more
1 年Hey, Great tutorial! What entity using in the "attualmente in play" section? Can you share this code?
Electronics and Computer Control Expert at the Physics Department at University of Antwerp
1 年This tutorial helped me a lot with building up a selection of radio stations which can be played through a google home mini. It worked for months. Since I installed the last update Home Assistant (2023.3.5), the buttons are disabled. The warning says (translated) that the entity for input_select and input_number are not available anymore. Did to your knowledge some partial way of coding get depreciated? Nothing changed on the system a part from the updates, so I'm assuming the cause must have to do with that.
Retired Sr Hardware expert Engineer at Krohne New Technologies
1 年Hi I found this script dor playing the radio in HA. I looks interesting and The script looks clear to me and easy enoug to patse as a script. Editting for the stations is the next thing when all is working. But hopd did you create the 'view'? Which card did you use? you write Dropdown list to select the Radio station you want to listen to And another dropdown list. I looked in my cards but do not see a dropdown list