Use input_select as selector.select.options in a script

Hey guys,

I’m currently using a fixed list in a script for the select-options in a selector.

Can I somehow use the option defined in an input_select instead?

That’s the yaml of the script:

fields:
  room:
    name: Room
    required: true
    example: living_room
    selector:
      select:
        options:
          - bathroom
          - bedroom
          - hallway
          - kitchen
          - living_room
          - patricia_s_room
          - stairway_landing

Do you want to use the currently selected option, or full list of available options?

I know I’m doing something incorrectly, but I just cannot get the selector.select.options working. My full, but incomplete, script is below.

I get the error Array has too many items. Expected 1 or fewer. to the right of the next section, but the error highlighting starts at - Google

The error message goes away if I remove the second selection, namely - Sonos
The location of the selector does not matter. Meaning I can put it anywhere in the fields and I get the error.

door_chime:
  variables:
    default_volume: input_number.announcement_volume
  fields:
    player:
      name: Media Player
      description: Play on Sonos or Google
      required: false
      default: 'Google'
      selector:
        select:
          options:
            - Google
            - Sonos
    sound:
      name: Sound File
      description: The sound to play
      example: matrixxx__ping.wav
      required: false
      default: 'matrixxx__ping.wav'
      selector: 
        text:
    volume:
      name: Volume
      description: The volume at which to play the sound
      example: '0.5'
      required: false
      default: '{{ default_volume }}'
      selector:
        number:
          min: 0
          max: 1
          step: 0.1
          mode: slider
  sequence:
  - condition: state
    entity_id: input_boolean.audible_notifications
    state: 'on'
  - service: media_player.volume_set
    target:
      entity_id: media_player.home_group
    data:
      volume_level: template
      value_template: '{{ volume }}'
  - service: media_player.play_media
    target:
      entity_id: media_player.home_group
    data:
      media_content_id: /local/sounds/matrixxx__ping.wav
      media_content_type: music/wav
  - delay:
      hours: 0
      minutes: 0
      seconds: 5
      milliseconds: 0
  - service: media_player.volume_set
    target:
      entity_id: media_player.home_group
    data:
      volume_level: 0.25
  mode: single
  alias: Door Chime
  icon: mdi:bell-ring

I’m struggling to do the same thing as @RubenKelevra. Did you ever figure it out?

I want to replace the list of options in the field selector with an object (an input_select or even a template) containing a list of items. This list will then be shown when users click on the dropdown menu when running the script. But I can’t seem to figure out a way to do this.

Wondering if this is has been figured out. I’d like to do the same. Keep a list of selector options centrally in an input select helper and use that in different scripts and automations.

It’s a bit of a hack, but you can use a State Selector with the Input Select or Select entity specified:

alias: Example using Select options in Selector
description: ""
fields:
  test:
    required: true
    selector:
      state:
        entity_id: input_select.bin_type
    name: testing
    description: a selector of bins
sequence:
  - action: persistent_notification.create
    metadata: {}
    data:
      message: "{{ test }}"
1 Like

Thank you @Didgeridrew - that did it! Much appreciated.

Small nitpick, doing it this way includes two unintended options in my dropdown menu along with my main options, one is a blank spot and the other is “unavailable”. I can live with this, but any way to avoid it? Possible bug?

Thanks again.

AFAIK there is no way to get rid off those, it’s just the normal operation of a State selector.

1 Like