RGB Color change on tasmota with Ikea 5 button zigbee controller

I found an workaround to use an Ikea 5 button controller with my RGB led strip controlled by tasmota via mqtt
That I need to do was use next and prev button to change color on my RGB led

I use this:
first of all create a input number

input_number:
  rgb_color:
    name: RGB Color
    icon: mdi:palette
    min: 0
    max: 360
    step: 20

next, you can use the number value to set your rgb color with this automation

- id: 'rgbw_prev'    
  alias: rgbw_prev
  initial_state: 'on'
  trigger:
   - platform: event
     event_type: deconz_event
     event_data:
       id: ctrl5buttons1
       event: 4002
  action:
   - service: input_number.set_value
     data_template:
      entity_id: input_number.rgb_color
      value: '{{ states.input_number.rgb_color.state | int - 20 }}'
   - service: mqtt.publish
     data_template:
       topic: 'cmnd/rgbw_cam/HsbColor2'
       payload: 100
   - service: mqtt.publish
     data_template:
       topic: 'cmnd/rgbw_cam/HsbColor1'
       payload: "{{ states('input_number.rgb_color') }}"

and

- id: 'rgbw_next'    
  alias: rgbw_next
  initial_state: 'on'
  trigger:
   - platform: event
     event_type: deconz_event
     event_data:
       id: ctrl5buttons1
       event: 5002
  action:
   - service: input_number.set_value
     data_template:
      entity_id: input_number.rgb_color
      value: '{{ states.input_number.rgb_color.state | int + 20 }}'
   - service: mqtt.publish
     data_template:
       topic: 'cmnd/rgbw_cam/HsbColor2'
       payload: 100
   - service: mqtt.publish
     data_template:
       topic: 'cmnd/rgbw_cam/HsbColor1'
       payload: "{{ states('input_number.rgb_color') }}"

at this point you can change color by press next and prev buttons
but you have a problem! when you reach 360 or 0 value you can only go in one way!
workaround :smiley:
with this automation when you reach 0 value on your slider at next button’s click set to 340 (0 and 360 is the same color on HSB)

- id: 'back_to_360'    
  alias: back_to_360
  initial_state: 'on'
  trigger:
  - platform: event
    event_type: deconz_event
    event_data:
      id: ctrl5buttons1
      event: 4002
  condition:
  - condition: state
    entity_id: input_number.rgb_color
    state: "0.0"
  action:
  - service: input_number.set_value
    data_template:
      entity_id: input_number.rgb_color
      value: "340"

and when is 360 go to 20

- id: 'back_to_0'    
  alias: back_to_0
  initial_state: 'on'
  trigger:
  - platform: event
    event_type: deconz_event
    event_data:
      id: ctrl5buttons1
      event: 5002
  condition:
  - condition: state
    entity_id: input_number.rgb_color
    state: "360.0"
  action:
  - service: input_number.set_value
    data_template:
      entity_id: input_number.rgb_color
      value: "20"
1 Like

I found your post while looking for a “next color” or “previous color” action. Thank you for posting this. Adjusting the hue is probably what I should do.

You can use a modulo do keep the value within the bounds as well. I would add 360 to the new result, and then do the modulo, so it would look something like this: (360 + input_number.rgb_color) % 360. Adding 360 just keeps the modulo in the positive range.

If input_number.rgb_color was -10, then it would be 350 % 360 = 350. If it was 370, it would be 730 % 360 = 10.

I’m using this for my kiddo’s light bulb. Blue means they can get out of bed. So I will have the additional challenge of skipping blue hues. I am imagining them adjusting the brightness and color before going to bed, forcing it to be a sleep friendly color after a while, and then forcing blue in the morning.