Problem using input_select based script

Hi,

I’m trying to extent my “Wakeup Light with Radio” automation by adding a selector for different radio streams.
First I tried to code a script (for testing purposes) but I can’t get it to work.

input_select entry:

input_select:
  radio_station:
    name: Radio Station
    options:
      - Radio 538
      - Q-Music
      - 3FM
    initial: Radio 538
    icon: mdi:radio

Script:

  radio538:
    alias: Play Radio538 on Chromecast Audio
    sequence:
      - alias: Start stream
        service: media_player.play_media
        data:
          entity_id: media_player.cc_audio
          media_content_id: >
            {% if is_state("input_select.radio_station", "Radio 538") %} 'http://vip-icecast.538.lw.triple-it.nl:80/RADIO538_MP3'
            {%-elif is_state("input_select.radio_station", "Q-Music") %} 'http://icecast-qmusic.cdp.triple-it.nl/Qmusic_nl_live_96.mp3'
            {%-elif is_state("input_select.radio_station", "3FM") %} 'http://icecast.omroep.nl/3fm-bb-mp3'
            {% endif %}
          media_content_type: 'audio/mp4' 

Input selector shows up in my frontend but does not play when I execute the script. Chromecast is activated.
All 3 streams work fine seperately. There are also no errors in my log file.

Help is appreciated.

Replace data with data_template for starters. Without looking too closely at the rest of the code, that might just be enough to get it to work.

1 Like

I changed data to data_template, initially it didn’t work but after deleting the 2 " around the URL’s it works!
Thanks.

1 Like

Happy to help :slight_smile:

Hey @Bob_NL - I’m glad you got this sorted out. I moved your post to “Configuration” as “Share Your Projects” is typically for sharing completed working projects that others can learn from like tutorials.

Not a biggie, just wanted to point it out.

No problem, I’ll keep that in mind in future posts

1 Like