Input select - Select next getting stuck while cycling through options

I’ve got a few SmartThings buttons and I’ve got some SmartLife bulbs that I’m working with.

I set up 3 input_select lists with the RGB values that I’d like to cycle through.

In my configuration.yaml:

input_select:
  red_color:
    options:
      - 255
      - 255
      - 255
      - 239
      - 119
      - 70
      - 0
      - 0
      - 0
      - 255
  green_color:
    options:
      - 239
      - 96
      - 71
      - 70
      - 70
      - 144
      - 255
      - 255
      - 255
      - 174
  blue_color:
    options:
      - 72
      - 71
      - 129
      - 255
      - 255
      - 255
      - 255
      - 106
      - 0
      - 0

I setup an automation to use the button triggers and cycle through the RGB values from these lists.

- id: '1642148439200'
  alias: Lights Control (Automation)
  description: ''
  trigger:
  - platform: state
    entity_id: sensor.button_click
    to: double
    id: double
  condition: []
  action:
  - service: light.turn_on
    target:
      entity_id: light.lamp
    data:
      rgb_color:
      - '{{ states(''input_select.red_color'') }}'
      - '{{ states(''input_select.green_color'') }}'
      - '{{ states(''input_select.blue_color'') }}'
  - service: input_select.select_next
    target:
      entity_id:
      - input_select.red_color
      - input_select.green_color
      - input_select.blue_color
  mode: single

Everything works perfectly fine when the lists only have a max of 3 values - it will cycle through 1 - 3 for as many times as the buttons are pressed. Anything beyond 3, it will get stuck on the 4th option.

Even if I manually change the bulb colour and then I try use the automation again, it starts by the 4th option but at the same time won’t go through the next options.

I have tried switching the order of the RGB values, I have tried a normal list with colour names instead of RGB values, but still get the same behaviour.

I have also since moved this automation to a script (to do a bit more logic) but even in the script, it behaves the same.

There’s no errors on the log output so I don’t even know where to begin to debug.

You could look at the automation trace to see if there are any clues as to what is happening.

Thank you, that is actually something I didn’t think of! Will give it a go :slight_smile:

No luck unfortunately.

I even added a persistent notification to output the RGB values both before and after the automation is run, and the values remain the same.

@tom_l Just wanted to thank you for trying to help solve the issue.

I ended up asking on the Discord server and was able to get help from another mod (RobC).

It appears it could be an issue with the input_select, so I’ve logged an issue with HA Core.

# Input select - Select next getting stuck with duplicate items #64161

In the meantime, I have managed to find a different solution (also with help from RobC) for my use case.

I created an input_number:

With an automation:

alias: Lights Control (Automation v1)
description: ''
trigger:
  - platform: state
    entity_id:
      - sensor.bedroom_button_click
      - sensor.living_room_button_click
    to: single
    id: single
condition: []
action:
  - service: script.set_lights_colour
    data:
      button_id: '{{ trigger.to_state.entity_id }}'
mode: single

And finally my script:

set_lights_colour:
  variables:
    red_colour: [255, 255, 255, 239, 119, 70, 0, 0, 0, 255]
    green_colour: [239, 96, 71, 70, 70, 144, 255, 255, 255, 174]
    blue_colour: [72, 71, 129, 255, 255, 255, 255, 106, 0, 0]
    button_area: "{{ area_name(button_id) }}"
    cur_index: "{{ states('input_number.rgb_index')|int }}"
    rgb_max: "{{ state_attr('input_number.rgb_index', 'max')|int }}"
    rgb_min: "{{ state_attr('input_number.rgb_index', 'min')|int }}"

  sequence:
    - service: light.turn_on
      data_template:
        entity_id: >
          {% if button_area == 'Bedroom' %}
            group.bedroom_lights
          {% elif button_area == 'Living Room' %}
            group.living_room_lights
          {% endif %}
        rgb_color:
          - "{{ red_colour[cur_index] }}"
          - "{{ green_colour[cur_index] }}"
          - "{{ blue_colour[cur_index] }}"
        brightness_pct: 100

    - service: input_number.set_value
      data:
        entity_id: input_number.rgb_index
        value: >
          {% if cur_index == rgb_max %}
            {{ rgb_min }}
          {% else %}
            {{ (cur_index + 1) }}
          {% endif %}
1 Like