Radio station selection

Hi
if I try to run it I get some error

Error executing script script.radio. Invalid data for call_service at pos 1: not a valid value for dictionary value @ data['entity_id']

what I do wrong?

group:
  radio:
    name: Radio
    entities:
    - input_select.radio_station
    - input_select.chromecast_radio
    - script.radio
    - input_number.volume_radio

input_select:
  radio_station:
    name: 'Select Radio Station:'
    options:
      - Hit 92-9
      - Nova 93-7
      - Mix 94-5
      - 96FM
      - 80's
      - OldSkool Hits
      - Raw FM (dance)
      - 181FM Power (Todays Hits)
      - 181FM 90's Dance
      - 181FM Star 90's
      - 181FM The Breeze
      - Heat Radio (RnB)
      - Fresh 92-7
      - DI Chill & Tropical House
      - DI Disco House
      - DI Funky House
      - DI Liquid D&B
    initial: Raw FM (dance)
    icon: mdi:radio
    
  chromecast_radio:
    name: 'Select Speakers:'
    options:
      - kitchen_speaker
      - bedroom_speaker
      - livingroom_speaker
    initial: livingroom_speaker
    icon: mdi:speaker-wireless

input_number: 
  volume_radio:
    name: Volume
    icon: mdi:volume-high
    min: 0
    max: 1
    step: 0.05

automation:
  - alias: Listen Radio
    hide_entity: True
    trigger:
      - platform: state
        entity_id: input_select.radio_station
    action: 
      - service: script.radio
  - alias: Set Chromecast Radio Volume
    trigger:
      platform: state
      entity_id: input_number.volume_radio
    action:
      service: media_player.volume_set
      data_template:
        entity_id: >
          {% if is_state("input_select.chromecast_radio", "Kitchen") %} media_player.kitchen_speaker
          {% elif is_state("input_select.chromecast_radio", "Bedroom") %} media_player.bedroom_speaker
          {% elif is_state("input_select.chromecast_radio", "Living room") %} media_player.livingroom_speaker
          {% endif %}
        volume_level: '{{  states.input_number.volume_radio.state  }}'

script:
  radio:
    alias: Play Radio on Chromecast Audio
    sequence:
    - service: media_player.volume_set
      data_template:
        entity_id: >
          {% if is_state("input_select.chromecast_radio", "Kitchen") %} media_player.kitchen_speaker
          {% elif is_state("input_select.chromecast_radio", "Bedroom") %} media_player.bedroom_speaker
          {% elif is_state("input_select.chromecast_radio", "Living room") %} media_player.livingroom_speaker
          {% endif %}
        volume_level: '{{  states.input_number.volume_radio.state  }}' 
    - service: media_player.play_media
      data_template:
        entity_id: >
          {% if is_state("input_select.chromecast_radio", "Kitchen") %} media_player.kitchen_speaker
          {% elif is_state("input_select.chromecast_radio", "Bedroom") %} media_player.bedroom_speaker
          {% elif is_state("input_select.chromecast_radio", "Living room") %} media_player.livingroom_speaker
          {% endif %}
        media_content_id: >
          {% if is_state("input_select.radio_station", "Hit 92-9") %} http://sc01.scahw.com.au/6ppm_32
          {% elif is_state("input_select.radio_station", "Nova 93-7") %} http://streaming.novaentertainment.com.au/nova937
          {% elif is_state("input_select.radio_station", "Mix 94-5") %} http://sc01.scahw.com.au/6mix_32
          {% elif is_state("input_select.radio_station", "96FM") %} https://icy.ihrcast.arn.com.au/au_012_icy
          {% elif is_state("input_select.radio_station", "80's") %} http://streaming.the80s.com.au/;stream/1
          {% elif is_state("input_select.radio_station", "OldSkool Hits") %} http://sc01.scahw.com.au/loveland_32
          {% elif is_state("input_select.radio_station", "Raw FM (dance)") %} http://stream.rawfm.com.au:8000/;stream.nsv
          {% elif is_state("input_select.radio_station", "181FM Power (Todays Hits)") %} http://listen.181fm.com/181-power_128k.mp3?
          {% elif is_state("input_select.radio_station", "181FM 90's Dance") %} http://listen.181fm.com/181-90sdance_128k.mp3
          {% elif is_state("input_select.radio_station", "181FM Star 90's") %} http://listen.181fm.com/181-star90s_128k.mp3
          {% elif is_state("input_select.radio_station", "181FM The Breeze") %} http://listen.181fm.com/181-breeze_128k.mp3
          {% elif is_state("input_select.radio_station", "Heat Radio (RnB)") %} http://174.37.159.206:8106/stream
          {% elif is_state("input_select.radio_station", "Fresh 92-7") %} http://live.fresh927.com.au/freshmp3
          {% elif is_state("input_select.radio_station", "DI Chill & Tropical House") %} http://pub1.diforfree.org:8000/di_chillntropicalhouse_hi
          {% elif is_state("input_select.radio_station", "DI Disco House") %} http://pub1.diforfree.org:8000/di_discohouse_hi
          {% elif is_state("input_select.radio_station", "DI Funky House") %} http://pub1.diforfree.org:8000/di_funkyhouse_hi
          {% elif is_state("input_select.radio_station", "DI Liquid D&B") %} http://pub1.diforfree.org:8000/di_liquiddnb_hi
          {% endif %}
        media_content_type: 'audio/mp4'

as far as I can see your “sequence” and “- service” started at same indent, “- service” should be one step indented left after “sequence”
Try it…

You gave these options for your input select.

      - kitchen_speaker
      - bedroom_speaker
      - livingroom_speaker

You are testing for these options in your script

          {% if is_state("input_select.chromecast_radio", "Kitchen") %} media_player.kitchen_speaker
          {% elif is_state("input_select.chromecast_radio", "Bedroom") %} media_player.bedroom_speaker
          {% elif is_state("input_select.chromecast_radio", "Living room") %} media_player.livingroom_speaker
          {% endif %}

Change your input select to this.

  chromecast_radio:
    name: 'Select Speakers:'
    options:
      - Kitchen
      - Bedroom
      - Living room
    initial: livingroom_speaker
    icon: mdi:speaker-wireless

I do what you suggest. same error:anguished:

script:
  radio:
    alias: Play Radio on Chromecast Audio
    sequence:
     - service: media_player.volume_set
       data_template:
        entity_id: >
          {% if is_state("input_select.chromecast_radio", "Kitchen") %} media_player.kitchen_speaker
          {% elif is_state("input_select.chromecast_radio", "Bedroom") %} media_player.bedroom_speaker
          {% elif is_state("input_select.chromecast_radio", "Living room") %} media_player.livingroom_speaker
          {% endif %}
        volume_level: '{{  states.input_number.volume_radio.state  }}' 
     - service: media_player.play_media
       data_template:
        entity_id: >
          {% if is_state("input_select.chromecast_radio", "Kitchen") %} media_player.kitchen_speaker
          {% elif is_state("input_select.chromecast_radio", "Bedroom") %} media_player.bedroom_speaker
          {% elif is_state("input_select.chromecast_radio", "Living room") %} media_player.livingroom_speaker
          {% endif %}
        media_content_id: >
          {% if is_state("input_select.radio_station", "Hit 92-9") %} http://sc01.scahw.com.au/6ppm_32
          {% elif is_state("input_select.radio_station", "Nova 93-7") %} http://streaming.novaentertainment.com.au/nova937
          {% elif is_state("input_select.radio_station", "Mix 94-5") %} http://sc01.scahw.com.au/6mix_32
          {% elif is_state("input_select.radio_station", "96FM") %} https://icy.ihrcast.arn.com.au/au_012_icy
          {% elif is_state("input_select.radio_station", "80's") %} http://streaming.the80s.com.au/;stream/1
          {% elif is_state("input_select.radio_station", "OldSkool Hits") %} http://sc01.scahw.com.au/loveland_32
          {% elif is_state("input_select.radio_station", "Raw FM (dance)") %} http://stream.rawfm.com.au:8000/;stream.nsv
          {% elif is_state("input_select.radio_station", "181FM Power (Todays Hits)") %} 'http://listen.181fm.com/181-power_128k.mp3?'
          {% elif is_state("input_select.radio_station", "181FM 90's Dance") %} http://listen.181fm.com/181-90sdance_128k.mp3
          {% elif is_state("input_select.radio_station", "181FM Star 90's") %} http://listen.181fm.com/181-star90s_128k.mp3
          {% elif is_state("input_select.radio_station", "181FM The Breeze") %} http://listen.181fm.com/181-breeze_128k.mp3
          {% elif is_state("input_select.radio_station", "Heat Radio (RnB)") %} http://174.37.159.206:8106/stream
          {% elif is_state("input_select.radio_station", "Fresh 92-7") %} http://live.fresh927.com.au/freshmp3
          {% elif is_state("input_select.radio_station", "DI Chill & Tropical House") %} http://pub1.diforfree.org:8000/di_chillntropicalhouse_hi
          {% elif is_state("input_select.radio_station", "DI Disco House") %} http://pub1.diforfree.org:8000/di_discohouse_hi
          {% elif is_state("input_select.radio_station", "DI Funky House") %} http://pub1.diforfree.org:8000/di_funkyhouse_hi
          {% elif is_state("input_select.radio_station", "DI Liquid D&B") %} http://pub1.diforfree.org:8000/di_liquiddnb_hi
          {% endif %}
        media_content_type: 'audio/mp4'

