Issue with Controlling Individual WS2812 Neopixel LEDs in ESPHome – NO LEDs Lighting Up

Hi everyone,

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:

  1. Changing the rgb_order from GRB to RGB.
  2. Adjusting range_from and range_to to target individual LEDs.
  3. Ensuring the id: neopixel_light is correctly referenced.
  4. 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?

Thanks in advance for your help!

on_value_range will trigger when the value goes from over 30 to under 30. Had it made that transition?

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?

try Addressable Lambda Effect

Thanks for the help :slight_smile:

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

Never tried anything like that, but use high priority (like 800) if you need to do it before other components start.