This repository provides an ESPHome external component that adds a light: platform for the Sonoff L1 LED strip controller.
The Sonoff L1 controller typically contains an ESP8285 (ESP8266 family) plus a second microcontroller that drives the LEDs. The LED controller accepts AT style commands over a UART connection at 19200 baud. This component talks to that UART using the ESP8266 hardware serial port.
The Sonoff L1 controller is normally powered from mains. Always unplug it before opening the enclosure. If you are not comfortable working around mains powered devices, get help from someone who is.
- A Sonoff L1 controller
- A 3.3 V USB to TTL serial adapter (FTDI, CP2102, CH340, etc). Do not use 5 V.
- A few jumper wires, plus a way to connect to the Sonoff L1 programming pads (soldering, pogo pins, or clips)
- Home Assistant with the ESPHome add-on installed, or ESPHome installed on your computer
Most Sonoff L1 controllers expose pads for 3V3, GND, RX, TX. Some boards also expose GPIO0 or a button used to enter bootloader mode.
- Adapter GND to device GND
- Adapter TX to device RX
- Adapter RX to device TX
- Adapter 3V3 to device 3V3
Power the device from the adapter 3V3 while flashing. Keep it disconnected from mains.
For ESP8266/ESP8285, flashing mode usually requires GPIO0 held low during power on:
- Hold GPIO0 to GND
- Apply 3V3 power
- Release GPIO0 after a second
If your board has a button, it may do the same thing.
Home Assistant route (recommended):
- Install the ESPHome add-on.
- Open ESPHome, click New Device, follow the prompts.
- When it is time to install, choose Manual download to download the firmware
.bin. - Use a browser flasher like ESPHome Web to flash the downloaded
.binvia your USB to TTL adapter.
Command line route (alternative):
- Create a YAML file (see examples below)
- Run
esphome run <your-yaml>.yamland select the serial port when prompted
Once flashed and booted on Wi-Fi, Home Assistant will discover the device via the ESPHome integration.
This component must be pulled from GitHub via external_components.
Use this in your device YAML:
external_components:
- source: github://ettiennecoetzee/esphome-sonoff-l1@main
components: [sonoff_l1]
logger:
baud_rate: 0 # IMPORTANT: free UART0 for LED control
light:
- platform: sonoff_l1
name: "TV Backlight"
output_id: l1_out
effects:
- lambda:
name: Colorful Gradient (Smooth)
lambda: |-
id(l1_out).setModeGradient();See the full working example in examples/sonoff-l1-device-github.yaml.
Use the GitHub based example:
examples/sonoff-l1-device-github.yaml
That file is ready to paste into ESPHome. It uses substitutions for device name and friendly name, and uses YOURPASSWORDHERE placeholders for Wi-Fi, OTA, and API encryption.
If you prefer to keep the component in your ESPHome config instead of pulling from GitHub:
-
Copy
components/sonoff_l1/into your ESPHome config folder as:/config/esphome/external_components/sonoff_l1/ -
Use the local example (using a local
external_componentsfolder):
examples/sonoff-l1-device-local.yaml
The Sonoff L1 uses the ESP8266 hardware UART for LED control. You must disable serial logging:
logger:
baud_rate: 0- If the device does not respond to color changes, confirm
logger: baud_rate: 0is set. - If flashing fails, double check you are using 3.3 V (not 5 V), and that RX/TX are crossed.
- If the device will not enter flashing mode, confirm GPIO0 is held low at power on.
MIT, see LICENSE.