Input select

The Input select integrationIntegrations connect and integrate Home Assistant with your devices, services, and more. [Learn more] allows the user to define a list of values that can be selected via the frontend and can be used within conditions of an automation. When a user selects a new item, a state transition event is generated. This state event can be used in an automation trigger.

The preferred way to configure an input select is via the user interface at Settings > Devices & services > Helpers. Click the add button and then choose the Dropdown option.

To be able to add Helpers via the user interface you should have default_config: in your configuration.yamlThe configuration.yaml file is the main configuration file for Home Assistant. It lists the integrations to be loaded and their specific configurations. In some cases, the configuration needs to be edited manually directly in the configuration.yaml file. Most integrations can be configured in the UI. [Learn more], it should already be there by default unless you removed it. If you removed default_config: from you configuration, you must add input_select: to your configuration.yaml first, then you can use the UI.

Input selects can also be configured via configuration.yamlThe configuration.yaml file is the main configuration file for Home Assistant. It lists the integrations to be loaded and their specific configurations. In some cases, the configuration needs to be edited manually directly in the configuration.yaml file. Most integrations can be configured in the UI. [Learn more]:

# Example configuration.yaml entry
input_select:
  who_cooks:
    name: Who cooks today
    options:
      - Paulus
      - Anne Therese
    initial: Anne Therese
    icon: mdi:panda
  living_room_preset:
    options:
      - Visitors
      - Visitors with kids
      - Home Alone

Configuration Variables

input_select map Required

Alias for the input. Multiple entries are allowed.

options list Required

List of options to choose from.

name string (Optional)

Friendly name of the input.

initial map (Optional)

Initial value when Home Assistant starts.

Default:

First element of options

icon icon (Optional)

Icon to display in front of the input element in the frontend.

Note

Because YAML defines booleans as equivalent, any variations of ‘On’, ‘Yes’, ‘Y’, ‘Off’, ‘No’, or ‘N’ (regardless of case) used as option names will be replaced by True and False unless they are defined in quotation marks.

Restore state

If you set a valid value for initial this integration will start with the state set to that value. Otherwise, it will restore the state it had prior to Home Assistant stopping.

Actions

This integration provides three actions to modify the state of the input_select.

Action Data Description
select_option option This can be used to select a specific option.
set_options options
entity_id(s)
Set the options for specific input_select entities.
select_first Select the first option.
select_last Select the last option.
reload Reload input_select configuration

Action input_select.select_next

Select the next option.

Data attribute Optional Description
cycle yes Whether to cycle to the first value after the last. Default: true

Action input_select.select_previous

Select the previous option.

Data attribute Optional Description
cycle yes Whether to cycle to the last value before the first. Default: true

Scenes

Specifying a target option in a Scene is simple:

# Example configuration.yaml entry
scene:
  - name: Example1
    entities:
      input_select.who_cooks: Paulus

The list of options can also be set in a Scene. In that case, you also need to specify what the new state will be.

# Example configuration.yaml entry
scene:
  - name: Example2
    entities:
      input_select.who_cooks:
        options:
          - Alice
          - Bob
          - Paulus
        state: Bob

Automation examples

The following example shows the usage of the input_select.select_option action in an automation:

# Example configuration.yaml entry
automation:
  - alias: "example automation"
    triggers:
      - trigger: event
        event_type: MY_CUSTOM_EVENT
    actions:
      - action: input_select.select_option
        target:
          entity_id: input_select.who_cooks
        data:
          option: "Paulus"

To dynamically set the input_select options you can call input_select.set_options in an automation:

# Example configuration.yaml entry
automation:
  - alias: "example automation"
    triggers:
      - trigger: event
        event_type: MY_CUSTOM_EVENT
    actions:
      - action: input_select.set_options
        target:
          entity_id: input_select.who_cooks
        data:
          options: ["Item A", "Item B", "Item C"]

Example of input_select being used in a bidirectional manner, both being set by and controlled by an MQTT action in an automation.

# Example configuration.yaml entry using 'input_select' in an action in an automation
   
# Define input_select
input_select:
  thermostat_mode:
    name: Thermostat Mode
    options:
      - "auto"
      - "off"
      - "cool"
      - "heat"
    icon: mdi:target

# Automation.     
 # This automation script runs when a value is received via MQTT on retained topic: thermostatMode
 # It sets the value selector on the GUI. This selector also had its own automation when the value is changed.
- alias: "Set Thermostat Mode Selector"
  triggers:
    - trigger: mqtt
      topic: "thermostatMode"
   # entity_id: input_select.thermostat_mode
  actions:
    - action: input_select.select_option
      target:
        entity_id: input_select.thermostat_mode
      data:
        option: "{{ trigger.payload }}"

 # This automation script runs when the thermostat mode selector is changed.
 # It publishes its value to the same MQTT topic it is also subscribed to.
- alias: "Set Thermostat Mode"
  triggers:
    - trigger: state
      entity_id: input_select.thermostat_mode
  actions:
    - action: mqtt.publish
      data:
        topic: "thermostatMode"
        retain: true
        payload: "{{ states('input_select.thermostat_mode') }}"