RGBW strip with H801 + Tasmota

After a few hours of tinkering, I’ve got a decent setup with an H801 controlling an RGBW strip so I thought I’d share. The biggest problem I ran into was having both RGB and White LEDs on at the same time.

Because of the way Tasmota expects “r,g,b,w” and Home Assistant sends RGB and white on separate topics, it’s not possible to have both types of LEDs on using the auto-discovered device. The closest I could easily get was with adding a while channel, and even then it’s a bit wonky: it’s possible to turn the white LEDs on after setting an RGB color, but as soon as you change the color white annoyingly gets instantly reset to 0.

So here’s essentially what I did:

  1. Solder serial headers to H801 and flash Tasmota

  2. Connect to Wifi, then enable MQTT

  3. I enabled SetOption19 but I think it would work just as well without it – note the MQTT topics below will change though (eg: cmnd/kitchen-accent/Color2 instead of kitchen-accent/cmnd/Color2).

  4. Add the following device:

    light:
      -  platform: mqtt
         name: "Kitchen Accent 2"
         availability_topic: "kitchen-accent/tele/LWT"
         command_topic: "kitchen-accent/cmnd/POWER1"
         state_topic: "kitchen-accent/stat/RESULT"
         state_value_template: "{{value_json.POWER}}"
         brightness_command_topic: "kitchen-accent/cmnd/Dimmer"
         brightness_state_topic: "kitchen-accent/stat/RESULT"
         brightness_value_template: "{{value_json.Dimmer}}"
         brightness_scale: 100
         rgb_command_topic: "kitchen-accent/cmnd/Color2"
         rgb_state_topic: "kitchen-accent/stat/RESULT"
         # RGB<->RGBW conversion
         rgb_value_template: "{% set red = (value_json.Color.split(',')[0] | round(0)) %}{% set green = (value_json.Color.split(',')[1] | round(0)) %}{% set blue = (value_json.Color.split(',')[2] | round(0)) %}{% set white = (value_json.Color.split(',')[3] | round(0)) %}{{ red + white }},{{ green + white }},{{ blue + white }}"
         rgb_command_template: "{% set white = ([red,green,blue]|min) %}{{ red - white }},{{ green - white }},{{ blue - white }},{{ white }}"
         payload_on: "ON"
         payload_off: "OFF"
         payload_available: "Online"
         payload_not_available: "Offline"
         qos: 1
         effect_command_topic: "kitchen-accent/cmnd/Scheme"
         effect_state_topic: "kitchen-accent/stat/RESULT"
         effect_value_template: "{{value_json.Scheme}}"
         effect_list:
         - 0
         - 1
         - 2
         - 3
         - 4
    

That should be it.

How this works is basically I’m converting between RGB and RGBW.values. rgb_command_template is calculating white as the minimum of [R,G,B], and then all R,G,B values have that same amount subtracted. Some examples (r,g,b vs r,g,b,w values):

  • Pure red: 255,0,0 becomes 255,0,0,0
  • Pure white: 255,255,255 becomes 0,0,0,255
  • Yellow-white: 255,255,109 becomes 146,146,0,109
  • Purple-white: 163,72,255 becomes 91,0,183,72

Using The yellow-white as an example, basically instead of using blue to start mixing towards white (blue being the complementary color to yellow), it just uses the white LED instead (so blue = 0). Likewise, pure white uses only the white LEDs rather than mixing white using the RGB LEDs.

Using the outside of the color picker, you always get a 0 for one of the colors, so the white LEDs are completely off. The closer you get to the center the more the white LEDs turn on and the RGBs go dimmer, until the very center (pure white) only the white LEDs turn on at full brightness and RGB LEDs are completely off.

The rgb_value_template also has the corresponding opposite calculation so the color wheel is updated properly. Brightness also works fine here - note in the video I have the brightness set to 5 to try to make it easier to see on the camera, but it works on all brightnesses.


This is pretty much my first use of Home Assistant beyond essentially just being a UI for my ISY99/Insteon network, so I’d welcome any feedback on ways to improve the templates or anything else here.

One thing I did consider was offsetting the colors by 50%, so that the midpoint between pure red and pure white sends 255,0,0,255 (full bright white + full bright red) instead of 146,0,0,109 (~50% each) which it sends now, but I am worried that will reduce the resolution on the color wheel by too much while not really making much practical difference. I might still try that eventually.

5 Likes

after recent update this system doesn’t work :frowning:
when you select every color in the midpoint it send pure white and pure color (255,0,0,255 for red)

I’ve also experienced the same as itmax86. The outer ring of the color wheel works fine, as does the center white, but any other swatch sets the White value to the maximum value of the other three colors, and not the minimum.

@gregmac great work, I was able to implement your code on HA to control RGBW bulb flashed with Tasmota and works like a charm.
However as mentioned by other two members there is a minor hiccup. White LEDs in the bulb are brighter than the RGB leds, hence it washes out the colours when mixed according to your calculation in jason template.
Is there a way to proportionally reduce the brightness of White led in the calculation. Tasmota does have an options to blend the white led Tasmtoa white blend mode These settings seem to work when controlling from Tasmota interface, however these settings here are bypassed when controlled from HA via MQTT