esphome / esphome/feature-requests

Option to use an AddressableLight in a lambda

Open
#1,665 4 comments 3 reactions 0 assignees View on GitHub
component: addressable_light enhancement Type: Automation
Dominant language
No language data
Stars
450
Forks
29
PR merge metrics
No merged PRs in 30d

Description

**Describe the problem you have/What new integration you would like**

For an addressable light, in example neopixlebus, I can define an addressable-lambda-effect. In this lambda, I do have the AddressableLight object as "it", thus it is possible to create animation, etc.
- https://esphome.io/components/light/index.html#addressable-lambda-effect

The same light in a script returns via `id(light_id)` an AddressableLightState object and thus only the basic light operations (turn_on/ off, toggle, ..) are accessible in the script.

**Please describe your use case for this integration and alternatives you've tried:**

I use an e-ink screen together with a rotary encoder. The e-ink screen is not responsible enough to give me good feedback for my inputs, thus I want to use an additional RGB ring, that updates with every `on_value:` call.
For this to work, I need to have the AddressableLight object in the lambda.

Below I added an example how I imagine it could look like.

**Additional context**

Example yaml-configuration:

```
light:
- platform: neopixelbus
id: rgb_led

script:
- id: animate
then:
- lambda: |-
static AddressableLight my_light = id(rgb_led).light();
static boolean initial_run = true;
static uint16_t progress = 0;
uint16_t changes = 0;

if (initial_run) {
progress = 0;
my_light.all() = Color::BLACK;
initial_run = false;
return;
}
for (int i = my_light.size() - 1; i > 0; i--) {
my_light[i] = my_light[i - 1].get();
}
my_light[0] = Color::random_color();
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by comparing the addressable-lambda-effect entry point with the script lambda using id(rgb_led), especially the AddressableLight and AddressableLightState types. Confirm how id(rgb_led).light() is exposed, then define done as making an AddressableLight available in the script example so the shown animation can run.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, yaml
Domain
embedded-iot
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.