Here is my YAML
it is basically a D1 mini 8266 that controls 2 LED Strips.
I have added the BME680
thank you for you time
esphome:
name: tvledlight
platform: ESP8266
board: d1_mini
platformio_options:
build_flags:
- -DPIO_FRAMEWORK_ARDUINO_MMU_CACHE16_IRAM48_SECHEAP_SHARED
wifi:
ssid: "XXXXX"
password: "XXXXX"
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "TV Led Light"
password: "XXXXXX"
#web_server:
# port: 80
#captive_portal:
# Enable logging
logger:
# level: VERY_VERBOSE
debug:
# Enable Home Assistant API
api:
encryption:
key: XXXXXXXXXXXx
ota:
- platform: esphome
id: my_ota
password: "XXXX"
i2c:
# sda: GPIO5
# scl: GPIO4
# scan: True
# frequency: 8khz
bme68x_bsec2_i2c:
address: 0x77
model: bme680
operating_age: 28d
sample_rate: LP
supply_voltage: 3.3V
binary_sensor:
- platform: status
name: "TVLedLight_Status"
sensor:
- platform: wifi_signal
name: "TVLedLight Wifi"
- platform: homeassistant
id: "id_kitchenled_percentage_from_ha"
entity_id: sensor.percentage_light
- platform: bme68x_bsec2
temperature:
name: "LivingRoom_BME680_Temperature"
pressure:
name: "LivingRoom_BME680_Pressure"
humidity:
name: "LivingRoom_BME680_Humidity"
iaq:
name: "LivingRoom_BME680_IAQ"
co2_equivalent:
name: "LivingRoom_BME680_CO2_Equivalent"
breath_voc_equivalent:
name: "LivingRoom_BME680_Breath_VOC_Equivalent"
gas_resistance:
name: "LivingRoom_BME680_Gas_Resistance"
switch:
- platform: restart
name: "TVLedLight Restart"
light:
- platform: neopixelbus
type: GRB
variant: WS2811
pin: GPIO15
num_leds: 212
name: "TV Led Light"
id: light_1
effects:
- addressable_rainbow:
- addressable_rainbow:
name: Rainbow Effect With Custom Values
speed: 100
width: 50
- addressable_color_wipe:
- addressable_color_wipe:
name: Color Wipe Effect With Custom Values
colors:
- red: 100%
green: 100%
blue: 100%
num_leds: 1
- red: 0%
green: 0%
blue: 0%
num_leds: 1
add_led_interval: 100ms
reverse: False
- addressable_fireworks:
- addressable_fireworks:
name: Fireworks Effect With Custom Values
update_interval: 32ms
spark_probability: 10%
use_random_color: false
fade_out_rate: 120
- addressable_scan:
- addressable_scan:
name: Scan Effect With Custom Values
move_interval: 10ms
scan_width: 10
- random:
- random:
name: Random Effect With Custom Values
transition_length: 5s
update_interval: 7s
- strobe:
- strobe:
name: Strobe Effect With Custom Values
colors:
- state: True
brightness: 100%
red: 100%
green: 90%
blue: 0%
duration: 500ms
- state: False
duration: 250ms
- state: True
brightness: 100%
red: 0%
green: 100%
blue: 0%
duration: 500ms
- strobe:
name: Strobe Red
colors:
- state: True
brightness: 100%
red: 100%
green: 0%
blue: 0%
duration: 50ms
- state: False
duration: 50ms
- flicker:
- flicker:
name: Flicker Effect With Custom Values
alpha: 95%
intensity: 1.5%
- addressable_twinkle:
- addressable_twinkle:
name: Twinkle Effect With Custom Values
twinkle_probability: 5%
progress_interval: 4ms
- addressable_flicker:
- addressable_flicker:
name: Addressable Flicker Effect With Custom Values
update_interval: 16ms
intensity: 5%
- addressable_lambda:
name: "Christmas RedGreen"
update_interval: 1000ms
lambda: |-
static int step = 0;
if (step == 0){
for (int i = 1; i < it.size(); i+=2) {
it[i] = light::ESPColor(255, 0, 18);
}
for (int i = 0; i < it.size(); i+=2) {
it[i] = light::ESPColor(0, 179, 44);
}
step = 1;
} else {
for (int i = 1; i < it.size(); i+=2) {
it[i] = light::ESPColor(0, 179, 44);
}
for (int i = 0; i < it.size(); i+=2) {
it[i] = light::ESPColor(255, 0, 18);
}
step = 0;
}
- addressable_lambda:
name: "Halloween"
update_interval: 1000ms
lambda: |-
static int duration_on = 500;
static int duration_off = 500;
// Randomize durations between 100ms to 1000ms for ON and OFF states
duration_on = random(100, 1000);
duration_off = random(100, 1000);
// Toggle light on and off with random durations
if (id(light_1).current_values.is_on()) {
id(light_1).turn_off();
delay(duration_off);
} else {
id(light_1).turn_on().set_brightness(1.0).perform();
//id(light_1).turn_on();
//id(light_1).set_brightness(1.0); // Set to full brightness
//id(light_1).set_red(1.0); // Set color to red
delay(duration_on);
}
- addressable_lambda:
name: "Fire"
update_interval: 15ms
lambda: |-
int Cooling = 55;
int Sparking = 110;
static byte heat[188];
int cooldown;
// Step 1. Cool down every cell a little
for( int i = 0; i < it.size(); i++) {
cooldown = random(0, ((Cooling * 10) / it.size()) + 2);
if(cooldown>heat[i]) {
heat[i]=0;
} else {
heat[i]=heat[i]-cooldown;
}
}
// Step 2. Heat from each cell drifts 'up' and diffuses a little
for( int k= it.size() - 1; k >= 2; k--) {
heat[k] = (heat[k - 1] + heat[k - 2] + heat[k - 2]) / 3;
}
// Step 3. Randomly ignite new 'sparks' near the bottom
if( random(255) < Sparking ) {
int y = random(7);
heat[y] = heat[y] + random(160,255);
}
// Step 4. Convert heat to LED colors
for( int Pixel = 0; Pixel < it.size(); Pixel++) {
// Scale 'heat' down from 0-255 to 0-191
byte t192 = round((heat[Pixel]/255.0)*191);
// calculate ramp up from
byte heatramp = t192 & 0x3F; // 0..63
heatramp <<= 2; // scale up to 0..252
// figure out which third of the spectrum we're in:
//this is where you can reverse the effect by switching the commented out lines in all 3 places.
if( t192 > 0x80) { // hottest
//it[it.size() - Pixel - 1] = ESPColor(255, 255, heatramp);
it[Pixel] = ESPColor(255, 255, heatramp);
} else if( t192 > 0x40 ) { // middle
//it[it.size() - Pixel - 1] = ESPColor(255, heatramp, 0);
it[Pixel] = ESPColor(255, heatramp, 0);
} else { // coolest
//it[it.size() - Pixel - 1] = ESPColor(heatramp, 0, 0);
it[Pixel] = ESPColor(heatramp, 0, 0);
}
}
- addressable_lambda:
name: "percentage level"
lambda: |-
const int leds_to_use=it.size(); // you can change that if you don't want all the leds to be used
float percentage = id(id_kitchenled_percentage_from_ha).state;
if (isnan(percentage)) {
percentage = 0;
}
// number of leds that are drawn with full brightness
int full_leds = int(leds_to_use*percentage/100.0);
// set those leds to the current_color of the light
it.range(0, full_leds) = current_color;
// if full_leds is not the last led, render a remaining fraction of a led dimmed
if (full_leds < leds_to_use) {
it[full_leds] = current_color*((leds_to_use*percentage/100.0-full_leds)*255);
}
// set the remaing leds to black
if (full_leds+1 < leds_to_use) {
it.range(full_leds+1, leds_to_use) = ESPColor::BLACK; // change the color to something else if you want
}
- platform: partition
name: "Section1"
segments:
- id: light_1
from: 0
to: 49
effects:
- addressable_rainbow:
name: Rainbow
- addressable_twinkle:
- platform: partition
name: "Section2"
segments:
- id: light_1
from: 50
to: 106
effects:
- addressable_rainbow:
name: Rainbow
- addressable_twinkle:
- platform: partition
name: "Section3"
segments:
- id: light_1
from: 107
to: 154
effects:
- addressable_rainbow:
name: Rainbow
- addressable_twinkle:
- platform: partition
name: "Section4"
segments:
- id: light_1
from: 155
to: 211
effects:
- addressable_rainbow:
name: Rainbow
- addressable_twinkle:
- platform: neopixelbus
type: GRB
variant: WS2811
pin: GPIO2
num_leds: 69
name: "TV Led Light Bottom"
effects:
- addressable_rainbow:
- addressable_rainbow:
name: Rainbow Effect With Custom Values
speed: 100
width: 50
- addressable_color_wipe:
- addressable_color_wipe:
name: Color Wipe Effect With Custom Values
colors:
- red: 100%
green: 100%
blue: 100%
num_leds: 1
- red: 0%
green: 0%
blue: 0%
num_leds: 1
add_led_interval: 100ms
reverse: False
- addressable_fireworks:
- addressable_fireworks:
name: Fireworks Effect With Custom Values
update_interval: 32ms
spark_probability: 10%
use_random_color: false
fade_out_rate: 120
- addressable_scan:
- addressable_scan:
name: Scan Effect With Custom Values
move_interval: 10ms
scan_width: 10
- random:
- random:
name: Random Effect With Custom Values
transition_length: 5s
update_interval: 7s
- strobe:
- strobe:
name: Strobe Effect With Custom Values
colors:
- state: True
brightness: 100%
red: 100%
green: 90%
blue: 0%
duration: 500ms
- state: False
duration: 250ms
- state: True
brightness: 100%
red: 0%
green: 100%
blue: 0%
duration: 500ms
- strobe:
name: Strobe Red
colors:
- state: True
brightness: 100%
red: 100%
green: 0%
blue: 0%
duration: 50ms
- state: False
duration: 50ms
- flicker:
- flicker:
name: Flicker Effect With Custom Values
alpha: 95%
intensity: 1.5%
- addressable_twinkle:
- addressable_twinkle:
name: Twinkle Effect With Custom Values
twinkle_probability: 5%
progress_interval: 4ms
- addressable_flicker:
- addressable_flicker:
name: Addressable Flicker Effect With Custom Values
update_interval: 16ms
intensity: 5%
- addressable_lambda:
name: "Christmas RedGreen"
update_interval: 1000ms
lambda: |-
static int step = 0;
if (step == 0){
for (int i = 1; i < it.size(); i+=2) {
it[i] = light::ESPColor(255, 0, 18);
}
for (int i = 0; i < it.size(); i+=2) {
it[i] = light::ESPColor(0, 179, 44);
}
step = 1;
} else {
for (int i = 1; i < it.size(); i+=2) {
it[i] = light::ESPColor(0, 179, 44);
}
for (int i = 0; i < it.size(); i+=2) {
it[i] = light::ESPColor(255, 0, 18);
}
step = 0;
}
- addressable_lambda:
name: "Fire"
update_interval: 15ms
lambda: |-
int Cooling = 55;
int Sparking = 110;
static byte heat[188];
int cooldown;
// Step 1. Cool down every cell a little
for( int i = 0; i < it.size(); i++) {
cooldown = random(0, ((Cooling * 10) / it.size()) + 2);
if(cooldown>heat[i]) {
heat[i]=0;
} else {
heat[i]=heat[i]-cooldown;
}
}
// Step 2. Heat from each cell drifts 'up' and diffuses a little
for( int k= it.size() - 1; k >= 2; k--) {
heat[k] = (heat[k - 1] + heat[k - 2] + heat[k - 2]) / 3;
}
// Step 3. Randomly ignite new 'sparks' near the bottom
if( random(255) < Sparking ) {
int y = random(7);
heat[y] = heat[y] + random(160,255);
}
// Step 4. Convert heat to LED colors
for( int Pixel = 0; Pixel < it.size(); Pixel++) {
// Scale 'heat' down from 0-255 to 0-191
byte t192 = round((heat[Pixel]/255.0)*191);
// calculate ramp up from
byte heatramp = t192 & 0x3F; // 0..63
heatramp <<= 2; // scale up to 0..252
// figure out which third of the spectrum we're in:
//this is where you can reverse the effect by switching the commented out lines in all 3 places.
if( t192 > 0x80) { // hottest
//it[it.size() - Pixel - 1] = ESPColor(255, 255, heatramp);
it[Pixel] = ESPColor(255, 255, heatramp);
} else if( t192 > 0x40 ) { // middle
//it[it.size() - Pixel - 1] = ESPColor(255, heatramp, 0);
it[Pixel] = ESPColor(255, heatramp, 0);
} else { // coolest
//it[it.size() - Pixel - 1] = ESPColor(heatramp, 0, 0);
it[Pixel] = ESPColor(heatramp, 0, 0);
}
}
- addressable_lambda:
name: "percentage level"
lambda: |-
const int leds_to_use=it.size(); // you can change that if you don't want all the leds to be used
float percentage = id(id_kitchenled_percentage_from_ha).state;
if (isnan(percentage)) {
percentage = 0;
}
// number of leds that are drawn with full brightness
int full_leds = int(leds_to_use*percentage/100.0);
// set those leds to the current_color of the light
it.range(0, full_leds) = current_color;
// if full_leds is not the last led, render a remaining fraction of a led dimmed
if (full_leds < leds_to_use) {
it[full_leds] = current_color*((leds_to_use*percentage/100.0-full_leds)*255);
}
// set the remaing leds to black
if (full_leds+1 < leds_to_use) {
it.range(full_leds+1, leds_to_use) = ESPColor::BLACK; // change the color to something else if you want
}