Hello all,
I need some help with addressable lambda effect. I found great lambda effect, which is working fine when you specify specific color in RGB format (see below). I would like to amend that lambda, so I can replace RGB value in bracets () with input_select:
I have created in Home Assistant with RGB values (see below) and then loaded it onto ESPHome as text_sensor:
with id:
tag (see below). Unfortunately I get and error when I try to install in onto my d1mini (see below). Is it even possible to load variables to Lambda effect? Also, is it possible to replace update_interval:
value with variable? When I try to replace it with (id(door_led_s_top_lock_speed)
, I get error, that this entry is not templateable.
input_select:
code in HA:
door_led_s_top_lock_color:
name: "Door LED's top lock color"
options:
- '255, 0, 0' #red
- '0, 0, 255' #blue
- '0, 255, 0' #green
- '255, 255, 0' #yellow
icon: mdi:pallete
door_led_s_top_lock_speed:
name: Door LED's top lock speed
options:
- '10ms'
- '25ms'
- '50ms'
- '100ms'
- '300ms'
- '500ms'
icon: mdi:star-shooting-outline
ESPHome code:
text_sensor:
- platform: homeassistant
name: Door led's top lock color
id: door_led_s_top_lock_color
entity_id: input_select.door_led_s_top_lock_color
- platform: homeassistant
name: Door led's top lock speed
id: door_led_s_top_lock_speed
entity_id: input_select.door_led_s_top_lock_speed
light:
- platform: neopixelbus
type: GRB
variant: WS2812X
pin: D7
num_leds: 50
name: "Door LED's"
id: door_leds
gamma_correct: 0
default_transition_length: 0s
effects:
- !include common/led_effects/lambda.yaml
Lambda effect:
addressable_lambda:
name: "lambda"
update_interval: 10ms // is it possible to replace THIS with `id:` tag?
lambda: |-
static auto TAG = "Falling light";
static uint16_t progress = 0;
// static Color mRed = Color(255, 0, 0); // Original value
static Color mRed = Color(id(door_led_s_top_lock_color)); // <-- how to replace THIS ??
if (initial_run) {
progress = 0;
it.all() = Color::BLACK;
ESP_LOGD(TAG, "initial run");
ESP_LOGD(TAG, "it.size() = %d", it.size());
}
else {
if (progress < it.size()) {
it[progress] = mRed;
progress++;
//ESP_LOGD(TAG, "increas progress : %d", progress);
}
else {
}
};
Error: