I’m having trouble controlling individual LEDs on my WS2812 Neopixel strip using ESPHome. The goal is to light up specific LEDs based on readings from a PM1006 sensor. However, instead of controlling just one LED, no LEDs light up at once. Here’s an excerpt of my current configuration:
light:
- platform: esp32_rmt_led_strip
rgb_order: GRB
pin: GPIO6
num_leds: 30
rmt_channel: 0
chipset: ws2812
name: "neopixel_light"
id: neopixel_light
sensor:
- platform: pm1006
update_interval: 20s
pm_2_5:
name: "PM2.5"
id: pm25_value
on_value_range:
- below: 30
then:
- light.addressable_set:
id: neopixel_light
range_from: 0
range_to: 1 # I want to control only the first LED
red: 0%
green: 0%
blue: 25%
I would like only the first LED to turn blue when PM2.5 is below 30, but currently, no LEDs turned on.
What I’ve tried so far:
Changing the rgb_order from GRB to RGB.
Adjusting range_from and range_to to target individual LEDs.
Ensuring the id: neopixel_light is correctly referenced.
If I turn on the switch on the website all LEDs are turned on and rainbow animation is running
Has anyone experienced this or knows what might be wrong?
No…how can I trigger if this transition is not done ? So that the value is always compared?
I tried it with
on_value:
- lambda: |-
if (x > 100.0) {
auto call = id(neopixel_light).turn_on();
// set parameters (optional)
call.set_brightness(0.2); // 1.0 is full brightness
call.set_color_mode(ColorMode::RGB);
call.set_rgb(0.5, 0.25, 1.0); // color in RGB order, this example is purple
// perform action:
call.perform();
} else {
auto call = id(neopixel_light).turn_on();
// set parameters (optional)
call.set_brightness(0.2); // 1.0 is full brightness
call.set_color_mode(ColorMode::RGB);
call.set_rgb(0.5, 0.25, 1.0); // color in RGB order, this example is purple
// perform action:
call.perform();
}
But how can I address only one LED?? like the index 0?
I have one more question how can I do a boot animation of the LEDs and only if the animation stops all other components starts working??
Here is my try but it’ doesnt work as expcted
esphome:
on_boot:
priority: -10 # Runs after everything else initializes
then:
# 1. Boot Animation - Lauflicht effect
- lambda: |-
auto call = id(neopixel_light).turn_on();
// set parameters (optional)
call.set_brightness(0.5); // 1.0 is full brightness
call.set_effect("Rainbow Effect");
// perform action:
call.perform();
// Delay between each LED for the chase effect
delay(200); // 200ms delay between each step
#2. Turn off lights
- light.turn_off: neopixel_light