Use InputSelect as a custom built component

Is it possible to build an InputSelect based component? or utilize that functionality in another component?

For example, I’d like top build a component that provides a list of drop downs and not require them to be manually configured. Figured I’d ask since I dont see any examples.

You can populate the input_select based on attributes from another component. Is this what you are looking for?

For example I pull my playlists from a Sonos media_player attribute and populate the input_select when there’s changes. I can post an example later if you’re interested.

3 Likes

Well close… I need a specific set of values as an input select… it pertains to a list of pre-set light themes for a pool light… when you turn the light on you have to pass a value of what color you want it to be… there are 12 options that the light supports and they are strings like Emerald Green or Disco Party… so essentially I’d like my pool automation component that I’m building to present a ‘Choose Pool Light Color’ entity.

Any developers looking at this?

@Jer78can you please share your code sample?

@martindybal

Hi Martin,

Here’s the example I was referring to earlier. I use the rest_command to populate the lists from a Sonos speaker into the input_select. You’ll just need to create a Long Lived Access Token and paste it below. For the long lived access token, you can create one from the Profile area and scroll to the bottom. Also, I populate multiple input_selects at the same time, but you can shorten it to just one input_select if that’s all you need. Let me know if you need any help setting it up.

rest_command:
  update_sonos_playlists:
    url: "http://localhost:8123/api/services/input_select/set_options"
    method: POST
    headers:
      content-type: application/json
      authorization: Bearer REPLACE-WITH-LONG-LIVED-TOKEN-HERE
    content_type: application/json
    payload: >-
      {
        "entity_id": [
          "input_select.options_morning_music", "input_select.options_morning_music_sunday", "input_select.options_morning_music_monday", "input_select.options_morning_music_tuesday", "input_select.options_morning_music_wednesday", "input_select.options_morning_music_thursday", "input_select.options_morning_music_friday", "input_select.options_morning_music_saturday", "input_select.options_morning_music_guest", "input_select.options_all_speakers_source", "input_select.options_dinner_music_source", "input_select.options_vacation_music", "input_select.options_night_music"
        ],
        "options": [
      {%- for item in state_attr('media_player.sonos_living_room', 'source_list') %}
          "{{item}}"{% if not loop.last %}, {% endif %}
      {%- endfor %}
        ]
      }
1 Like

Curious if you ever found a way to do an InputSelect in an integration.
Just finished another pool integration myself and bumped into the same issue. For the pool lights using light.color_effects solved it. But then I had to choose a heater for the pool or spa… WaterHeater.operation_mode did the trick but not easily. Left with a few things like “pump speed settings” or “chemistry set points” that would be perfect as an InputNumber but I can’t implement for now. I don’t fully understand what makes some entities easy to derived from and some not…

No I’m not