Trigger <input_select> Choose <input_select>.<options>

I have an input_select that stores a number of states. When something changes the value of the input_select, I want to trigger an automation.

However, I don’t care what the value was (from) or what the value is not (to). I want to use a choose based on the value of the input_select.option.

Choose was described last night to be like a JavaScript switch, but that doesn’t appear to be the case as each case or conditions as Choose calls them are not based on a common expression.

I know the syntax isn’t correct. This is just trying to explain what I want to do:

automation:
  - trigger:
    <input_select>: value changes

    action:
      - choose: <input_select>.<select_option>
          - condition: this
            sequence:
              - service:

          - condition: that
            sequence:
              - service:

          - condition: other
            sequence:
              - service:

        default:
            sequence:
              - service:

Simply trying to find the most optimal way - without repeating the same thing over and over.
Any advice would be great.

trigger:
  platform: state
  entity_id: input_select.something
- choose:
    - conditions:
        - condition: state 
          entity_id: input_select.something
          state: option_that_you_want_to_act_on

Thanks Marc. I’ll give that a try…

1 Like

So that appears to have worked. However, for some reason I can’t get a button to change the value of the input_select.

type: button
tap_action:
  - service: input_select.select_option
    data:
      entity_id: input_select.office_light_state
      option: 'off'
entity: light.office
name: 'Off'
icon: 'mdi:power-on'

.

I think in lovelace you have to use service_data instead of data.

That didn’t work unfortunately…