i edit my code like what you write here. its doesnt work

group:
  radio:
    name: Radio
    entities:
    - input_select.radio_station
    - input_select.chromecast_radio
    - script.radio
    - input_number.volume_radio

input_select:
  radio_station:
    name: 'Select Radio Station:'
    options:
      - Hit 92-9
      - Nova 93-7
      - Mix 94-5
      - 96FM
      - 80's
      - OldSkool Hits
      - Raw FM (dance)
      - 181FM Power (Todays Hits)
      - 181FM 90's Dance
      - 181FM Star 90's
      - 181FM The Breeze
      - Heat Radio (RnB)
      - Fresh 92-7
      - DI Chill & Tropical House
      - DI Disco House
      - DI Funky House
      - DI Liquid D&B
    initial: Raw FM (dance)
    icon: mdi:radio
    
  chromecast_radio:
    name: 'Select Speakers:'
    options:
      - Kitchen
      - Bedroom
      - Living room
    initial: Kitchen
    icon: mdi:speaker-wireless

input_number: 
  volume_radio:
    name: Volume
    icon: mdi:volume-high
    min: 0
    max: 1
    step: 0.05

automation:
  - alias: Listen Radio
    hide_entity: True
    trigger:
      - platform: state
        entity_id: input_select.radio_station
    action: 
      - service: script.radio
  - alias: Set Chromecast Radio Volume
    trigger:
      platform: state
      entity_id: input_number.volume_radio
    action:
      service: media_player.volume_set
      data_template:
        entity_id: >
          {% if is_state("input_select.chromecast_radio", "Kitchen") %} media_player.kitchen_speaker
          {% elif is_state("input_select.chromecast_radio", "Bedroom") %} media_player.bedroom_speaker
          {% elif is_state("input_select.chromecast_radio", "Living room") %} media_player.livingroom_speaker
          {% endif %}
        volume_level: '{{  states.input_number.volume_radio.state  }}'

