mirror of
https://github.com/esphome/esphome-docs.git
synced 2024-12-27 17:37:45 +01:00
Update light lambda effect example (#125)
* Update index.rst * Use modern API
This commit is contained in:
parent
cb2097ce6a
commit
e30cc782f1
@ -278,15 +278,19 @@ This effect allows you to write completely custom light effects yourself using :
|
||||
update_interval: 1s
|
||||
lambda: |-
|
||||
static int state = 0;
|
||||
auto call = id(my_light).turn_on();
|
||||
// Transtion of 1000ms = 1s
|
||||
call.set_transition_length(1000);
|
||||
if (state == 0) {
|
||||
id(my_light).start_transition(light::LightColorValues::from_rgb(1.0, 1.0, 1.0)));
|
||||
call.set_rgb(1.0, 1.0, 1.0);
|
||||
} else if (state == 1) {
|
||||
id(my_light).start_transition(light::LightColorValues::from_rgb(1.0, 0.0, 1.0)));
|
||||
call.set_rgb(1.0, 0.0, 1.0);
|
||||
} else if (state == 2) {
|
||||
id(my_light).start_transition(light::LightColorValues::from_rgb(0.0, 0.0, 1.0)));
|
||||
call.set_rgb(0.0, 0.0, 1.0);
|
||||
} else {
|
||||
id(my_light).start_transition(light::LightColorValues::from_rgb(0.0, 0.0, 0.0)));
|
||||
call.set_rgb(1.0, 0.0, 0.0);
|
||||
}
|
||||
call.execute();
|
||||
state += 1;
|
||||
if (state == 4)
|
||||
state = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user