Unusual Results with Light Component

I have been attempting to implement the Light Component on my daughters bedroom lights (A length of WS2812 under the bed).

There are two forms of triggering for the lights… a PIR sensor and a zigbee 3 button via MQTT. Everything seems fine, except the code occasionally spits an error related to the light effects.

Here’s my code…

substitutions:
  off_hour: '5'
  on_hour: '14'

esp8266:
 board: d1_mini
 framework:
  version: recommended
  
esphome:
  name: esp4-bdrmlights 

status_led:
  pin: GPIO2

# Enable logging
logger:
  level: VERBOSE

# Enable Home Assistant API
api:
  encryption:
    key: <REDACTED>

ota:
  password: "<REDACTED>"

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

# Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Esp4-Bdrmlights Fallback Hotspot"
    password: "<REDACTED>"

captive_portal:

mqtt:
  broker: !secret mqtt_broker_new
  username: !secret mqtt_login
  password: !secret mqtt_passwd
  port: 1883
  reboot_timeout: 0s
  keepalive: 60s
  discovery: false
  on_message:
    - topic: zigbee2mqtt/Q-3Button-Remote/action
      payload: '1_single'
      qos: 0
      then:
      - if:
          condition:
            and:
              # If the LED's are off
              - light.is_off: bdrm_led_lights
          then:
          # Turn on the LED lights
          - script.execute: rainbow_effect
          - logger.log: "The LED lights are ON Rainbow"
          - script.execute: turn_off
  
    - topic: zigbee2mqtt/Q-3Button-Remote/action
      payload: '2_single'
      qos: 0
      then:
      - if:
          condition:
            and:
              # If the LED's are off
              - light.is_off: bdrm_led_lights
          then:
              # Turn on the LED lights
              - script.execute: randomize_effect
              - logger.log: "The LED lights are ON Random"
              - script.execute: turn_off

    - topic: zigbee2mqtt/Q-3Button-Remote/action
      payload: '3_single'
      qos: 0
      then:
      - if:
          condition:
            and:
              # If the LED's are off
              - light.is_off: bdrm_led_lights
          then:
              # Turn on the LED lights
              - script.execute: pulse_effect
              - logger.log: "The LED lights are ON Pulse"
              - script.execute: turn_off

sun:
  latitude: !secret latitude
  longitude: !secret longitude

script:
  - id: turn_off
    mode: restart
    then:
      - delay: 90s
      - light.turn_off:
          id: bdrm_led_lights
          transition_length: 7.5s
      - logger.log: "LED lights are OFF"

  - id: randomize_effect
    then:
      - light.turn_on:
          id: bdrm_led_lights
          brightness: 60%
          effect: random
      - logger.log: "LED lights are ON with random effect"

  - id: rainbow_effect
    then:
      - light.turn_on:
          id: bdrm_led_lights
          brightness: 70%
          effect: addressable_rainbow
      - logger.log: "LED lights are ON with rainbow effect"

  - id: pulse_effect
    then:
      - light.turn_on:
          id: bdrm_led_lights
          brightness: 70%
          effect: pulse
      - logger.log: "LED lights are ON with pulse effect"

  - id: scan_effect
    then:
      - light.turn_on:
          id: bdrm_led_lights
          brightness: 70%
          effect: addressable_scan
      - logger.log: "LED lights are ON with scan effect"

binary_sensor:
  - platform: gpio
    pin: D5
    id: bdrm_pir
    name: "Bdrm PIR Sensor"
    device_class: motion
    on_press:
      then:
      - if:
          condition:
            and:
              # If it's night time
              - sun.is_below_horizon:
              - lambda: |-
                  auto hour = id(my_time).now().hour;
                  return hour > 12 || hour < ${off_hour};
              - light.is_off: bdrm_led_lights
          then:
              #Turn on the LED lights
              - script.execute: randomize_effect
    on_release:
      - script.execute: turn_off

