Device / radio selection automations issues

Hey everyone,

I’m currently working on automating my openhasp screen to perform a few tasks. Primarily, I want it to allow users to select from two Chromecast devices along with the grouped option. Additionally, I want users to be able to select their preferred radio station.

Initially, I had some success with the code for selecting devices. However, when I added the option to select the radio station, nothing seems to happen (except for the test message appearing in the HA Dashboard).

Could you please guide me in the right direction on how to troubleshoot and solve this issue? Your insights would be greatly appreciated!

Automation:

      - obj: "p2b4" # dropdown
        properties:
          "options": >
            {% if (state_attr('input_select.my_dropdown_selections','Living Room, Kitchen, Multi-Room ') != none and states('input_select.my_dropdown_selections') not in ['unavailable', 'unknown']) %}{%for item in state_attr('input_select.my_dropdown_selections','options')%}{{item+"\n"|e}}{%-if not loop.last%}{%-endif%}{%-endfor%}{% endif %}
          "val": >
            {% if (state_attr('input_select.my_dropdown_selections','Living Room, Kitchen, Multi-Room') != none and states('input_select.my_dropdown_selections') not in ['unavailable', 'unknown']) %}{%for item in state_attr('input_select.my_dropdown_selections','options')%}
            {{loop.index -1 if item == states('input_select.my_dropdown_selections') }}
            {%-endfor%}{% endif %}
        event:
          "changed":
            - service: input_select.select_option
              data:
                option: '{{ text }}'
              target:
                entity_id: input_select.my_dropdown_selections
            - service: persistent_notification.create
              data:
                message: Selected {{ text }}
            - service: script.play_media_based_on_selection
              data:
                selected_entity: >
                  {% if text == 'Living Room' %}
                    media_player.living_room_speaker
                  {% elif text == 'Kitchen' %}
                    media_player.chromecastaudio6512
                  {% elif text == 'Multi-Room' %}
                    media_player.13_group
                   {% endif %}
            

      - obj: "p2b5" # radio dropdown
        properties:
          "options": >
            {% if (state_attr('input_select.radio_dropdown_selections','Opus, DE Radio') != none and states('input_select.radio_dropdown_selections') not in ['unavailable', 'unknown']) %}
              {% for item in state_attr('input_select.radio_dropdown_selections','options') %}
                {{ item + "\n"|e }}
                {%- if not loop.last %}
                  {%- endif %}
              {%- endfor %}
            {% endif %}
          "val": >
            {% if (state_attr('input_select.radio_dropdown_selections','Opus, DE Radio') != none and states('input_select.radio_dropdown_selections') not in ['unavailable', 'unknown']) %}
              {% for item in state_attr('input_select.radio_dropdown_selections','options') %}
                {{ loop.index - 1 if item == states('input_select.radio_dropdown_selections') }}
              {%- endfor %}
            {% endif %}
        event:
          "changed":
            - service: input_select.select_option
              data:
                option: '{{ text }}'
              target:
                entity_id: input_select.radio_dropdown_selections
            - service: persistent_notification.create
              data:
                message: Selected {{ text }}
            - service: script.play_radio_based_on_selection
              data:
                selected_radio: >
                  {% if text == 'Opus' %}
                    http://lrt-cast.lrt.lt:8000/lrt_opus
                  {% elif text == 'DE Radio' %}
                    http://stream.spreeradio.de/spree-live/mp3-192/radio-browser.info/
                  {% endif %}

Script that I use:

play_radio_based_on_selection:
  sequence:
    - service: media_player.play_media
      data_template:
        entity_id: "{{ selected_entity }}"
        media_content_id: "{{ selected_radio }}" 
        media_content_type: "audio/mpeg"