I realize this post is a few months old, so maybe you resolved the issue already. But just in case…
Your code worked for me–the light matrix shows up in HA and can be turned on/off and color changed. So it’s not a code issue. Maybe check your wiring (e.g. are you connecting to the DIN on the square rather than the DOUT)? Or it could be defective hardware?
For others who find this post in the future, I wrote some code to change the light’s color (green, orange, or red) based on the CO2 level. Works great:
captive_portal:
light:
- platform: neopixelbus
variant: WS2812
pin: D8
num_leds: 64
type: GRB
id: neopixel_light
name: "NeoPixel Light"
color_correct: [25%, 25%, 25%]
uart:
- rx_pin: D4
tx_pin: D3
baud_rate: 9600
id: uart_2
# Define sensor for CO2 measurement
sensor:
- platform: senseair
uart_id: uart_2
co2:
id: co2
name: "SenseAir CO2 Value"
update_interval: 60s
# Set light color based on CO2 reading
interval:
- interval: 60sec
then:
- light.control:
id: neopixel_light
red: !lambda |
if ((id(co2).state) > 800) {
return 1;
} else {
return 0;
}
green: !lambda |
if ((id(co2).state) > 1000) {
return 0;
} else if ((id(co2).state) > 800) {
return 0.65;
} else {
return 1;
}
blue: 0