Light card behavior with RGBW

Hi,
I have a custom light I made using RGBW LEDs (similar to Adafruit Neopixel). It talks to HA via MQTT. It’s working well when I set levels via MQTT Explorer.

The issue is with the built-in Light Card. When I select colors via the Hue/Saturation color disc I would expect the more saturated colors to the outside of the disc to have less white channel mixed in, with more white channel towards the center of the disk, like this:

But in fact, HA doesn’t ever change the white value no matter what is selected in the Light Card. If I set it to a value via MQTT explorer, then adjust from the Light Card, it will send new color values but won’t ever touch the white channel value.

There’s also a White Brightness and Color Brightness slider, but they don’t seem to behave consistently.

I’m wondering if the issue is how I have the light set up in my configuration.yaml:

mqtt:
  - light:
      name: wally
      unique_id: wally_ID
      schema: json
      state_topic: "home/wally"
      command_topic: "home/wally/set"
      brightness: true
      color_mode: true
      supported_color_modes: ["rgbw"]
      optimistic: false
      qos: 0

I’m following the JSON schema for RGBW on the MQTT Light page here:

Is there something wrong with my config or is the Light card just bugged?

Thank you!

I did a bit more testing and installed the light entity card from the HACS here:

It does do the RGBW values correctly as near as I can tell, but it sends the deprecated key white_value so HA throws an error whenever you use it.

So I think this is something internal to how the HA card takes input from the color wheel and translates it into MQTT values. It’s just doing the math wrong in RGBW mode.

Until this issue gets fixed, I added a hack on the device side to assign the “white” value of the RGB to the actual white channel (using Arduino IDE):

    //hack to compensate for the fact that HA does not send RGBW values correctly
    if (red != 0 && green != 0 && blue != 0) {
      white = min(red, green);
      white = min(white, blue);
      red = red - white;
      green = green - white;
      blue = blue - white;
    }

I will add this issue on the HA github repo.

2 Likes