[SOLVED] Set LED on_state trigger

Hi

I want to set 2 LED’s to a colour each the colour is changed (2 LED’s will always be 1 colour)

Here’s what I have:

esphome:
  name: pacman

esp8266:
  board: esp01_1m
  framework:
    version: 2.7.4

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password
 
# Enable logging
logger:
 
# Enable Home Assistant API
api:
 
ota:
 
light:
  - platform: fastled_clockless
    chipset: WS2812
    pin: 2
    num_leds: 30
    name: 'Pacman'
    rgb_order: GRB
    on_state:
      lambda: |-
        it[28] = Color(255,255,255);
        it[29] = Color(255,255,255);
    effects:
    - addressable_lambda:
        name: "Pacman Green with White Eyes"
        update_interval: 16ms
        lambda: |-
          it.range(0, 28) = Color(0,255,0);
          it[28] = Color(255,255,255);
          it[29] = Color(255,255,255);

I can use an effect to get the desired output but I don’t really want to have to create x number of effects just so I can select some colours.

I receive an error when compiling:

INFO Reading configuration /config/esphome/pacman.yaml...
WARNING The selected Arduino framework version is not the recommended one. If there are connectivity or build issues please remove the manual version.
WARNING The selected Arduino framework version is not the recommended one. If there are connectivity or build issues please remove the manual version.
INFO Generating C++ source...
INFO Compiling app...
Processing pacman (board: esp01_1m; framework: arduino; platform: platformio/espressif8266 @ 2.6.3)
--------------------------------------------------------------------------------
HARDWARE: ESP8266 80MHz, 80KB RAM, 1MB Flash
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
Dependency Graph
|-- <ESP8266WiFi> 1.0
|-- <ESP8266mDNS> 1.2
|-- <FastLED> 3.3.2
Compiling /data/pacman/.pioenvs/pacman/src/main.cpp.o
/config/esphome/pacman.yaml: In lambda function:
/config/esphome/pacman.yaml:30:7: error: 'it' was not declared in this scope
         it[28] = Color(255,255,255);
       ^
At global scope:
cc1plus: warning: unrecognized command line option "-Wno-nonnull-compare" [enabled by default]
*** [/data/pacman/.pioenvs/pacman/src/main.cpp.o] Error 1
========================== [FAILED] Took 4.05 seconds ==========================

Is there any way to do this?

For anyone wondering I managed to achieve this but using the addressable_set action

esphome:
  name: pacman

esp8266:
  board: esp01_1m
  framework:
    version: 2.7.4

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password
 
# Enable logging
logger:
 
# Enable Home Assistant API
api:
 
ota:
 
light:
  - platform: fastled_clockless
    id: pac
    chipset: WS2812
    pin: 2
    num_leds: 30
    name: 'Pacman'
    default_transition_length: 0s
    rgb_order: GRB
    on_state:
      - delay: 100ms
      - light.addressable_set:
          id: pac
          range_from: 28
          range_to: 30
          red: 100%
          green: 100%
          blue: 100%