On_boot not working with addressable LED strip

esphome:
  name: ${device_name}
  on_boot:
    - light.addressable_set:
        id: status_light
        red: 50%
        green: 0
        blue: 0
        white: 0


esp32:
  board: nodemcu-32s

logger:

web_server:
  port: 80

<<: !include _base.yaml


light:
  - platform: esp32_rmt_led_strip
    rgb_order: GRB
    pin: GPIO2
    num_leds: 10
    rmt_channel: 1
    chipset: SK6812
    is_rgbw: true
    id: status_light
    internal: true

when the system starts up with the above config, none of the LEDs are on, even though I’d expect them to be.

  on_boot:
    - light.turn_on: status_light
    - light.addressable_set:
        id: status_light
        red: 50%
        green: 0
        blue: 0
        white: 0

With the above changes, I see all the LEDs light up red for a fraction of a second before going white. This is the opposite of what I expect to happen!

When I open up the web console, I can confirm that the color is set to white: “Keeping current color mode White for call without color mode”, and this is not a color channel misconfiguration.

Any ideas why this is behaving so oddly?

What does the documentation say about using RGB % values in regards to brightness? Ya know, the Docs are a super helpful place to find answers and learn this stuff.

You also need to read the part that explains what light.addressable_set: is for and what the difference is between light.addressable and light.turn_on/turn_off.

These are used for 2 specific purposes and they do 2 different things.

Please read the first code snippet closely, particularly around on_boot. With only the light.addressable_set and no light.turn_on, things behave even more poorly.

I’m aware of the excellent documentation and have read it closely but unfortunately I don’t see how it resolves my issue.

What is light.addressable_set for?

Try raising the on boot priority to 800. Default (as you have not specified anything) is 600.

See: ESPHome Core Configuration — ESPHome

No brightness defined.

esphome:
  name: ${device_name}
  on_boot:
    - light.addressable_set:
        id: status_light
        red: 50%
        green: 0
        blue: 0
        white: 0


esp32:
  board: nodemcu-32s

logger:

web_server:
  port: 80

<<: !include _base.yaml


light:
  - platform: esp32_rmt_led_strip
    rgb_order: GRB
    pin: GPIO2
    num_leds: 10
    rmt_channel: 1
    chipset: SK6812
    is_rgbw: true
    id: status_light
    internal: true

light.addressable is for controlling a range of led’s just like it sais and you couldn’t find some how.

You also have no range defined so in that case you need to use light.turn_on

This is the part I was trying to get you to find but, you missed this big information box somehow. 50% Red only sets the % Red, not the brightness. You have to configure the brightness in addition to the color.

Does light.addressable_set work as expected outside of on_boot?

I’m wondering if this could be a timing issue, e.g. you are trying to turn on the light whole the component is still initialized?

on_boot has an additional parameter priority which can be used to set the execution order.

Yeah I mentioned that already.

800 segfaults due to the light not being initialized yet, which makes sense to me given the docs. priority: 0 doesn’t seem to help either. I don’t have anything else in my config affecting this light, so I don’t think this is it.

when range_to and range_from are left blank, they default to all LEDs in the strip

Oh, I did miss that! That’s going to be helpful in a moment, but in this case it shouldn’t matter. I should just be seeing red at full brightness.


what seems to have solved the problem is the following, particularly the transition_length: 0s, and the very small initial color value. It seems like the transition from the first command was overriding the second

    - light.turn_on:
        id: status_light
        transition_length: 0s
        red: 0
        green: .1
        blue: 0
        white: 0
    - light.addressable_set:
        id: status_light
        red: 100%
        green: 0
        blue: 0

The reason I do it this unusually way is because this is not my real problem, but a simplification of what I’m trying to do. Here’s where I’ve finally ended up:

This turns the color LEDs “on”, but then stops anything from being shown on them:

esphome:
  name: ${device_name}
  on_boot:
  - light.turn_on:
      id: status_light
      transition_length: 0s
      red: 0
      green: .1
      blue: 0
      white: 0
  - light.addressable_set:
      id: status_light
      red: 0
      green: 0
      blue: 0

Then, later on, I use these LEDs as an indicator:

output:
  - platform: gpio
    pin: GPIO25
    id: fan_mid
  - platform: gpio
    pin: GPIO22
    id: fan_high
  - platform: gpio
    pin: GPIO17
    id: fan_turbo
  - platform: gpio
    pin: GPIO21
    id: fan_low
  - platform: template
    id: fan_speed_output
    type: float
    write_action:
      - lambda: |-
          id(fan_low).turn_off();
          id(fan_mid).turn_off();
          id(fan_high).turn_off();
          id(fan_turbo).turn_off();
          auto light = ((AddressableLight*)id(status_light).get_output());
          for (int i = 6; i <= 9; i++) {
            light->get(i).set(Color::BLACK);
          }

          if (state < 0.24) {
          } else if (state < 0.26) {
            id(fan_low).turn_on();
            light->get(6).set(Color(255,0,0,0));
          } else if (state < 0.51) {
            id(fan_mid).turn_on();
            light->get(7).set(Color(255,0,0,0));
          } else if (state < 0.76) {
            id(fan_high).turn_on();
            light->get(8).set(Color(255,0,0,0));
          } else {
            id(fan_turbo).turn_on();
            light->get(9).set(Color(255,0,0,0));
          }
          light->schedule_show();

Thank you all for the help and the suggestions!

So move it up a bit. You started at 600. You know it can’t be 800. So try 700.

1 Like

This configuration works well with addressable LEDs (ws2812x, neopixelbus) indicating the start and end of the boot process:

esphome:
  on_boot:

    - priority: 600
      then:
        - light.turn_on:
            id: led_light
            brightness: 100%
            red: 100%
            green: 0%
            blue: 0%

    - priority: -100
      then:
        - delay: 3s
        - light.turn_on:
            id: led_light
            effect: "1-green"
            brightness: 15%

I don’t know if this helps, but I find it cleaner to put the code into a script and just call the script on boot:

esphome:
  on_boot:
    priority: -100.0
    then:
      - script.execute: test_trashbin