script:
  radio:
    alias: Play Radio on Chromecast Audio
    sequence:
     - service: media_player.volume_set
       data_template:
        entity_id: >
          {% if is_state("input_select.chromecast_radio", "Kitchen") %} media_player.kitchen_speaker
          {% elif is_state("input_select.chromecast_radio", "Bedroom") %} media_player.bedroom_speaker
          {% elif is_state("input_select.chromecast_radio", "Living room") %} media_player.livingroom_speaker
          {% endif %}
        volume_level: '{{  states.input_number.volume_radio.state  }}' 
     - service: media_player.play_media
       data_template:
        entity_id: >
          {% if is_state("input_select.chromecast_radio", "Kitchen") %} media_player.kitchen_speaker
          {% elif is_state("input_select.chromecast_radio", "Bedroom") %} media_player.bedroom_speaker
          {% elif is_state("input_select.chromecast_radio", "Living room") %} media_player.livingroom_speaker
          {% endif %}
        media_content_id: >
          {% if is_state("input_select.radio_station", "Hit 92-9") %} http://sc01.scahw.com.au/6ppm_32
          {% elif is_state("input_select.radio_station", "Nova 93-7") %} http://streaming.novaentertainment.com.au/nova937
          {% elif is_state("input_select.radio_station", "Mix 94-5") %} http://sc01.scahw.com.au/6mix_32
          {% elif is_state("input_select.radio_station", "96FM") %} https://icy.ihrcast.arn.com.au/au_012_icy
          {% elif is_state("input_select.radio_station", "80's") %} http://streaming.the80s.com.au/;stream/1
          {% elif is_state("input_select.radio_station", "OldSkool Hits") %} http://sc01.scahw.com.au/loveland_32
          {% elif is_state("input_select.radio_station", "Raw FM (dance)") %} http://stream.rawfm.com.au:8000/;stream.nsv
          {% elif is_state("input_select.radio_station", "181FM Power (Todays Hits)") %} "http://listen.181fm.com/181-power_128k.mp3?"
          {% elif is_state("input_select.radio_station", "181FM 90's Dance") %} http://listen.181fm.com/181-90sdance_128k.mp3
          {% elif is_state("input_select.radio_station", "181FM Star 90's") %} http://listen.181fm.com/181-star90s_128k.mp3
          {% elif is_state("input_select.radio_station", "181FM The Breeze") %} http://listen.181fm.com/181-breeze_128k.mp3
          {% elif is_state("input_select.radio_station", "Heat Radio (RnB)") %} http://174.37.159.206:8106/stream
          {% elif is_state("input_select.radio_station", "Fresh 92-7") %} http://live.fresh927.com.au/freshmp3
          {% elif is_state("input_select.radio_station", "DI Chill & Tropical House") %} http://pub1.diforfree.org:8000/di_chillntropicalhouse_hi
          {% elif is_state("input_select.radio_station", "DI Disco House") %} http://pub1.diforfree.org:8000/di_discohouse_hi
          {% elif is_state("input_select.radio_station", "DI Funky House") %} http://pub1.diforfree.org:8000/di_funkyhouse_hi
          {% elif is_state("input_select.radio_station", "DI Liquid D&B") %} http://pub1.diforfree.org:8000/di_liquiddnb_hi
          {% endif %}
        media_content_type: 'audio/mp4'

Did you restart Home Assistant? You’ve changed an entity so you need to restart for it to register the change.

If you have restarted, what error do you get now?

yes its work great.
now the new issue is how i add stop media button ?
i try input it as a service
but i no see the button
how i will do it ?

group:
  radio:
    name: Radio
    entities:
    - input_select.radio_station
    - input_select.chromecast_radio
    - script.radio
    - input_number.volume_radio

input_select:
  radio_station:
    name: 'Select Radio Station:'
    options:
      - GalGalatz
      - Galatz
      - Radius 100FM
      - Echo 99FM
      - Kan 88FM
      - 103FM
      - Lev Hamedina 91FM
      - Reshet Gimel
      - Radio Darom
      - Kol Hayam Haadom 102FM
    initial: GalGalatz
    icon: mdi:radio
    
  chromecast_radio:
    name: 'Select Speakers:'
    options:
      - Kitchen
      - Bedroom
      - Living room
    initial: Kitchen
    icon: mdi:speaker-wireless

