Combining single RGBW channels into one light

I have a LED strip (RGBW) where I can control each channel separately by defining a KNX light for every channel. I can now set every color by manually dimming those lights (ledstrip_R, ledstrip_G, ledstrip_B, ledstrip_W).

Is there any way to combine those channels into one Light entity so that I can set the color with the color picker?

Write a script that accepts 3 values. The script should use each of those values for each light. Whenever you want to set a color, call the script and supply it with the 3 values.

The last 2 examples in the link show you how to pass variables to a script.

How can I manage to call this script because I selected a color in the color picker? Can I somehow create another light entity where I can attach my script?

You can use a switch template or light template that will show up as a toggle in Home assistant. Then in the turn_on, turn_off sections of those functions, you can call a script. Iā€™m not sure if you can specify a color with those devices, but you could have a separate input_select that defines the color when those devices turn on.

This may be more than you wanted to do. But I use this fine code by BRUH to control LED strips

Put the code on an ESP8266, and then you can integrate it right into HA. If you want multiple lights to be controlled by the same entity, you just subscribe the ESP connected to each strip to the same MQTT topic. I have status lights around my house that alert me to driveway motion, door entry, water leaks, Internet outage, etc.

I can also set the color for all my LED strips via one entity in the HA UI

1 Like

Pretty cool, where did you place the LEDs in your house?

For me I only have a couple LEDs from a long strip in each ā€œfixtureā€ Here are couple pics.


Ah cool. Iā€™ll have to do something like this myself. It looks pretty handy and both of those look ā€˜wife approvedā€™.

1 Like

Credit for the models go to the authors on thingiverse.com who designed those models that I 3D printed. I definitely donā€™t have much artistic ability

Iā€™ve now found a way to solve this. I created a mqtt_json light, which is listening to a dummy topic. This will probably also work with other lights, but mqtt_json supports RGB and white channel:

- platform: mqtt_json
  name: wohnzimmer_strip
  brightness: true
  rgb: true
  command_topic: "dummy"
  optimistic: true
  white_value: true

This gives me a dimmable light with a color picker and also a white channel:

With this, I can have automations which forward the state of this light to the individual lights:

- alias: "Wohnzimmer LED Strip Color"
  trigger:
    platform: state
    entity_id: light.wohnzimmer_strip
  condition:
     - condition: state
       entity_id: light.wohnzimmer_strip                                                                                                           state: 'on'
  action:
     - service: light.turn_on
       entity_id: light.wohnzimmer_strip_decke_r
       data_template:
          brightness: "{{ (states.light.wohnzimmer_strip.attributes.rgb_color[0] * (states.light.wohnzimmer_strip.attributes.brightness / 255)) | int  }}"
     - service: light.turn_on
       entity_id: light.wohnzimmer_strip_decke_g
       data_template:
          brightness: "{{ (states.light.wohnzimmer_strip.attributes.rgb_color[1] * (states.light.wohnzimmer_strip.attributes.brightness / 255)) | int  }}"
     - service: light.turn_on
       entity_id: light.wohnzimmer_strip_decke_b
       data_template:
          brightness: "{{ (states.light.wohnzimmer_strip.attributes.rgb_color[2] * (states.light.wohnzimmer_strip.attributes.brightness / 255)) | int  }}"
     - service: light.turn_on
       entity_id: light.wohnzimmer_strip_decke_w
       data_template:
          brightness: "{{ (states.light.wohnzimmer_strip.attributes.white_value * (states.light.wohnzimmer_strip.attributes.brightness / 255)) | int  }}"

- alias: "Wohnzimmer LED Strip Power"                                                                                                         trigger:
     platform: state
     entity_id: light.wohnzimmer_strip
     to: 'off'
  action:
     - service: light.turn_off
       entity_id: light.wohnzimmer_strip_decke_r
     - service: light.turn_off
       entity_id: light.wohnzimmer_strip_decke_g
     - service: light.turn_off
       entity_id: light.wohnzimmer_strip_decke_b
     - service: light.turn_off
       entity_id: light.wohnzimmer_strip_decke_w

Iā€™d prefer if I could pack everything into one rule, but it seems like the rgb_color attribute is not present when the light is turned off.

This is the same method the BRUH Automation guy uses in his code. JSON. Since I use his code my lights behave exactly as you described. I have all mine on the same MQTT topic, but one certainly wouldnā€™t have to limit it to one topic

HI, have you any idea how to make it the outer way around? I.e. Use a RGB(W) Controller as 3-4 individual LED Dimm channels?

1 Like

thank you very much. Great solution. Did you find any way to also adjust the color temperature?