Accessing Individual LEDs

Hi,
Can anyone explain how I can access individual leds on a WS2812b matrix on a node mcu esp8266?
I am able to apply built in effects but I’d like to set colour and brightness settings for each individual led.
I built a night light for my kids that slowly fades from blue to (almost) red and back using the code below on an arduino nano. How do I accomplish the same thing on an esp8266 device?
More generally, how can I access a specific led in a matrix and change its values based on a function?

#include <FastLED.h>
#define DATA_PIN 6
#define NUM_LEDS 16

#define LED_TYPE WS2812B
#define COLOR_ORDER GRB
CRGB leds[NUM_LEDS];

#define MaxBrightness 200
#define MinBrightness 5
#define FADEDELAY 500

void setup(){
FastLED.addLeds<LED_TYPE,DATA_PIN,COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);
// FastLED.setBrightness(BRIGHTNESS);
}
void loop(){
// fading color from blue to pink:
for( int colorStep=0; colorStep<195; colorStep++ ) {
// Set brightness via variable resistor (knob)
int val = analogRead(2);
int NumtToBrightness = map(val, 0, 1023, MinBrightness, MaxBrightness);
FastLED.setBrightness(NumtToBrightness);

  int r = colorStep;  // Redness starts at zero and goes up to full
  int b = 255-colorStep;  // Blue starts at full and goes down to zero
  int g = 0;              // No green needed to go from blue to red

  fill_solid(leds,NUM_LEDS,CRGB(r,g,b));
  FastLED.show();

  delay(FADEDELAY); 

}

// fading color from pink to blue:
for (int colorStep=194; colorStep>=0; colorStep-- ){
// Set brightness via variable resistor (knob)
int val = analogRead(2);
int NumtToBrightness = map(val, 0, 1023, MinBrightness, MaxBrightness);
FastLED.setBrightness(NumtToBrightness);

  int r=colorStep;
  int g=0;
  int b=255-colorStep;
  fill_solid(leds,NUM_LEDS,CRGB(r,g,b));
  FastLED.show();

  delay(FADEDELAY);

}
}

Exactly the same I would have thought.

If I paste that code in the node’s yaml file it fails validation.

Sorry I didn’t even see you were in the esphome section. Silly me.

This thread may have the answer (although it is inconclusive) Can I address individual FastLED Clockless Lights?

Maybe have a look at including your C code using this:

https://esphome.io/custom/custom_component.html

I’m confused. Does the code in the example go in the node’s yaml file? If I try to include it there it won’t validate. Where does my C code or custom component definition go?

your C code goes in a file (eg: my_custom_component.h) that you reference within the yaml. It’s all on that page:

image