Turn Light on with defined effect (WS2812)

Hi there,

I just can´t get this to work and I was hoping someone could help me.

I want to turn on the light (via button press) with a predefined effect (rainbow).

I have the following code:

esphome:
  name: l-d1-laurabett
  friendly_name: l-d1-laurabett

esp8266:
  board: d1_mini
  

# Enable logging
logger:
  level: DEBUG

# Enable Home Assistant API
api:

ota:
  - platform: esphome

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password
  fast_connect: True
  min_auth_mode: WPA2

binary_sensor:
  - platform: gpio    
    pin: 
      number: D3
      inverted: True
      mode:
        input: True
        pullup: True
    id: "button"
    on_press: 
      then:
        - logger.log: "Button pressed"
        - light.toggle: strip60
#    on_click: 
#      min_length: 500ms
#      max_length: 2000ms
#      then:
#        - logger.log: "Button long pressed"
#        - light.toggle: strip60

light:
  - platform: neopixelbus
    id: "strip60"
    name: none
    type: GRB
    variant: ws2812
    pin: D4
    num_leds: 60
    restore_mode: RESTORE_DEFAULT_OFF
    on_turn_on: 
      then:
        - light.turn_on:
            id: "strip60" 
            brightness: 40%
            effect: addressable_rainbow
    effects:
      - addressable_rainbow: 

But if I use this, I get an error message in my logs:

[16:37:49.513][D][main:210]: Button pressed
[16:37:49.525][D][light:091]: 'l-d1-laurabett' Setting:
[16:37:49.526][D][light:104]:   State: ON
[16:37:49.526][D][light:142]:   Transition length: 1.0s
[16:37:49.526][W][light:523]: 'l-d1-laurabett': no such effect 'addressable_rainbow'
[16:37:49.526][D][light:091]: 'l-d1-laurabett' Setting:
[16:37:49.539][D][light:079]:   Brightness: 40%
[16:37:49.539][D][light:142]:   Transition length: 1.0s
[16:37:49.539][D][binary_sensor:041]: 'button': New state is ON
[16:37:49.651][D][binary_sensor:041]: 'button': New state is OFF

Does someone have a tip for me?

Yep you need to add the effect in this sort of format

    effects:
      - pulse:
          name: "Slow Pulse"
          transition_length: 150ms
          update_interval: 150ms
          min_brightness: 20%
          max_brightness: 100%

But I have no idea what you expect of your effect or how to write the code, all I know is you have not specified it so it cant run it.

The effect “addressable_rainbow” is predefined in the neopixel lib and it is working when I chose it from the Home Assistant UI.

I just can´t manage to call this effect when turning on the light directly (instead of through the UI).

Try the light turn on section instead of the light toggle in the the button press rather than when the light comes on. Just a guess though.

I think I found it: If I give the library effect a name instead of directly calling the default name, then it works…

So the only change is:

    effects:
      - addressable_rainbow: 
          name: "rainbow"