Hello Guys.
I tried to use my google mini speaker to integrate it with HA to play my favourite radio station. And I did it last days.
I decided to create switch button with the name of radio station and two icons dependant of playing status. It was working very well.
above radio station turned off
and also turned on.
to operate with volume I used the integration from HA
It was working very well, so I was decided to add another buttons with another stations
but I didn’t predict one thing - if I “turned on” any station all button has been changed, because my script shown status of media player not a stream which is currently played.
I would like to change it to “turn on” icon (yellow) --> only the station that is currently playing.
Could anybody help me with that?
my codes are shown below:
scripts.yaml
radio_357:
alias: radio 357 w salonie
sequence:
- service: media_player.play_media
data:
entity_id: media_player.mojo
media_content_id: 'https://stream.rcs.revma.com/ye5kghkgcm0uv'
media_content_type: audio/mp3
antyradio:
alias: antyradio w salonie
sequence:
- service: media_player.play_media
data:
entity_id: media_player.mojo
media_content_id: 'http://ant-waw-01.cdn.eurozet.pl:8602/;'
media_content_type: audio/mp3
meloradio:
alias: meloradio w salonie
sequence:
- service: media_player.play_media
data:
entity_id: media_player.mojo
media_content_id: 'https://n-4-9.dcs.redcdn.pl/sc/o2/Eurozet/live/meloradio.livx'
media_content_type: audio/mp3
trojka:
alias: trojka w salonie
sequence:
- service: media_player.play_media
data:
entity_id: media_player.mojo
media_content_id: 'http://mp3.polskieradio.pl:8904/;'
media_content_type: audio/mp3
switches.yaml
#virtual switches
- platform: template
switches:
radio357:
friendly_name: "Radio 357 Salon"
value_template: "{{ is_state('media_player.mojo', 'playing') }}"
turn_on:
service: script.turn_on
data:
entity_id: script.radio_357
turn_off:
service: media_player.turn_off
data:
entity_id: media_player.mojo
icon_template: >-
{% if is_state('media_player.mojo', 'playing') %}
mdi:radio
{% else %}
mdi:radio-off
{% endif %}
meloradio:
friendly_name: "MeloRadio Salon"
value_template: "{{ is_state('media_player.mojo', 'playing') }}"
turn_on:
service: script.turn_on
data:
entity_id: script.meloradio
turn_off:
service: media_player.turn_off
data:
entity_id: media_player.mojo
icon_template: >-
{% if is_state('media_player.mojo', 'playing') %}
mdi:radio
{% else %}
mdi:radio-off
{% endif %}
antyradio:
friendly_name: "AntyRadio Salon"
value_template: "{{ is_state('media_player.mojo', 'playing') }}"
turn_on:
service: script.turn_on
data:
entity_id: script.antyradio
turn_off:
service: media_player.turn_off
data:
entity_id: media_player.mojo
icon_template: >-
{% if is_state('media_player.mojo', 'playing') %}
mdi:radio
{% else %}
mdi:radio-off
{% endif %}
program3:
friendly_name: "Program3 Salon"
value_template: "{{ is_state('media_player.mojo', 'playing') }}"
turn_on:
service: script.turn_on
data:
entity_id: script.trojka
turn_off:
service: media_player.turn_off
data:
entity_id: media_player.mojo
icon_template: >-
{% if is_state('media_player.mojo', 'playing') %}
mdi:radio
{% else %}
mdi:radio-off
{% endif %}