Input_select based on another input_select

So i’m trying to make an input_select based on the selection of another input select.


   name: media type
     - video
     - radio
     - music

Based on this selection i would like to be able to present a “second” input_select with the specific option.

Is this possible? If so can you give me a small exemple?

Best regards

if you mean a dynamic list in input_select I’m not sure it’s possible.
What you may need to do is 3 sub input_select lists and have one displayed based on the first input select option, other being hidden.
Look for the the set_visibility service:

So what you sugesti, and based on my exemple, is 4 input_select.

One as on my exemple, and three other with the input_select for each option.

And then play with the:
visible: False/True

PS: Yes i wanted a dinamic input_select based on another :slight_smile:

Did i get it right?

that’s exactly what I meant :slight_smile:

You can definitely change the options for a given input_select. Not exactly sure what you want the second input_select options to be, but you could do something like this:

  name: media type
      - video
      - radio
      - music
      - initial option 1
      - initial option 2
  - alias: change select2
      platform: state
      entity_id: input_select.media_type
      service: input_select.set_options
        entity_id: input_select.select2
        options: >
          {% if trigger.to_state.state == 'video' %}
            ["option 1 for video", "option 2 for video"]
          {% elif trigger.to_state.state == 'radio' %}
            ["option 1 for radio", "option 2 for radio"]
          {% else %}
            ["option 1 for music", "option 2 for music"]
          {% endif %}

Or did I misunderstand what you want to do?

1 Like

I love it when I’m wrong and I learn new things :slight_smile:

1 Like

Yes it’s something like that but more customization like:
{% if trigger.to_state.state == ‘video’ %}
link’s to all files on a movies directory
{% elif trigger.to_state.state == ‘radio’ %}
a static list/url
{% else %}
content of a music directory
{% endif %}

I’ll give it a few hours of testing and then try to report back :slight_smile:

Hi - did you ever get this working? I am trying something very similar, but it seems like data_template just doesn’t work for set_options…

It seems that I cannot use any template within the actual data. e.g.

["NotSet", "{{[0].name }}"]

I saw someone do exactly that in another post. Are you using data_template (as opposed to data)? What error are you seeing? It would help if you posted more of the context.

Apologies, I just meant to provide my recent conclusion - that you can’t use a template to construct the actual ‘options’.

I made a separate topic with all my details here - Using templates for input_select.set_options (populating options within an input selector)

And yep - definitely using data_template

Hi guy, did you succeed?