Use switch to cycle through RGB colors

Hi all

Apologies in advance for this no doubt noob question.

I have Shelly devices installed and would like to use a HA automation to cycle through some preset colours of my Shelly RGBW lights from a Shelly i3 switch.

I have set visual editor automations to use button combinations (1 click, 2 click, 3 click) to change them to Red, Green, Blue, but would like to use just a single click to cycle through these options instead.

I think I need to use a Helper and input_select but really not sure how to implement this. Have tried researching but haven’t seen anything that helps me yet.

I would like to be able to use the Visual Editor in automations if possible. Is this possible?

Thank you in advance. :pray:

alias: LIVING ROOM - S3 - RED
description: ""
trigger:
  - platform: device
    device_id: shellyi3
    domain: shelly
    type: single
    subtype: button3
condition: []
action:
  - service: light.turn_on
    data:
      brightness: 255
      rgbw_color:
        - 255
        - 0
        - 0
        - 0
      transition: 2
    target:
      entity_id:
        - light.living_room_shelves_left
        - light.living_room_shelves_right
        - light.living_room_record_player
mode: single

Hope you don’t mind reviving this topic. Ever have any luck with this @SuperChick3n ? I’m trying to do a similiar thing with a button. I’d like to tap a single that will cycle through multiple colors. Right now I’m using a script and a bunch of IF statements, but I can’t seem to get the color to be used as a condition. Automation triggers the script when the button is pressed.

I’ve tried the below script as well as nesting the IF statements, but can’t get passed the initial action. Lights turn on and set to orange, but will not change on the next run. Seems like I’m setting my RGB attribute and color incorrectly?

alias: Cabinet Lights test
sequence:
  - alias: If
    if:
      - condition: state
        entity_id: light.cabinet_lights
        state: "off"
        alias: If Cabinet Lights are off...
    then:
      - alias: Set to Orange
        service: light.turn_on
        target:
          entity_id: light.cabinet_lights
        data:
          rgb_color:
            - 255
            - 147
            - 0
    else: []
  - alias: If
    if:
      - alias: If they're Orange...
        condition: state
        entity_id: light.cabinet_lights
        attribute: rgb_color
        state: 255, 147, 0
    then:
      - alias: Set to Blue
        service: light.turn_on
        target:
          entity_id: light.cabinet_lights
        data:
          rgb_color:
            - 0
            - 253
            - 255
          effect: colorloop
    else: []
  - alias: If
    if:
      - alias: If they're Blue...
        condition: state
        entity_id: light.cabinet_lights
        attribute: rgb_color
        state: 0, 252, 255
    then:
      - alias: Set to Purple
        service: light.turn_on
        target:
          entity_id: light.cabinet_lights
        data:
          rgb_color:
            - 211
            - 87
            - 254
    else: []
  - alias: If
    if:
      - alias: If they're Purple...
        condition: state
        entity_id: light.cabinet_lights
        attribute: rgb_color
        state: 212, 91, 255
    then:
      - service: light.turn_off
        target:
          entity_id: light.cabinet_lights
        data: {}
        alias: Turn them off
    else:
      - alias: Set to Orange
        service: light.turn_on
        target:
          entity_id: light.cabinet_lights
        data:
          rgb_color:
            - 255
            - 147
            - 0
mode: single
icon: mdi:led-strip

I thought Alias is suppose to define something specific

Nah - alias is just a label in the UI. I didn’t rename that part of the action. Shouldn’t have any bearing on the function of the action.

Sorry to nudge this. Curious if anyone has had success on cycling through colors using a single trigger. Is the best way to to this to use an RGB color as a condition?

I believe some has, using i.e input-select and automation

Here is a start, if not sufficient info, you can always try the search function, the more you use search-functions on the web, the better you get to “narrow down” your search words etc.
In your case you already have the right words.

Step through colors with a single button - #3 by Dujith.

Search results for 'cycling through choose options' - Home Assistant Community.

1 Like