Home Assistant Smart LEDs using WLED and ESP8266
To date there have been two primary methods for integrating cheap ESP8266 boards like the NodeMCU or D1 Mini with Home Assistant. The first I wrote about in January using custom Arduino code written by Bruh Automation and the second used ESPHome. Both of these methods were fine but each had their pros and cons.
Flashing custom Arduino code can be error prone and confusing sometimes. Not to mention a minefield of driver management and that the Arduino IDE requires Java. ESPHome is very simple to set up but lacks the intricate configurability of custom code. In short, there's always a trade off. But what if I told you that there's now a third way that mashes the best bits of these two options together?
A platinum level Home Assistant integration for the WLED project was released with version 0.120 on Nov 20th 2019. I'm going to walk you through flashing a D1 Mini (though the same steps apply for a NodeMCU too) using Linux. You can probably expect this process to take about 5-10 minutes.
Hardware required
Please note that the links below are Amazon affiliate links that support my bringing this content to you.
Item | Price | Purpose |
---|---|---|
D1 Mini | $5.50 | A mini wifi board with 4MB flash based on ESP-8266EX |
5v LEDs | $28 | 300 5v LEDs with WS2812b controller (1 LED = 1 pixel) |
Micro USB Breakout Board | 69c each | MicroUSB power input board |
Total | $16.07 |
You'll also need a power supply. The Amazon listing suggest 18A at 5v to power all 300 LEDs so I would suggest only using these 5v strips in smaller projects. For longer runs, use the 12v strips from my original article. For these 5v strips you need to budget approx 60mA for each LED at full brightness.
I also designed a 3d printable case for the components from my previous post, so if you're using a nodemcu instead of a d1 mini then you can use this from thingiverse.
Wiring diagram
Pay attention to the power supply comment above but here's an example wiring diagram to help you get started.
Flashing the firmware
Flashing WLED is unbeliveably easy on Linux. I grab esptool
from the AUR on Arch and then executed the following one line command to flash firmware.
sudo esptool.py --port /dev/ttyUSB0 write_flash 0x00000 Downloads/WLED_0.8.6_ESP8266.bin
- Download the version of the latest WLED firmware from Github on the releases page
- Install
esptool
(Arch usersyay -S esptool
) - esptool project link - Connect the D1 mini via usb to your system and then...
- Flash the firmware
Yes, that is it. You will now be able to perform all future updates over the air, wirelessly.
Configuring the D1 mini
- Using your smartphone or laptop look for a new wifi network called
WLED-AP
and connect to it using the default passwordwled1234
- Navigate to the IP address
4.3.2.1
in a browser - Fill-in the relevant wifi information for your network
- Hit save
Configuring a custom name and add to Home Assistant
This video shows how to set a custom name in the WLED web server and how to integrate with Home Assistant.
Configuring Home Assistant
This is covered in the short video above labelled 'how to integrate'.
- Enter the configuration menu
- Enter the integrations menu
- Use the orange plus in the bottom right to add a new integration
- Search for WLED from the drop down list
- Enter the IP address of your D1 mini
- Save
Configure Home Assistant interface
This is covered in the short video above labelled 'how to integrate'.
- Load Home Assistant Overview page and 'configure UI' from 3 dot menu in the top right
- Add a new light card
- Select the light and customise the icon as you see fit
- For bonus points you could add this new light to a group
Summary
That's it folks. What took me several days to understand in January previously now takes a matter of minutes...
- No MQTT servers (though this firmware does support it)
- No custom code compiliation (though you can if you want to customise the data pin for some reason)
- Full effect selection available
- Native Home Assistant API integration
There is a native Android and iOS app if you didn't want to use Home Assistant, for some reason.