thank you very much for your support! you did a fantastic job. In the end I customized your package that I am attaching … it is a simplified version without being able to view the artist and the track but equally functional …
I just changed the fact that when you press the Stop the boolean input goes directly off and eliminated the Scrap, then as regards the reproduction instead of audio / mp4 I had to put music otherwise some radio stations did not work me. I attach the package if could be of interest to someone else
Package Radio v1.0
#################################################################
# #
# Radio #
# #
#################################################################
homeassistant:
customize:
input_number.initial_volume_radio:
icon: mdi:volume-high
input_select.chromecast_radio_station:
icon: mdi:radio
sensor.radio_selected:
icon: mdi:radio
input_select.chromecast_radio_speakers:
icon: mdi:speaker-wireless
sensor.speaker_selected:
icon: mdi:speaker-wireless
input_text.custom_station:
icon: mdi:link-variant
#################################################################
sensor:
- platform: template
sensors:
radio_selected:
value_template: '{{ states.input_select.chromecast_radio_station.state }}'
friendly_name: 'Stazione selezionata'
- platform: template
sensors:
speaker_selected:
value_template: '{{ states.input_select.chromecast_radio_speakers.state }}'
friendly_name: 'Speaker selezionato'
#################################################################
input_number:
initial_volume_radio:
name: Volume iniziale
initial: 0.3
min: 0
max: 1
step: 0.05
mode: box
#################################################################
input_select:
chromecast_radio_station:
name: 'Select Radio Station'
options:
- RDS Radio
- Radio 105
- Virgin Radio
- Radio freccia
- Custom Station
- Spenta
chromecast_radio_speakers:
name: 'Select Speakers'
options:
- Salotto
- Bagno
- Studio
- Gruppo Casa
#################################################################
input_text:
custom_station:
name: Radio URL
#################################################################
script:
play_chromecast_radio:
alias: Cast Selected Radio on Chromecast Speakers
sequence:
- service: media_player.volume_set
data_template:
entity_id: >
{% if is_state("input_select.chromecast_radio_speakers", "Salotto") %} media_player.googlehome3627
{% elif is_state("input_select.chromecast_radio_speakers", "Studio") %} media_player.googlehome5227
{% elif is_state("input_select.chromecast_radio_speakers", "Gruppo Casa") %} media_player.gruppo_casa_3
{% elif is_state("input_select.chromecast_radio_speakers", "Bagno") %} media_player.bagno
{% endif %}
volume_level: '{{ states("input_number.initial_volume_radio") }}'
- service: media_player.play_media
data_template:
entity_id: >
{% if is_state("input_select.chromecast_radio_speakers", "Studio") %} media_player.googlehome5227
{% elif is_state("input_select.chromecast_radio_speakers", "Gruppo Casa") %} media_player.gruppo_casa_3
{% elif is_state("input_select.chromecast_radio_speakers", "Salotto") %} media_player.googlehome3627
{% elif is_state("input_select.chromecast_radio_speakers", "Bagno") %} media_player.bagno
{% endif %}
media_content_id: >
{% if is_state("input_select.chromecast_radio_station", "RDS Radio") %} https://icstream.rds.radio/rds
{% elif is_state("input_select.chromecast_radio_station", "Radio 105") %} http://icecast.unitedradio.it/Radio105.mp3
{% elif is_state("input_select.chromecast_radio_station", "Virgin Radio") %} http://icecast.unitedradio.it/Virgin.mp3
{% elif is_state("input_select.chromecast_radio_station", "Radio freccia") %} https://streamingv2.shoutcast.com/radiofreccia
{% elif is_state("input_select.chromecast_radio_station", "Custom Station") %} {{states("input_text.custom_station")}}
{% endif %}
media_content_type: music
stop_chromecast_radio:
alias: Stop Playing Radio on ChomeCast
sequence:
- service: media_player.turn_off
data_template:
entity_id: >
{% if is_state("input_select.chromecast_radio_speakers", "Salotto") %} media_player.googlehome3627
{% elif is_state("input_select.chromecast_radio_speakers", "Studio") %} media_player.googlehome5227
{% elif is_state("input_select.chromecast_radio_speakers", "Gruppo Casa") %} media_player.gruppo_casa_3
{% elif is_state("input_select.chromecast_radio_speakers", "Bagno") %} media_player.bagno
{% endif %}
- service: input_select.select_option
data:
entity_id: input_select.chromecast_radio_station
option: Spenta
#################################################################
switch:
- platform: template
switches:
chromecast_radio_mute:
icon_template: '{% if states("switch.chromecast_radio_mute") %}mdi:volume-off{% else %}mdi:volume-high{% endif %}'
value_template: >
{% if is_state("input_select.chromecast_radio_speakers", "Salotto") %} {% if state_attr("media_player.googlehome3627","is_volume_muted") %}on{% else %}off{% endif %}
{% elif is_state("input_select.chromecast_radio_speakers", "Studio") %} {% if state_attr("media_player.googlehome5227","is_volume_muted") %}on{% else %}off{% endif %}
{% elif is_state("input_select.chromecast_radio_speakers", "Gruppo Casa") %} {% if state_attr("media_player.gruppo_casa_3","is_volume_muted") %}on{% else %}off{% endif %}
{% elif is_state("input_select.chromecast_radio_speakers", "Bagno") %} {% if state_attr("media_player.bagno","is_volume_muted") %}on{% else %}off{% endif %}
{% else %}off
{% endif %}
turn_on:
service: media_player.volume_mute
data_template:
entity_id: >
{% if is_state("input_select.chromecast_radio_speakers", "Salotto") %} media_player.googlehome3627
{% elif is_state("input_select.chromecast_radio_speakers", "Studio") %} media_player.googlehome5227
{% elif is_state("input_select.chromecast_radio_speakers", "Gruppo Casa") %} media_player.gruppo_casa_3
{% elif is_state("input_select.chromecast_radio_speakers", "Bagno") %} media_player.bagno
{% endif %}
is_volume_muted: true
turn_off:
service: media_player.volume_mute
data_template:
entity_id: >
{% if is_state("input_select.chromecast_radio_speakers", "Salotto") %} media_player.googlehome3627
{% elif is_state("input_select.chromecast_radio_speakers", "Studio") %} media_player.googlehome5227
{% elif is_state("input_select.chromecast_radio_speakers", "Gruppo Casa") %} media_player.gruppo_casa_3
{% elif is_state("input_select.chromecast_radio_speakers", "Bagno") %} media_player.bagno
{% endif %}
is_volume_muted: false
chromecast_radio_vol_up:
icon_template: 'mdi:volume-plus'
value_template: 'on'
turn_on:
service: media_player.volume_up
data_template:
entity_id: >
{% if is_state("input_select.chromecast_radio_speakers", "Salotto") %} media_player.googlehome3627
{% elif is_state("input_select.chromecast_radio_speakers", "Studio") %} media_player.googlehome5227
{% elif is_state("input_select.chromecast_radio_speakers", "Gruppo Casa") %} media_player.gruppo_casa_3
{% elif is_state("input_select.chromecast_radio_speakers", "Bagno") %} media_player.bagno
{% endif %}
turn_off:
service: media_player.volume_up
data_template:
entity_id: >
{% if is_state("input_select.chromecast_radio_speakers", "Salotto") %} media_player.googlehome3627
{% elif is_state("input_select.chromecast_radio_speakers", "Studio") %} media_player.googlehome5227
{% elif is_state("input_select.chromecast_radio_speakers", "Gruppo Casa") %} media_player.gruppo_casa_3
{% elif is_state("input_select.chromecast_radio_speakers", "Bagno") %} media_player.bagno
{% endif %}
chromecast_radio_vol_down:
icon_template: 'mdi:volume-minus'
value_template: 'on'
turn_on:
service: media_player.volume_down
data_template:
entity_id: >
{% if is_state("input_select.chromecast_radio_speakers", "Salotto") %} media_player.googlehome3627
{% elif is_state("input_select.chromecast_radio_speakers", "Studio") %} media_player.googlehome5227
{% elif is_state("input_select.chromecast_radio_speakers", "Gruppo Casa") %} media_player.gruppo_casa_3
{% elif is_state("input_select.chromecast_radio_speakers", "Bagno") %} media_player.bagno
{% endif %}
turn_off:
service: media_player.volume_down
data_template:
entity_id: >
{% if is_state("input_select.chromecast_radio_speakers", "Salotto") %} media_player.googlehome3627
{% elif is_state("input_select.chromecast_radio_speakers", "Studio") %} media_player.googlehome5227
{% elif is_state("input_select.chromecast_radio_speakers", "Gruppo Casa") %} media_player.gruppo_casa_3
{% elif is_state("input_select.chromecast_radio_speakers", "Bagno") %} media_player.bagno
{% endif %}
chromecast_radio_play:
icon_template: 'mdi:play'
value_template: 'on'
turn_on:
service: script.turn_on
entity_id: script.play_chromecast_radio
turn_off:
service: script.turn_on
entity_id: script.play_chromecast_radio
chromecast_radio_stop:
icon_template: 'mdi:stop'
value_template: 'on'
turn_on:
service: script.turn_on
entity_id: script.stop_chromecast_radio
turn_off:
service: script.turn_on
entity_id: script.stop_chromecast_radio
Lovelace UI
cards:
- entities:
- entity: input_select.chromecast_radio_station
- entity: input_text.custom_station
- entity: input_select.chromecast_radio_speakers
- entity: switch.chromecast_radio_vol_down
- entity: switch.chromecast_radio_mute
- entity: switch.chromecast_radio_vol_up
- entity: switch.chromecast_radio_stop
- entity: switch.chromecast_radio_play
entity: input_select.chromecast_radio_station
state_image:
Custom Station: /local/immagini/radio/customstation.jpg
RDS Radio: /local/immagini/radio/rds.jpg
Radio 105: /local/immagini/radio/105.jpg
Radio freccia: /local/immagini/radio/freccia.jpg
Spenta: /local/immagini/radio/spenta.jpg
Virgin Radio: /local/immagini/radio/virgin.jpg
type: picture-glance
- entities:
- entity: sensor.radio_selected
- entity: sensor.speaker_selected
- entity: input_number.initial_volume_radio
show_header_toggle: false
type: entities
type: vertical-stack