-
-
Save emorydunn/db410db8bf68c8a335f3362d69624aaa to your computer and use it in GitHub Desktop.
| esphome: | |
| name: led_strip_1 | |
| platform: ESP8266 | |
| board: esp8285 | |
| includes: | |
| - custom_components/sonoff_l1.h | |
| wifi: | |
| captive_portal: | |
| # Logging must be disabled in order for the ESP to comunicate with the Nuvotron | |
| # logger: | |
| # hardware_uart: UART0_SWAP | |
| # level: VERBOSE | |
| # Enable Home Assistant API | |
| api: | |
| ota: | |
| light: | |
| - platform: custom | |
| lambda: |- | |
| auto light_out = new SonoffL1(); | |
| App.register_component(light_out); | |
| return {light_out}; | |
| lights: | |
| - name: "LED Strip 1" | |
| effects: | |
| - lambda: | |
| name: Colorful Gradient (Smooth) | |
| lambda: |- | |
| auto light_out = new SonoffL1(); | |
| light_out->setModeGradient(); | |
| - lambda: | |
| name: Colorful Breath (Fade) | |
| lambda: |- | |
| auto light_out = new SonoffL1(); | |
| light_out->setModeBreath(); | |
| - lambda: | |
| name: RGB Gradient | |
| lambda: |- | |
| auto light_out = new SonoffL1(); | |
| light_out->setModeRGBGradient(); | |
| - lambda: | |
| name: RGB Pulse (Strobe) | |
| lambda: |- | |
| auto light_out = new SonoffL1(); | |
| light_out->setModeRGBPulse(); | |
| - lambda: | |
| name: RGB Breath | |
| lambda: |- | |
| auto light_out = new SonoffL1(); | |
| light_out->setModeRGBBreath(); | |
| - lambda: | |
| name: RGB Strobe (Flash) | |
| lambda: |- | |
| auto light_out = new SonoffL1(); | |
| light_out->setModeRGBStrobe(); | |
| - lambda: | |
| name: Sound Reactive | |
| lambda: |- | |
| auto light_out = new SonoffL1(); | |
| light_out->setModeSync(); |
| #include "esphome.h" | |
| class SonoffL1 : public Component, public LightOutput { | |
| #define SONOFF_L1_MODE_COLORFUL 1 // [Color key] Colorful (static color) | |
| #define SONOFF_L1_MODE_COLORFUL_GRADIENT 2 // [SMOOTH] Colorful Gradient | |
| #define SONOFF_L1_MODE_COLORFUL_BREATH 3 // [FADE] Colorful Breath | |
| #define SONOFF_L1_MODE_DIY_GRADIENT 4 // DIY Gradient (fade in and out) [Speed 1- 100, color] | |
| #define SONOFF_L1_MODE_DIY_PULSE 5 // DIY Pulse (faster fade in and out) [Speed 1- 100, color] | |
| #define SONOFF_L1_MODE_DIY_BREATH 6 // DIY Breath (toggle on/off) [Speed 1- 100, color] | |
| #define SONOFF_L1_MODE_DIY_STROBE 7 // DIY Strobe (faster toggle on/off) [Speed 1- 100, color] | |
| #define SONOFF_L1_MODE_RGB_GRADIENT 8 // RGB Gradient | |
| #define SONOFF_L1_MODE_RGB_PULSE 9 // [STROBE] RGB Pulse | |
| #define SONOFF_L1_MODE_RGB_BREATH 10 // RGB Breath | |
| #define SONOFF_L1_MODE_RGB_STROBE 11 // [FLASH] RGB strobe | |
| #define SONOFF_L1_MODE_SYNC_TO_MUSIC 12 // Sync to music [Speed 1- 100, sensitivity 1 - 10] | |
| public: | |
| int mode = SONOFF_L1_MODE_COLORFUL; | |
| void setup() override { | |
| // nothing to do here | |
| Serial.begin(19200); | |
| } | |
| LightTraits get_traits() override { | |
| // return the traits this light supports | |
| auto traits = LightTraits(); | |
| // Use Supported Color Modes for 2021.8 and later | |
| traits.set_supported_color_modes({light::ColorMode::RGB}); | |
| // Use Individual traits for earlier versions | |
| // traits.set_supports_brightness(true); | |
| // traits.set_supports_rgb(true); | |
| // traits.set_supports_rgb_white_value(false); | |
| // traits.set_supports_color_temperature(false); | |
| return traits; | |
| } | |
| void write_state(LightState *state) override { | |
| // This will be called by the light to get a new state to be written. | |
| float red, green, blue; | |
| // use any of the provided current_values methods | |
| state->current_values_as_rgb(&red, &green, &blue); | |
| // Convert to 0-255 | |
| int redValue, greenValue, blueValue; | |
| redValue = floor(red * 255); | |
| greenValue = floor(green * 255); | |
| blueValue = floor(blue * 255); | |
| bool ledState; | |
| state->current_values_as_binary(&ledState); | |
| float brightnessPercent; | |
| state->current_values_as_brightness(&brightnessPercent); | |
| // Convert to 0-100 | |
| int brightness = floor(brightnessPercent * 100); | |
| char buffer[140]; | |
| snprintf_P(buffer, sizeof(buffer), PSTR("AT+UPDATE=\"sequence\":\"%d%03d\",\"switch\":\"%s\",\"light_type\":1,\"colorR\":%d,\"colorG\":%d,\"colorB\":%d,\"bright\":%d,\"mode\":%d"), | |
| millis(), millis()%1000, | |
| ledState ? "on" : "off", | |
| redValue, greenValue, blueValue, | |
| brightness, | |
| SONOFF_L1_MODE_COLORFUL); | |
| Serial.print(buffer); | |
| Serial.write(0x1B); | |
| Serial.flush(); | |
| } | |
| // SONOFF_L1_MODE_COLORFUL_GRADIENT | |
| void setModeGradient() { | |
| char buffer[140]; | |
| snprintf_P(buffer, sizeof(buffer), PSTR("AT+UPDATE=\"sequence\":\"%d%03d\",\"mode\":%d"), | |
| millis(), millis()%1000, | |
| SONOFF_L1_MODE_COLORFUL_GRADIENT | |
| ); | |
| Serial.print(buffer); | |
| Serial.write(0x1B); | |
| Serial.flush(); | |
| } | |
| // SONOFF_L1_MODE_COLORFUL_BREATH | |
| void setModeBreath() { | |
| char buffer[140]; | |
| snprintf_P(buffer, sizeof(buffer), PSTR("AT+UPDATE=\"sequence\":\"%d%03d\",\"mode\":%d"), | |
| millis(), millis()%1000, | |
| SONOFF_L1_MODE_COLORFUL_BREATH | |
| ); | |
| Serial.print(buffer); | |
| Serial.write(0x1B); | |
| Serial.flush(); | |
| } | |
| // SONOFF_L1_MODE_RGB_GRADIENT | |
| void setModeRGBGradient() { | |
| char buffer[140]; | |
| snprintf_P(buffer, sizeof(buffer), PSTR("AT+UPDATE=\"sequence\":\"%d%03d\",\"mode\":%d"), | |
| millis(), millis()%1000, | |
| SONOFF_L1_MODE_RGB_GRADIENT | |
| ); | |
| Serial.print(buffer); | |
| Serial.write(0x1B); | |
| Serial.flush(); | |
| } | |
| // SONOFF_L1_MODE_RGB_PULSE | |
| void setModeRGBPulse() { | |
| char buffer[140]; | |
| snprintf_P(buffer, sizeof(buffer), PSTR("AT+UPDATE=\"sequence\":\"%d%03d\",\"mode\":%d"), | |
| millis(), millis()%1000, | |
| SONOFF_L1_MODE_RGB_PULSE | |
| ); | |
| Serial.print(buffer); | |
| Serial.write(0x1B); | |
| Serial.flush(); | |
| } | |
| // SONOFF_L1_MODE_RGB_BREATH | |
| void setModeRGBBreath() { | |
| char buffer[140]; | |
| snprintf_P(buffer, sizeof(buffer), PSTR("AT+UPDATE=\"sequence\":\"%d%03d\",\"mode\":%d"), | |
| millis(), millis()%1000, | |
| SONOFF_L1_MODE_RGB_BREATH | |
| ); | |
| Serial.print(buffer); | |
| Serial.write(0x1B); | |
| Serial.flush(); | |
| } | |
| // SONOFF_L1_MODE_RGB_STROBE | |
| void setModeRGBStrobe() { | |
| char buffer[140]; | |
| snprintf_P(buffer, sizeof(buffer), PSTR("AT+UPDATE=\"sequence\":\"%d%03d\",\"mode\":%d"), | |
| millis(), millis()%1000, | |
| SONOFF_L1_MODE_RGB_STROBE | |
| ); | |
| Serial.print(buffer); | |
| Serial.write(0x1B); | |
| Serial.flush(); | |
| } | |
| // SONOFF_L1_MODE_SYNC_TO_MUSIC | |
| void setModeSync(int sensitive = 10, int speed = 50) { | |
| char buffer[140]; | |
| snprintf_P(buffer, sizeof(buffer), PSTR("AT+UPDATE=\"sequence\":\"%d%03d\",\"mode\":%d,\"sensitive\":%d,\"speed\":%d"), | |
| millis(), millis()%1000, | |
| SONOFF_L1_MODE_SYNC_TO_MUSIC, | |
| sensitive, | |
| speed | |
| ); | |
| Serial.print(buffer); | |
| Serial.write(0x1B); | |
| Serial.flush(); | |
| } | |
| }; |
Hey Emory,
Found the issue with the help from @JeffResc who did the changes for the D1-Dimmer.
This needs to be changed in the "sonoff_l1.h" code above...
LightTraits get_traits() override {
// return the traits this light supports
auto traits = LightTraits();
traits.set_supports_brightness(true);
traits.set_supports_rgb(true);
traits.set_supports_rgb_white_value(false);
traits.set_supports_color_temperature(false);
return traits;
to this ...
LightTraits get_traits() override {
// return the traits this light supports
auto traits = LightTraits();
traits.set_supported_color_modes({light::ColorMode::BRIGHTNESS});
return traits;
}
Works perfectly from here onward.
Thx and go well and be safe.
Best rgds
Sirronb
@sirronb thanks so much for looking into that. I haven't updated yet, so I'll incorporate your changes if they're backwards compatible. It might be time to convert this to a proper repo, especially if there need to be multiple versions of the config.
@emorydunn, Thanks for your response. I'd just like to add that the program compiled perfectly in ESPHome, but after uploading (ota) and testing it out on the L1, there was no response. So something has changed causing the sonoff L1 hardware not to respond as would be expected.
Hence, a new approach will have to be looked into.
From the deprecated functions, it seems to be an RGB light. Maybe give the code below a try?
I ran into a similar problem with my (entirely different brand of) lights. An incorrect colour mode seemed to not allow my light to turn on at all. The other possible values are here: https://esphome.io/api/namespaceesphome_1_1light.html#ae15e8fc701ad0efd46c3dfeefa408c7a
LightTraits get_traits() override {
// return the traits this light supports
auto traits = LightTraits();
traits.set_supported_color_modes({light::ColorMode::RGB});
return traits;
}
I finally got around to updating ESPHome and testing this out. Looks like @kancelott's change does the trick.
Thanks guys! It worked perfect for me too!
Perfectly did the trick, thanks @kancelott and @sirronb !
Hey guys, seems since the update I lost the color picker? Any idea why this happened?
Hello! Does it work without server (HA) after compiling?
@Kentrp It should, although I'm not sure how useful a device running ESPHome will be without Home Assistant.
Hello, it seems that esphome 2023.7.0 broke this component for me. It looks like sending commands to the Nuvotron fails:
AT+UPDATE="sequence":"588226226","switch":"off","light_type":1,"colorR":0,"colorG":0,"colorB":0,"bright":100,"mode":1
[11:33:45][W][component:204]: Component light took a long time for an operation (0.22 s).
[11:33:45][W][component:205]: Components should block for at most 20-30ms.
Anyone else experiencing the same issue with 2023.7.0?
Hello, it seems that esphome 2023.7.0 broke this component for me. It looks like sending commands to the Nuvotron fails:
AT+UPDATE="sequence":"588226226","switch":"off","light_type":1,"colorR":0,"colorG":0,"colorB":0,"bright":100,"mode":1 [11:33:45][W][component:204]: Component light took a long time for an operation (0.22 s). [11:33:45][W][component:205]: Components should block for at most 20-30ms.Anyone else experiencing the same issue with 2023.7.0?
The same for me.
Maybe https://github.com/esphome/issues/issues/4717 is related? But I get the impression that other components show the "too a long time" warning but still work, while this one breaks.
A git bisect between 2023.6.5 and 2023.7 would be very useful to find the exact commit that breaks the component. Don't know whether I have the time to do it though.
I found the issue, I had logger enabled for wifi logging, which up to now did not seem to be an issue, but maybe in the latest version logger tries to set the baud rate or something. I fixed it by setting baud_rate: 0 which disables serial logging.
logger:
esp8266_store_log_strings_in_flash: false
baud_rate: 0
With this change the controller actually became more responsive than before. Maybe with logger enabled the Nuvotron was being slowed down by debug messages sent to it?
Note also that the " took a long time for an operation" warning still appears, probably it takes too long to send the command over serial, but likely it's not an issue. In https://github.com/esphome/issues/issues/4717 it is mentioned that components should use callbacks to avoid the warning.
Anyone been able to get this converted into an external component for 2025.2 support?
Found a workaround by re-implementing custom components using this repo https://github.com/robertklep/esphome-custom-component
@ShonP40 Could you share with us your yaml and how do register sonoff_l1.h?
Just add this to your YAML
external_components:
- source:
type: git
url: https://github.com/robertklep/esphome-custom-component
components: [ custom, custom_component ]As stated on the README of the repo I linked above
hi there i just flash a L1 with esphome, works.... but i have a problem with the minimun brightness, about 25% the unit turn off. is theres any way to adjust??? im only using this yaml.
`external_components:
- source:
type: git
url: https://github.com/robertklep/esphome-custom-component
components: [ custom, custom_component ]
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
manual_ip:
static_ip: 192.168.0.151
subnet: 255.255.255.0
gateway: 192.168.0.1
dns1: 8.8.8.8
dns2: 8.8.4.4
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Led-Test-L1 Fallback Hotspot"
password: "ts9AWpPcKHED"
captive_portal:
light:
- platform: custom
lambda: |-
auto light_out = new SonoffL1();
App.register_component(light_out);
return {light_out};
lights:
- name: "LED Strip `1"``
The latest update, esphome 2026.1, does not work on this device; it simply does not update.
In file included from src/main.cpp:58:
src/sonoff_l1.h: In member function 'virtual void SonoffL1::setup()':
src/sonoff_l1.h:24:5: error: 'Serial' was not declared in this scope
24 | Serial.begin(19200);
| ^~~~~~
In file included from src/main.cpp:58:
src/sonoff_l1.h: In member function 'virtual void SonoffL1::write_state(esphome::light::LightState*)':
src/sonoff_l1.h:71:5: error: 'Serial' was not declared in this scope
71 | Serial.print(buffer);
| ^~~~~~
src/sonoff_l1.h: In member function 'void SonoffL1::setModeGradient()':
src/sonoff_l1.h:85:5: error: 'Serial' was not declared in this scope
85 | Serial.print(buffer);
| ^~~~~~
src/sonoff_l1.h: In member function 'void SonoffL1::setModeBreath()':
src/sonoff_l1.h:98:5: error: 'Serial' was not declared in this scope
98 | Serial.print(buffer);
| ^~~~~~
src/sonoff_l1.h: In member function 'void SonoffL1::setModeRGBGradient()':
src/sonoff_l1.h:111:5: error: 'Serial' was not declared in this scope
111 | Serial.print(buffer);
| ^~~~~~
src/sonoff_l1.h: In member function 'void SonoffL1::setModeRGBPulse()':
src/sonoff_l1.h:124:5: error: 'Serial' was not declared in this scope
124 | Serial.print(buffer);
| ^~~~~~
src/sonoff_l1.h: In member function 'void SonoffL1::setModeRGBBreath()':
src/sonoff_l1.h:137:5: error: 'Serial' was not declared in this scope
137 | Serial.print(buffer);
| ^~~~~~
src/sonoff_l1.h: In member function 'void SonoffL1::setModeRGBStrobe()':
src/sonoff_l1.h:150:5: error: 'Serial' was not declared in this scope
150 | Serial.print(buffer);
| ^~~~~~
src/sonoff_l1.h: In member function 'void SonoffL1::setModeSync(int, int)':
src/sonoff_l1.h:165:5: error: 'Serial' was not declared in this scope
165 | Serial.print(buffer);
The latest update, esphome 2026.1, does not work on this device; it simply does not update.
In file included from src/main.cpp:58: src/sonoff_l1.h: In member function 'virtual void SonoffL1::setup()': src/sonoff_l1.h:24:5: error: 'Serial' was not declared in this scope 24 | Serial.begin(19200); | ^~~~~~ In file included from src/main.cpp:58: src/sonoff_l1.h: In member function 'virtual void SonoffL1::write_state(esphome::light::LightState*)': src/sonoff_l1.h:71:5: error: 'Serial' was not declared in this scope 71 | Serial.print(buffer); | ^~~~~~ src/sonoff_l1.h: In member function 'void SonoffL1::setModeGradient()': src/sonoff_l1.h:85:5: error: 'Serial' was not declared in this scope 85 | Serial.print(buffer); | ^~~~~~ src/sonoff_l1.h: In member function 'void SonoffL1::setModeBreath()': src/sonoff_l1.h:98:5: error: 'Serial' was not declared in this scope 98 | Serial.print(buffer); | ^~~~~~ src/sonoff_l1.h: In member function 'void SonoffL1::setModeRGBGradient()': src/sonoff_l1.h:111:5: error: 'Serial' was not declared in this scope 111 | Serial.print(buffer); | ^~~~~~ src/sonoff_l1.h: In member function 'void SonoffL1::setModeRGBPulse()': src/sonoff_l1.h:124:5: error: 'Serial' was not declared in this scope 124 | Serial.print(buffer); | ^~~~~~ src/sonoff_l1.h: In member function 'void SonoffL1::setModeRGBBreath()': src/sonoff_l1.h:137:5: error: 'Serial' was not declared in this scope 137 | Serial.print(buffer); | ^~~~~~ src/sonoff_l1.h: In member function 'void SonoffL1::setModeRGBStrobe()': src/sonoff_l1.h:150:5: error: 'Serial' was not declared in this scope 150 | Serial.print(buffer); | ^~~~~~ src/sonoff_l1.h: In member function 'void SonoffL1::setModeSync(int, int)': src/sonoff_l1.h:165:5: error: 'Serial' was not declared in this scope 165 | Serial.print(buffer);
Add enable_serial: true to your esp8266 config (as stated in the ESPHome 2026.1 changelog)
esp8266:
board: esp8285
restore_from_flash: true
enable_serial: trueAlso, this custom component has been broken ever since ESPHome 2025.5 was released, so I just stayed on ESPHome 2025.4 until I decided to convert it to an external component.
Released it over at https://github.com/ShonP40/Sonoff-L1
restore_from_flash: true enable_serial: true
Thank you so much, I didn't think that change would affect me when I read the documentation.
Could you explain a little bit about how to install your external component? I currently have this:
esphome:
name: ${device_name}
includes:
- custom_components/sonoff_l1.h
esp8266:
board: esp8285
restore_from_flash: true
enable_serial: true
external_components:
- source:
type: git
url: https://github.com/robertklep/esphome-custom-component
components: [ custom, custom_component ]
light:
-
platform: custom
lambda: |-
auto light_out = new SonoffL1();
App.register_component(light_out);
return {light_out};lights:
- name: "LED Strip 1"
effects:- lambda:
name: Colorful Gradient (Smooth)
lambda: |-
auto light_out = new SonoffL1();
light_out->setModeGradient(); - lambda:
name: Colorful Breath (Fade)
lambda: |-
auto light_out = new SonoffL1();
light_out->setModeBreath(); - lambda:
name: RGB Gradient
lambda: |-
auto light_out = new SonoffL1();
light_out->setModeRGBGradient(); - lambda:
name: RGB Pulse (Strobe)
lambda: |-
auto light_out = new SonoffL1();
light_out->setModeRGBPulse(); - lambda:
name: RGB Breath
lambda: |-
auto light_out = new SonoffL1();
light_out->setModeRGBBreath(); - lambda:
name: RGB Strobe (Flash)
lambda: |-
auto light_out = new SonoffL1();
light_out->setModeRGBStrobe(); - lambda:
name: Sound Reactive
lambda: |-
auto light_out = new SonoffL1();
light_out->setModeSync();
- lambda:
- name: "LED Strip 1"
I'd like to switch to your integration since it seems to be supported. Could I download the components/sonoff_l1 files from your GitHub repository and work with them locally?
How would I do that?
Thanks!
restore_from_flash: true enable_serial: trueThank you so much, I didn't think that change would affect me when I read the documentation.
Could you explain a little bit about how to install your external component? I currently have this:
esphome: name: ${device_name} includes: - custom_components/sonoff_l1.h
esp8266: board: esp8285 restore_from_flash: true enable_serial: true
external_components:
- source:
type: git
url: github.com/robertklep/esphome-custom-component
components: [ custom, custom_component ]light:
platform: custom
lambda: |-
auto light_out = new SonoffL1();
App.register_component(light_out);
return {light_out};
lights:
name: "LED Strip 1"
effects:
- lambda:
name: Colorful Gradient (Smooth)
lambda: |-
auto light_out = new SonoffL1();
light_out->setModeGradient();- lambda:
name: Colorful Breath (Fade)
lambda: |-
auto light_out = new SonoffL1();
light_out->setModeBreath();- lambda:
name: RGB Gradient
lambda: |-
auto light_out = new SonoffL1();
light_out->setModeRGBGradient();- lambda:
name: RGB Pulse (Strobe)
lambda: |-
auto light_out = new SonoffL1();
light_out->setModeRGBPulse();- lambda:
name: RGB Breath
lambda: |-
auto light_out = new SonoffL1();
light_out->setModeRGBBreath();- lambda:
name: RGB Strobe (Flash)
lambda: |-
auto light_out = new SonoffL1();
light_out->setModeRGBStrobe();- lambda:
name: Sound Reactive
lambda: |-
auto light_out = new SonoffL1();
light_out->setModeSync();I'd like to switch to your integration since it seems to be supported. Could I download the components/sonoff_l1 files from your GitHub repository and work with them locally?
How would I do that?
Thanks!
- You don't need to download anything manually anymore
- Replace everything in your config with this:
esphome:
name: ${device_name}
esp8266:
board: esp8285
restore_from_flash: true
external_components:
- source: github://ShonP40/Sonoff-L1
components: [ sonoff_l1 ]
uart:
tx_pin: GPIO1
rx_pin: GPIO3
baud_rate: 19200
light:
- platform: sonoff_l1
name: "Sonoff L1"
id: sonoff_l1
icon: mdi:led-strip-variant
on_turn_off:
- lambda: |-
auto output = (esphome::sonoff_l1::SonoffL1*)id(sonoff_l1).get_output();
output->resetMode();
effects:
- lambda:
name: "Gradient (Fast)"
lambda: |-
auto output = (esphome::sonoff_l1::SonoffL1*)id(sonoff_l1).get_output();
output->activateModeGradientFast();
- lambda:
name: "Gradient (Slow)"
lambda: |-
auto output = (esphome::sonoff_l1::SonoffL1*)id(sonoff_l1).get_output();
output->activateModeGradientSlow();
- lambda:
name: "Cycle (Fast)"
lambda: |-
auto output = (esphome::sonoff_l1::SonoffL1*)id(sonoff_l1).get_output();
output->activateModeCycleFast();
- lambda:
name: "Cycle (Slow)"
lambda: |-
auto output = (esphome::sonoff_l1::SonoffL1*)id(sonoff_l1).get_output();
output->activateModeCycleSlow();
- lambda:
name: "Pulse"
lambda: |-
auto output = (esphome::sonoff_l1::SonoffL1*)id(sonoff_l1).get_output();
output->activateModePulse();
- lambda:
name: "Strobe"
lambda: |-
auto output = (esphome::sonoff_l1::SonoffL1*)id(sonoff_l1).get_output();
output->activateModeStrobe();
- lambda:
name: "Sound Reactive"
lambda: |-
auto output = (esphome::sonoff_l1::SonoffL1*)id(sonoff_l1).get_output();
output->activateModeSoundReactive(5, 50); // Sensitivity: 1-10, Speed: 1-100also include your WiFi config obviously
btw, I just finished adding support for the IR remote that was included with this LED strip
It now syncs the state with ESPHome
light: - platform: sonoff_l1 name: "Sonoff L1" id: sonoff_l1 icon: mdi:led-strip-variant on_turn_off: - lambda: |- auto output = (esphome::sonoff_l1::SonoffL1*)id(sonoff_l1).get_output(); output->resetMode(); effects: - lambda: name: "Gradient (Fast)" lambda: |- auto output = (esphome::sonoff_l1::SonoffL1*)id(sonoff_l1).get_output(); output->activateModeGradientFast(); - lambda: name: "Gradient (Slow)" lambda: |- auto output = (esphome::sonoff_l1::SonoffL1*)id(sonoff_l1).get_output(); output->activateModeGradientSlow(); - lambda: name: "Cycle (Fast)" lambda: |- auto output = (esphome::sonoff_l1::SonoffL1*)id(sonoff_l1).get_output(); output->activateModeCycleFast(); - lambda: name: "Cycle (Slow)" lambda: |- auto output = (esphome::sonoff_l1::SonoffL1*)id(sonoff_l1).get_output(); output->activateModeCycleSlow(); - lambda: name: "Pulse" lambda: |- auto output = (esphome::sonoff_l1::SonoffL1*)id(sonoff_l1).get_output(); output->activateModePulse(); - lambda: name: "Strobe" lambda: |- auto output = (esphome::sonoff_l1::SonoffL1*)id(sonoff_l1).get_output(); output->activateModeStrobe(); - lambda: name: "Sound Reactive" lambda: |- auto output = (esphome::sonoff_l1::SonoffL1*)id(sonoff_l1).get_output(); output->activateModeSoundReactive(5, 50); // Sensitivity: 1-10, Speed: 1-100
It's not working for me; I get this error when compiling:
Failed config
light.sonoff_l1: [source /config/esphome/led.yaml:142]
platform: sonoff_l1
name: Sonoff L1
ID 'sonoff_l1' conflicts with the name of an esphome integration, please use another ID name.
id: sonoff_l1
icon: mdi:led-strip-variant
on_turn_off:
- lambda: |-
auto output = (esphome::sonoff_l1::SonoffL1*)id(sonoff_l1).get_output();
output->resetMode();
effects:
- lambda:
name: Gradient (Fast)
lambda: |-
Change the ID to something else
That sonoff_l1 ID was just an example
Change the ID to something else That
sonoff_l1ID was just an example
I can't get it to work. If I change the ID, it compiles, but it loses all the LED strip functionality. This is my YAML:
substitutions:
device_name: "led"
esphome:
name: ${device_name}
esp8266:
board: esp8285
restore_from_flash: true
uart:
tx_pin: GPIO1
rx_pin: GPIO3
baud_rate: 19200
external_components:
- source: github://ShonP40/Sonoff-L1
components: [ sonoff_l1 ]
api:
encryption:
key: "XXX"
ota:
- platform: esphome
password: "XXX" - platform: web_server
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
ap:
ssid: "LED"
password: !secret ap_password
captive_portal:
logger:
baud_rate: 0
web_server:
port: 80
time:
- platform: homeassistant
id: homeassistant_time
light:
- platform: sonoff_l1
name: "Sonoff L1"
id: led_cocina # Este es el ID actual
icon: mdi:led-strip-variant
on_turn_off:- lambda: |-
// Usamos el ID correcto: led_cocina
auto output = (esphome::sonoff_l1::SonoffL1*)id(led_cocina).get_output();
output->resetMode();
effects: - lambda:
name: "Gradient (Fast)"
lambda: |-
auto output = (esphome::sonoff_l1::SonoffL1*)id(led_cocina).get_output();
output->activateModeGradientFast(); - lambda:
name: "Gradient (Slow)"
lambda: |-
auto output = (esphome::sonoff_l1::SonoffL1*)id(led_cocina).get_output();
output->activateModeGradientSlow(); - lambda:
name: "Cycle (Fast)"
lambda: |-
auto output = (esphome::sonoff_l1::SonoffL1*)id(led_cocina).get_output();
output->activateModeCycleFast(); - lambda:
name: "Cycle (Slow)"
lambda: |-
auto output = (esphome::sonoff_l1::SonoffL1*)id(led_cocina).get_output();
output->activateModeCycleSlow(); - lambda:
name: "Pulse"
lambda: |-
auto output = (esphome::sonoff_l1::SonoffL1*)id(led_cocina).get_output();
output->activateModePulse(); - lambda:
name: "Strobe"
lambda: |-
auto output = (esphome::sonoff_l1::SonoffL1*)id(led_cocina).get_output();
output->activateModeStrobe(); - lambda:
name: "Sound Reactive"
lambda: |-
auto output = (esphome::sonoff_l1::SonoffL1*)id(led_cocina).get_output();
output->activateModeSoundReactive(5, 50);
- lambda: |-
preferences:
flash_write_interval: 5min
Can you create an issue on my repo & provide your config?
Since this is kinda off-topic to this custom component…
Hi Emory,
As of ESPHome Current version 2021.8.0 of today, the following errors are being reported when attempting to update devices with this version of ESPHome:
In file included from src/main.cpp:25:0:
src/sonoff_l1.h: In member function 'virtual esphome::light::LightTraits SonoffL1::get_traits()':
src/sonoff_l1.h:29:12: error: 'class esphome::light::LightTraits' has no member named 'set_supports_brightness'
traits.set_supports_brightness(true);
^
src/sonoff_l1.h:30:12: error: 'class esphome::light::LightTraits' has no member named 'set_supports_rgb'
traits.set_supports_rgb(true);
^
src/sonoff_l1.h:31:12: error: 'class esphome::light::LightTraits' has no member named 'set_supports_rgb_white_value'
traits.set_supports_rgb_white_value(false);
^
src/sonoff_l1.h:32:12: error: 'class esphome::light::LightTraits' has no member named 'set_supports_color_temperature'
traits.set_supports_color_temperature(false);
^
Compiling /data/led_strip_1/.pioenvs/led_strip_1/lib4d9/ESP8266WiFi/WiFiServerSecureBearSSL.cpp.o
*** [/data/led_strip_1/.pioenvs/led_strip_1/src/main.cpp.o] Error 1
========================= [FAILED] Took 18.90 seconds =========================
This website shows what the issue could be ...
https://esphome.io/api/classesphome_1_1light_1_1_light_traits.html
Will appreciate you looking into this when your time permits.
Many thanks. Keep well and be safe.
Rgds
sirronb