santaklon
(Nicolas)
October 1, 2024, 6:42pm
1
I am trying to build a simple radio frontend in a lovelace dashboard to use for my retired father who himself used to be a radio reporter. The emphasis here is on SIMPLE.
I want:
Buttons to play predefined Stations (that are all available in Radio Browser)
Buttons to toggle the different chromecast-speakers in the house (join / unjoin stream)
Buttons to increase / decrease the volume and stop the radio (this seems feasible)
Radio browser has so many stations, it can’t be those cannot be called up by e.g. a button in lovelace? Thats the only useful application of the Radio Browser integration I can think of - yet all solutions I found require complicated YAML and manual research of the stream-url. This cant be true?
Joining / unjoining cast-speakers from whatever is playing is also such an obvious function. Yet I cant find any simple solution to this, it seems like you always have to specify where you wanna play something BEFORE you play it?
Please tell me I’m stupid and there is a simple solution to all this! Any help appreciated.
Mikefila
(Mike Fila)
October 1, 2024, 9:05pm
2
santaklon
(Nicolas)
October 1, 2024, 9:22pm
3
Thank you - that loooks promising, at least UI-wise. However it still relies on a scripts in the background for each button to call a specific playlist.
Any Idea how i could directly call a radio station? It should be possible since the tiles / functions are all there in the Radio Browser…
Arh
October 2, 2024, 6:28am
4
The way i do it is I have a simple automation to play a radio station I use on each speaker that is available. so they are easy to copy and change when the online radio station changes its url etc. I then have a helper button to choose radio station and one to choose speaker. These are then setup in an automation using choose as the trigger and calling the automation for the channel. Along with a simple helper button for play and one for stop to trigger the automation’s.
I then use custom:auto entities in a conditional card to display whatever media player is playing.
type: conditional
conditions:
- condition: state
entity: media_player.media_players
state: 'on'
card:
type: custom:auto-entities
card:
type: entities
state_color: true
filter:
include:
- group: media_player.media_players
state: playing
exclude: []
It ends up looking like this wjhen playing
I can upload more code if needed but it is simple enough to create with the UI stuff.
santaklon
(Nicolas)
October 2, 2024, 11:15am
5
That looks exactly like what i’m trying to accomplish!
Since I used to exclusively automate in Node Red until recently and am only starting out with automations and dashboard building in YAML, I am still quite overwhelmed with all the coding.
I would be most grateful if you could drop some code of your automations and lovelace for me to better understand and learn how to build this.
Thank you so much!
Arh
October 2, 2024, 3:22pm
6
A radio station automation
alias: Shropshire Live HG
description: ""
trigger:
- platform: state
entity_id:
- input_button.shropshire_live
condition: []
action:
- data:
media_content_id: >-
https://stream-01.aiir.com/iahhslxolv3uv?zt=eyJhbGciOiJIUzI1NiJ9.eyJzdHJlYW0iOiJpYWhoc2x4b2x2M3V2IiwiaG9zdCI6InN0cmVhbS0wMS5haWlyLmNvbSIsInJ0dGwiOjUsImp0aSI6IlBOYURtOU52U1Q2TEQzU3BMOTlPM1EiLCJpYXQiOjE3MjMxODU5NTIsImV4cCI6MTcyMzE4NjAxMn0.OFmlWmQrCTjk4GISjcKNVezgF_b71mihD56vYTzAt1U
media_content_type: Radio
target:
entity_id: media_player.home_group
action: media_player.play_media
- data:
volume_level: 0.1
target:
entity_id: media_player.home_group
enabled: false
action: media_player.volume_set
mode: single
The more complex one for spaekers and stations
alias: Radio Stations and Speaker
description: ""
trigger:
- platform: state
entity_id: input_button.radio_play
condition: []
action:
- choose:
- conditions:
- condition: state
entity_id: input_select.radio_stations
state: Radio Wales
sequence:
- choose:
- conditions:
- condition: state
entity_id: input_select.speakers
state: Office Speaker
sequence:
- data: {}
target:
entity_id:
- automation.wake_up_radio_wales_adrian
action: automation.trigger
- conditions:
- condition: state
entity_id: input_select.speakers
state: Kitchen Speaker
sequence:
- data: {}
target:
entity_id: automation.bbc_sounds_wales_kitchen
action: automation.trigger
- conditions:
- condition: state
entity_id: input_select.speakers
state: Home Group
sequence:
- data: {}
target:
entity_id:
- automation.play_radio_wales
action: automation.trigger
- conditions:
- condition: state
entity_id: input_select.speakers
state: wireless
sequence:
- metadata: {}
data:
volume_level: 0.02
target:
entity_id: media_player.wireless_player
action: media_player.volume_set
- data:
media_content_id: >-
http://lstn.lv/bbc.m3u8?station=bbc_radio_wales_fm&bitrate=320000
media_content_type: radio
target:
entity_id: media_player.wireless_player
enabled: false
action: media_player.play_media
- metadata: {}
data:
media_id: >-
http://lstn.lv/bbc.m3u8?station=bbc_radio_wales_fm&bitrate=320000
target:
entity_id:
- media_player.wireless
enabled: true
action: mass.play_media
default: []
- conditions:
- condition: state
entity_id: input_select.radio_stations
state: Radio Shropshire
sequence:
- choose:
- conditions:
- condition: state
entity_id: input_select.speakers
state: Office Speaker
sequence:
- data: {}
target:
entity_id: automation.bbc_sounds_shropshire_office
action: automation.trigger
- conditions:
- condition: state
entity_id: input_select.speakers
state: Kitchen Speaker
sequence:
- data: {}
target:
entity_id: automation.bbc_sounds_shropshire_kitchen
action: automation.trigger
- conditions:
- condition: state
entity_id: input_select.speakers
state: Home Group
sequence:
- data: {}
target:
entity_id: automation.bbc_sounds_shropshire
action: automation.trigger
- conditions:
- condition: state
entity_id: input_select.speakers
state: wireless
sequence:
- data: {}
target:
entity_id:
- automation.shropshire_live_on_wireless
action: automation.trigger
default: []
- conditions:
- condition: state
entity_id: input_select.radio_stations
state: Radio 2
sequence:
- choose:
- conditions:
- condition: state
entity_id: input_select.speakers
state: Office Speaker
sequence:
- data: {}
target:
entity_id: automation.bbc_sounds_radio_2_office
action: automation.trigger
- conditions:
- condition: state
entity_id: input_select.speakers
state: Kitchen Speaker
sequence:
- data: {}
target:
entity_id: automation.bbc_sounds_radio_2_kitchen
action: automation.trigger
- conditions:
- condition: state
entity_id: input_select.speakers
state: Home Group
sequence:
- data: {}
target:
entity_id: automation.bbc_sounds_radio_2_hg
action: automation.trigger
default: []
- conditions:
- condition: state
entity_id: input_select.radio_stations
state: Shropshire Live
sequence:
- choose:
- conditions:
- condition: state
entity_id: input_select.speakers
state: Home Group
sequence:
- data:
skip_condition: true
target:
entity_id: automation.shropshire_live
action: automation.trigger
- conditions:
- condition: state
entity_id: input_select.speakers
state: Office Speaker
sequence:
- data:
skip_condition: true
target:
entity_id: automation.shropshire_live_os
action: automation.trigger
- conditions:
- condition: state
entity_id: input_select.speakers
state: wireless
sequence:
- metadata: {}
data:
volume_level: 0.01
target:
entity_id: media_player.wireless_player
action: media_player.volume_set
- metadata:
title: Shropshire Live
thumbnail: >-
https://www.shropshirelive.com/wp-content/uploads/2018/07/shropshirelive-black-120x120.png
media_class: music
children_media_class: null
navigateIds:
- {}
- media_content_type: app
media_content_id: media-source://radio_browser
- media_content_type: music
media_content_id: media-source://radio_browser/country/GB
data:
media_content_id: >-
media-source://radio_browser/480e9fc1-2392-4a3d-8926-d9fdb10f8ea6
media_content_type: audio/mpeg
target:
entity_id: media_player.wireless_player
action: media_player.play_media
enabled: false
- action: automation.trigger
metadata: {}
data:
skip_condition: true
target:
entity_id: automation.shropshire_live_on_wireless
enabled: false
- action: automation.trigger
metadata: {}
data:
skip_condition: true
target:
entity_id: automation.shropshire_live_on_wireless
default: []
mode: single
And the stop one
alias: Stop Radio
description: ""
trigger:
- platform: state
entity_id: input_button.stop_radio
condition: []
action:
- data: {}
target:
entity_id:
- media_player.home_group
- media_player.office_speaker_3
- media_player.kitchen_speaker
- media_player.office_wireless
- media_player.fred
- media_player.wireless_player
action: media_player.media_stop
mode: single
You will need to change speakers and stations obviously unless you like dodgy local radio from north midlands.
And the code for the whole dash board card
type: grid
cards:
- type: entities
entities:
- entity: input_select.radio_stations
- entity: input_select.speakers
- type: tile
entity: input_button.radio_play
name: Play
tap_action:
action: toggle
- type: tile
entity: input_button.stop_radio
name: Stop
tap_action:
action: toggle
- type: conditional
conditions:
- condition: state
entity: media_player.media_players
state: "on"
card:
type: custom:auto-entities
card:
type: entities
state_color: true
filter:
include:
- group: media_player.media_players
state: playing
exclude: []
- type: tile
entity: input_boolean.llanyblodewel_flood
name: Llanyblodwel Flood
icon: ""
visibility:
- condition: state
entity: input_boolean.llanyblodewel_flood
state: "on"
- type: tile
entity: input_boolean.maesbrook_flood
name: Maesbrook Flood
visibility:
- condition: state
entity: input_boolean.maesbrook_flood
state: "on"
- type: markdown
content: "{{states('sensor.low_battery_devices')}}"
title: Low batteries
visibility:
- condition: state
entity: sensor.low_battery_devices
state_not: unavailable
Try it see how you get on
Arh
October 2, 2024, 3:31pm
7
Just realised there is other code for that card about flood and batteries.
Here it is properly.
type: grid
cards:
- type: entities
entities:
- entity: input_select.radio_stations
- entity: input_select.speakers
- type: tile
entity: input_button.radio_play
name: Play
tap_action:
action: toggle
- type: tile
entity: input_button.stop_radio
name: Stop
tap_action:
action: toggle
- type: conditional
conditions:
- condition: state
entity: media_player.media_players
state: "on"
card:
type: custom:auto-entities
card:
type: entities
state_color: true
filter:
include:
- group: media_player.media_players
state: playing
exclude: []
santaklon
(Nicolas)
October 2, 2024, 3:54pm
8
Amazing, thank you so much!
I’ll sit down, try to understand it all and adapt it to my needs.