Toggle through input_select option light scenes

hello
i have setup a input_select to pick scenes

- alias: LichtWohnzimmer                            
  initial_state: true
  trigger:
  - platform: state
    entity_id:
    - input_select.szenen_wohnzimmer
  action:
  - service: scene.turn_on
    data_template:
      entity_id: >
        {% if trigger.entity_id == 'input_select.szenen_wohnzimmer' %}
          {% if trigger.to_state.state == 'Normal' %}
            scene.normal
          {% elif trigger.to_state.state == 'Abends' %}
            scene.abends
          {% elif trigger.to_state.state == 'Pink' %}
            scene.pink
          {% elif trigger.to_state.state == 'Hell' %}
            scene.hell
          {% elif trigger.to_state.state == 'Blau' %}
            scene.blau
          {% elif trigger.to_state.state == 'FrĂĽhling' %}
            scene.fruehling
          {% else %}
            scene.aus
          {% endif %}
        {% endif %}

this is working ok.
now i want to toggle through the input_select options with an Aqara switch. but this automation is not working.

- id: Aqara Schalter 2 linke Schaltflaeche kurz
  alias: Licht szenen togglen
  trigger:
  - platform: mqtt
    topic: zigbee2mqtt/xiaomi_schalter_wohnzimmer
  condition:
  - condition: template
    value_template: '{{ "left" == trigger.payload_json.click }}'
  action:
    service: input_select.select_option
    data_template:
      entity_id: >
        {% if is_state("input_select.szenen_wohnzimmer", "Normal" )%}
          'Abends'
        {% elif is_state("input_select.szenen_wohnzimmer", "Abends" )%}
          'Pink'
        {% elif is_state("input_select.szenen_wohnzimmer", "Pink" )%}
          'Hell'
        {% elif is_state("input_select.szenen_wohnzimmer", "Hell" )%}
          'Normal'
        {% endif %}

where is the mistake in this automation? is there another way to handle this?

This service input_select.set_option requires:

entity_id:
option:

Your automation lacks one of the two and also uses a template to set the wrong one.

Replace the automation’s action with this:

  action:
    service: input_select.select_option
    data_template:
      entity_id: input_select.szenen_wohnzimmer
      option:
        {% if is_state("input_select.szenen_wohnzimmer", "Normal" )%}
          'Abends'
        {% elif is_state("input_select.szenen_wohnzimmer", "Abends" )%}
          'Pink'
        {% elif is_state("input_select.szenen_wohnzimmer", "Pink" )%}
          'Hell'
        {% elif is_state("input_select.szenen_wohnzimmer", "Hell" )%}
          'Normal'
        {% endif %}

NOTE
There is another service called input_select.select_next that selects the next option in the list. Each time you execute the service, it selects the next option. It seems like what you want except that you cannot limit it to use less than all available options. For example, your input_select appears to have at least 5 or 6 options. However, your automation only steps through 4 of them. That requirement prevents the use of input_select.select_next.

1 Like

@123
works perfect, thank you

- id: Aqara Schalter 2 linke Schaltflaeche kurz
  alias: Licht szenen togglen
  trigger:
  - platform: mqtt
    topic: zigbee2mqtt/xiaomi_schalter_wohnzimmer
  condition:
  - condition: template
    value_template: '{{ "left" == trigger.payload_json.click }}'
  action:
    service: input_select.select_next
    entity_id: input_select.szenen_wohnzimmer
1 Like