time:
  platform: sntp
  servers: 192.168.0.1
  timezone: !secret timezone
  id: my_time
  on_time:
  - hours: ${off_hour}
    minutes: 0
    seconds: 0
    then:
    - light.turn_off:
        id: bdrm_led_lights

light:
  - platform: neopixelbus
    variant: WS2812
    pin: D1
    num_leds: 54
    type: GRB
    name: "FastLED WS2812B Light"
    id: bdrm_led_lights
    default_transition_length: 7.5s
    effects:
      # Use default parameters:
      - random:
      - pulse:
      - pulse:
          name: "Asymmetrical Pulse"
          transition_length:
            on_length: 1s
            off_length: 500ms
          update_interval: 1.5s
      - addressable_rainbow:
      - addressable_rainbow:
          name: "Rainbow Effect"
          speed: 10
          width: 50
      - addressable_color_wipe:
      - addressable_color_wipe:
          name: "Color Wipe Effect"
          colors:
            - red: 10%
              green: 90%
              blue: 25%
              num_leds: 5
            - red: 35%
              green: 15%
              blue: 60%
              num_leds: 1
          add_led_interval: 100ms
          reverse: false
      - addressable_fireworks:
      - addressable_fireworks:
          name: "Fireworks Effect"
          update_interval: 32ms
          spark_probability: 10%
          use_random_color: true
          fade_out_rate: 120
      - addressable_scan:
      - addressable_scan:
          name: "Scan Effect"
          move_interval: 100ms
          scan_width: 5
      - addressable_random_twinkle:
      - addressable_random_twinkle:
          name: Random "Twinkle Effect"
          twinkle_probability: 15%
          progress_interval: 32ms
      

And here’s the error I receive…

[10:11:35][W][light:476]: 'FastLED WS2812B Light' - No such effect 'addressable_rainbow'
[10:11:35][D][light:036]: 'FastLED WS2812B Light' Setting:
[10:11:35][D][light:047]:   State: ON
[10:11:35][D][light:051]:   Brightness: 70%
[10:11:35][D][light:085]:   Transition length: 7.5s
[10:11:35][D][main:927]: LED lights are ON with rainbow effect
[10:11:35][D][main:860]: The LED lights are ON Rainbow

No idea why I am seeing the… ‘FastLED WS2812B Light’ - No such effect ‘addressable_rainbow’ error? Especially when the random and pulse appear to work?

I am sure it’s something I am missing, and is probably something simple. Any feedback appreciated.

I notice you have all of them listed twice. No idea if this is the cause, (I know the docs show this, but I’ve always assumed it’s an error). I’ve always dropped the duplication and never had a problem.

Hey Ben,

Thanks for the reply. Yup, tried a number of combos of config in the ‘light’ code. Including removal of duplicate names etc.

Nothing seemed to make a difference. Almost seems like anything with ‘addressable’ has an issue.

Thanks for taking the time Ben, much appreciated.

So it turns out the fix is mind numbingly simple… instead of using addressable_rainbow you use rainbow when calling the effect from a script.

So the script looks like…

  - id: rainbow_effect
    then:
      - light.turn_on:
          id: bdrm_led_lights
          brightness: 70%
          effect: rainbow
      - logger.log: "LED lights are ON with rainbow effect"

Problem solved :yum:

Seems anything with addressable in the name must be removed for it to work.

EDIT… actually, it uses the name in the light yaml code.

- addressable_color_wipe:
          name: "Color Wipe Effect"
          colors:
            - red: 20%
              green: 70%
              blue: 25%
              num_leds: 5
            - red: 35%
              green: 15%
              blue: 60%
              num_leds: 10
          add_led_interval: 100ms
          reverse: false

So to activate addressable_color_wipe you use the following…

- id: color_wipe_effect
    then:
      - light.turn_on:
          id: bdrm_led_lights
          brightness: 70%
          effect: "Color Wipe Effect"
      - logger.log: "LED lights are ON with Color Wipe effect"
1 Like