Hello guys,
this is my setup.
Below screenshot is from Tileboard which I am using as wall mount HA control panel.
Config:
4 input_booleans for station selection
media player - chromecast mini
Automation - this will turn on/off radio and switch between stations
- id: "Radio_manual"
alias: "Radio Manual"
initial_state: true
trigger:
- platform: state
entity_id: input_boolean.station_1, input_boolean.station_2, input_boolean.station_3, input_boolean.station_4
to: 'on'
condition:
- condition: template
value_template: '{{ states | selectattr("entity_id","in", ["input_boolean.station_1", "input_boolean.station_2", "input_boolean.station_3", "input_boolean.station_4"] ) |selectattr("state","eq","on") | list | count | int > 1}}'
action:
- service: input_boolean.turn_off
data_template:
entity_id: >
{% for state in states.input_boolean if state.state == 'on' and 'station' in state.entity_id %}
{% if trigger.entity_id.split('_')[2] != state.entity_id.split('_')[2] %}
{{state.entity_id}}
{% endif %}
{% endfor %}
- service: script.turn_on
data_template:
entity_id: script.radio_live
- id: "Radio_manual_1"
alias: "Radio Manual 1"
initial_state: true
trigger:
- platform: state
entity_id: input_boolean.station_1, input_boolean.station_2, input_boolean.station_3, input_boolean.station_4
to: 'off'
action:
- service: media_player.turn_off
data_template:
entity_id: media_player.chormecast_id
- id: "Radio_manual_2"
alias: "Radio Manual 2"
initial_state: true
trigger:
- platform: state
entity_id: input_boolean.station_1, input_boolean.station_2, input_boolean.station_3, input_boolean.station_4
to: 'on'
condition:
- condition: template
value_template: '{{ states | selectattr("entity_id","in", ["input_boolean.station_1", "input_boolean.station_2", "input_boolean.station_3", "input_boolean.station_4"] ) |selectattr("state","eq","on") | list | count | int == 1}}'
action:
- service: script.turn_on
data_template:
entity_id: script.radio_live
script to turn on radio BTW, this script also takes care of suppressing start beep
radio_live:
alias: "Radio live"
sequence:
# lowers volume so you do not hear the startup sound
- service: media_player.volume_set
data_template:
entity_id: media_player.chormecast_id
volume_level: 0.01
# turn off Google Home - I had to do this or else I would hear the starting sound if Google Home wasn't "off" when the turn on step runs
- service: media_player.turn_off
data_template:
entity_id: media_player.chormecast_id
# wait 1 second before turning on Google Home
- delay: 00:00:01
# turn on Google Home
- service: media_player.turn_on
data_template:
entity_id: media_player.chormecast_id
# wait 1 seconds so you don't hear the startup sound
- delay: 00:00:01
# set volume to desired level
- service: media_player.volume_set
data_template:
entity_id: media_player.chormecast_id
volume_level: 0.30
# wait 1 second
- delay: 00:00:01
- service: media_player.play_media
data_template:
entity_id: media_player.chormecast_id
media_content_id: >
{% if is_state("input_boolean.station_1", "on") %} http://us3.internet-radio.com:8250/live
{% elif is_state("input_boolean.station_2", "on") %} http://fmout.spicefm.in:8000/spice_b
{% elif is_state("input_boolean.station_3", "on") %} http://51.15.208.163:8081/radio/Mirchi_love_telugu/icecast.audio
{% elif is_state("input_boolean.station_4", "on") %} http://51.15.208.163:8081/radio/MirchiTopTucker/icecast.audio
{% endif %}
media_content_type: 'music'