input_number: 
  volume_radio:
    name: Volume
    icon: mdi:volume-high
    min: 0
    max: 1
    step: 0.05

automation:
  - alias: Listen Radio
    hide_entity: True
    trigger:
      - platform: state
        entity_id: input_select.radio_station
    action: 
      - service: script.radio
  - alias: Set Chromecast Radio Volume
    trigger:
      platform: state
      entity_id: input_number.volume_radio
    action:
      service: media_player.volume_set
      data_template:
        entity_id: >
          {% if is_state("input_select.chromecast_radio", "Kitchen") %} media_player.kitchen_speaker
          {% elif is_state("input_select.chromecast_radio", "Bedroom") %} media_player.bedroom_speaker
          {% elif is_state("input_select.chromecast_radio", "Living room") %} media_player.livingroom_speaker
          {% endif %}
        volume_level: '{{  states.input_number.volume_radio.state  }}'

script:
  radio:
    alias: Play Radio on Chromecast Audio
    sequence:
     - service: media_player.volume_set
       data_template:
        entity_id: >
          {% if is_state("input_select.chromecast_radio", "Kitchen") %} media_player.kitchen_speaker
          {% elif is_state("input_select.chromecast_radio", "Bedroom") %} media_player.bedroom_speaker
          {% elif is_state("input_select.chromecast_radio", "Living room") %} media_player.livingroom_speaker
          {% endif %}
        volume_level: '{{  states.input_number.volume_radio.state  }}' 
     - service: media_player.media_stop
       data_template:
        entity_id: >
         {% if is_state("input_select.chromecast_radio", "Kitchen") %} media_player.kitchen_speaker
         {% elif is_state("input_select.chromecast_radio", "Bedroom") %} media_player.bedroom_speaker
         {% elif is_state("input_select.chromecast_radio", "Living room") %} media_player.livingroom_speaker
         {% endif %}
     - service: media_player.play_media
       data_template:
        entity_id: >
          {% if is_state("input_select.chromecast_radio", "Kitchen") %} media_player.kitchen_speaker
          {% elif is_state("input_select.chromecast_radio", "Bedroom") %} media_player.bedroom_speaker
          {% elif is_state("input_select.chromecast_radio", "Living room") %} media_player.livingroom_speaker
          {% endif %}
        media_content_id: >
          {% if is_state("input_select.radio_station", "GalGalatz") %} http://player.gl.bynetcdn.com/Redirector/glz/glglz/ICE-live
          {% elif is_state("input_select.radio_station", "Galatz") %} http://player.gl.bynetcdn.com/Redirector/glz/glz/ICE-live
          {% elif is_state("input_select.radio_station", "Radius 100FM") %} http://100fm.streamgates.net/Radios100Fm
          {% elif is_state("input_select.radio_station", "Echo 99FM") %} http://99.livecdn.biz/99fm_aac
          {% elif is_state("input_select.radio_station", "Kan 88FM") %} http://radiocast-rr-d.vidnt.com/ipbc_IPBC88LAM
          {% elif is_state("input_select.radio_station", "103FM") %} http://103fm.live.streamgates.net/103fm_live/1multix/icecast.audio
          {% elif is_state("input_select.radio_station", "Lev Hamedina 91FM") %} http://gb92.multix-technologies.com/Lev91Fm
          {% elif is_state("input_select.radio_station", "Reshet Gimel") %} http://radiocast-rr-d.vidnt.com/ipbc_IPBCgimmelLAM
          {% elif is_state("input_select.radio_station", "Radio Darom") %} http://audio-darom.ecast.co.il:9000/darom97fm
          {% elif is_state("input_select.radio_station", "Kol Hayam Haadom 102FM") %} http://eilat.cdnwz.net/102fm
          {% endif %}
        media_content_type: 'audio/mp4'
1 Like

Do you use lovelace? You can add a media player cards for each of your media players and use the control buttons on the card. If not let me know I’ll show you how to do it with an input boolean.

1 Like