Hi all,
I build myself a Nanoleaf replica, where each leaf has 12 addressable LED (WS2812B strip) that is configured like that:
light:
- platform: neopixelbus
variant: WS2812X
type: GRB
pin: GPIO3
num_leds: 228
name: "Nanoleaf"
color_correct: [93%, 93%, 93%]
id: nanoleaf_1
I successfully wrote a Lambda that changes the color of a single leaf. It is working fine, however, I couldn’t figure out how to transition (fade) to the color instead of a hard color change.
Reading the ESPHome light documentation I saw I could use set_transition_lenght
, however, it is under lights and not addressablelight, and I got confused with all the inheritance stuff and got stuck.
I also looked at the esphome::Color Struct Reference and just found a fade_to_white
and fade_to_black
functions, but could not find a reference to fade to a color.
Extract from the Ligh Lambda Documentation
auto call = id(my_light).turn_on();
// Transition of 1000ms = 1s
call.set_transition_length(1000);
call.set_rgb(1.0, 1.0, 1.0);
My Addresable Lambda Effect
- addressable_lambda:
name: "Random Triangule Off"
update_interval: 5s
lambda: |-
// it.size() - Number of LEDs
// it[num] - Access the LED at index num.
// Set the LED at num to the given r, g, b values
// it[num] = Color(r, g, b);
// Get the color at index num (Color instance)
// it[num].get();
// Get a random starting triangule
uint16_t start_triangule = rand() % 19;
// Set the base color
it.all() = current_color;
// Set the triangule color
it.range(start_triangule * 12, (start_triangule*12) + 12) = light::ESPColor(0, 0, 0);
Is it possible to use it
with set_rgb
or I am trying something that doesn’t make any sense?
Sorry if the question is too basic, I am new to all this