Tuya (generic) RGBWW bulb setup with ESPhome - working!

First project in HA, please be nice to me for any obvious glaring errors, but I would love feedback!

I have a yard lamppost with 3 candelabra sockets. My goal is to a) have these work normally on my “front outside light” switch but also b) set custom colors to celebrate whatever I feel like celebrating. I’m replacing a Caseta wall switch with a dumb switch to power the circuit without worry of its dimming circuit damaging the bulbs. Since I have a 4th bulb left over it’ll go into a living room floor lamp to accent the other non-smart warm white LED bulb in the thing :slight_smile:

I’m using Lohas RGBWW bulbs from Amazon. p/n LH-ZN037E-XWL. These have RGB, CW (cool white), and WW (warm white, really more of a yellow) LEDs on them in an E12 candelabra base.

As my experience with “smart bulbs” was zero, I naively tried the Lohas (rebranded Tuya) app. Terrible, really stinking bad. (They have my SSID and key now. Oh well.)

It didn’t take long to find tuya-convert and HA, so I was off down the rabbit hole.

I now have scenes and automations which are reliably using the white LEDs (and not mixing RGB to produce white) which was a big issue for a while. And I have things set to where my old-school manual-throw switches cause the lights to boot up in a warm white at moderate brightness using a mix of the WW/CW LED’s, which fulfills the expectation of getting light when you flip a switch (with about a 2-3 second delay, which is fine for my current usage).

I thought I’d put this together for anyone else looking for a better experience to build on.

  1. Set up your tuya-convert environment. For me, it was a raspberry pi model 3b. I dropped the latest Raspbian on an SD card, fired up the Pi, and followed the tuya-convert project’s instructions over at github, which really are not at all difficult for a non-developer network admin like me. I dropped tasmota 8.3 on the bulb in this process.

  2. found the bulb’s ip on my router, connected to the bulb via http, changed the config / other / template I found at the tasmota device templates site. Be sure to checkmark the “Activate” box, I was earnestly told.

  3. ran setoption78 1, and uploaded tasmota-lite 8.3 firmware. (For some reason I can’t seem to upload esphome unless I do this first.) I then use the bulb’s web UI to check the bulb’s operation too, make sure the pin mappings were correct (red actually operates red led’s, etc).

  4. added esphome to my HA. This was only a challenge because esphome’s documentation gives old instructions where to add it. otherwise super easy :slight_smile:

  5. created a new esphome device, based on esp8266, and edited to fill it out:
    (see this community post regarding “better_rgbww_output.h”)

esphome:
  name: livingroom1
  platform: ESP8266
  board: esp01_1m
  on_boot:
      priority: 750
      then:
        - light.turn_on:
            id: livingroom1
            # set white LED brightness and color balance between CW and WW
            # this is my own preference. you should choose yours
            color_temperature: 3300K
            white: 40%

  includes:
  # contributor [displaced] developed a workaround for properly using the CW/WW LEDs by setting the RGB color to white
   - better_rgbww_output.h
   
wifi:
  # obviously fill in your own stuff here

# Enable Home Assistant API
api:
  # password: !secret api_password
  password: 'u-choose-this'
  
ota:

# Define output pins
output:
  - platform: esp8266_pwm
    id: output_red
    pin: GPIO5
  - platform: esp8266_pwm
    id: output_green
    pin: GPIO4
  - platform: esp8266_pwm
    id: output_blue
    pin: GPIO13
  - platform: esp8266_pwm
    id: output_warm_white
    pin: GPIO12
  - platform: esp8266_pwm
    id: output_cold_white
    pin: GPIO14

# Define a light entity
light:
  - platform: custom
    lambda: |-
      auto light_out = new BetterRGBWLightOutput(id(output_red), id(output_green), id(output_blue), id(output_cold_white), id(output_warm_white));
      App.register_component(light_out);
      return {light_out};
    lights:
     - name: livingroom1
       id: livingroom1

  1. uploaded to the bulb, confirmed esphome’s console showed it connected, went to configuration >> integrations and the new bulb was there and ready to be added.

Thumbs up!!

definitely made my experience with home automation much, much, much more eye opening. I’ve got a few Caseta wall switches, Nest thermostats, and Unifi cameras for home automation so far, but HA looks really, really exciting. The possibilities are limited only by my very meager wallet. :slight_smile:

2 Likes

Some additional components you might like to add to your light that can help if you ever have any issues.

1 Like

I wonder @semjaza - I have these Lohas Amazon bulbs:

and i’m looking for the original firmware (which i believe is saved as part of the tuya-convert process). I don’t suppose you still have your original firmware do you? I am wanting to convert mine back to original to test something. thanks in advance

I haven’t the same bulb (in fact the Lohas bulbs I have are E12 base, “candelabra” style). I probably do have the original firmware saved from tuya-convert somewhere if you want to try it, but the innards are probably wired differently

1 Like

Actually yes, I have some of those too, that will do. How can I get the file? Dropbox?

Thanks in advance

no such luck, sorry - all I’m finding are post-tuyaconvert firmwares. i think i junked em

1 Like

Ok thanks anyway

@mark.carline if you still need firmware, i got it. Flashed some Tuya-based “MUE HOME” bulb yesterday, also have firmware backup for Teckin SP-25 socket.