Change WS2812 5050 LED Color using Home Assistant Automation

HI all,
I have a WS2812 RGB LED, connected to esp32 (flashed with esphome) and integrated into HA.
In HA, I can click on the light switch and use the rgb color wheel to change the color and brightness of the light. However, when I add the rgb values into an automation or change the values using State tab, the leds do not respond.

Below is my esphome code:

  - platform: fastled_clockless
    chipset: WS2812
    pin: GPIO12
    num_leds: 12
    rgb_order: GRB
    name: "FastLED WS2812 Light"

Below is what I’m passing in the States attributes yaml

brightness: 155
hs_color: 0,100
rgb_color: 255,0,0
xy_color: 0.701,0.299
friendly_name: FastLED WS2812 Light
supported_features: 57

Below is a sample automation I wrote to change rgb color when DHT22 humidity changes:

- id: '1573017141586'
  alias: New Automation2
  description: ''
  - below: '70'
    entity_id: sensor.living_room_humidity
    platform: numeric_state
  condition: []
  - data:
      entity_id: light.fastled_ws2812_light
      rgb_color: [0,0,255]

There is no service here to tell HA what to do.

  - data:
      entity_id: light.fastled_ws2812_light
      rgb_color: [0,0,255]


    service: light.turn_on
      entity_id: light.fastled_ws2812_light
      rgb_color: [0,0,255]
1 Like

Thanks man. It worked. After changing the code it was not working but silly me, the automation toggle was off in the editor, after turning it on worked flawlessly.

Just to check, my led has 12 individual rgb lights, is it possible to control the 12leds individually using some code in HA?

Not sure about fastled.

I use WLED. Even though that has a ridiculous number of effects and pallets (and there is a home assistant integration on the way) I’m pretty sure individual LED control is not possible.

I do remember reading something about partitioning LED strings in ESPhome, but for individual LED control you would have to partition it into the number of LEDs in your string, which is probably not viable.