r/smarthome • u/SiarheiBesarab • 4h ago
Home Assistant Cloud-free ESPHome firmware for the Yeelight W4L bulb: local control, sun-following adaptive light, no Yeelight app
In my part of Europe, the most affordable and widespread RGB bulb is the Yeelight W4L Multicolor. Of course I bought these bulbs. From time to time the stock Yeelight app would lose the connection, and through Apple Home and Google Home the bulb had only a bare minimum of settings. I kept reinstalling the app, reconnecting the bulb and somehow put up with it. Then one day one of the bulbs stopped being detected and froze on a permanent red glow. I decided I had nothing to lose and took it apart. What I saw inside made me very happy.
Taking the bulb apart is quite easy. The outer dome comes off if you carefully lift it around the edge, for example with a metal ruler. It is held on by a thin layer of glue.
So I made a local, cloud-free ESPHome firmware for it and run it on two bulbs.
Inside is an ESP32 with the APP CPU disabled in eFuse, so it is single core. Like on some other Xiaomi lamps, the factory MAC CRC is invalid on both of my bulbs, so ESP-IDF 5.x needs the CRC check bypassed or it boot loops. The UART pads are on the bottom of the driver board, so no desoldering is needed
What it does: a custom light component that uses the factory CCT table and colour matrix from the stock flash, a standalone web page, circadian adaptive light with an optional Mi Flora lux sensor, schedules, a sunrise alarm, a flow editor and encrypted leader/follower sync between two bulbs. It leaves about 140 KB of free heap.
Safety: treat the driver board as live mains. Flash only from 3.3 V on the bench with the bulb unplugged. The Wi-Fi setup mode by quick power cycles is still experimental.
So as far as I could find, this is the first ESPHome firmware for this bulb. Similar projects exist for other Yeelight and Xiaomi lamps, so the new part is the W4L itself and how far it goes. Colours use the factory calibration recovered from the stock flash, the CCT table and the colour matrix, instead of generic PWM mixing. Adaptive lighting runs on the bulb and needs no Home Assistant. It follows the sun for 19 built-in cities, adds a wind-down before bedtime and a sunrise alarm, and can use a Mi Flora sensor for ambient light. Two bulbs stay in sync without a hub. An insect lure mode drives the blue LED alone, without the bit of red the normal calibration mixes in.
Code (MIT): https://github.com/steanlab/moonlight-w4l
Write-up: https://hackaday.io/project/207503-moonlight-esphome-firmware-for-yeelight-w4l
Feedback is welcome, especially from anyone with the same bulb.