124 lines
3.1 KiB
YAML
124 lines
3.1 KiB
YAML
substitutions:
|
|
node_name: lvng-xmas
|
|
timezone: Europe/Warsaw
|
|
countdown_fill: 'Color(0, 255, 0)'
|
|
countdown_empty: 'Color(0, 0, 255)'
|
|
countdown_reversed: 'true'
|
|
|
|
packages:
|
|
common: !include lib/pkg-common.yaml
|
|
api: !include lib/pkg-api.yaml
|
|
wifi: !include lib/pkg-wifi.yaml
|
|
|
|
esphome:
|
|
platform: ESP8266
|
|
board: d1_mini
|
|
|
|
time:
|
|
- platform: sntp
|
|
timezone: ${timezone}
|
|
id: time_sntp
|
|
|
|
on_time:
|
|
- seconds: 0
|
|
minutes: 0
|
|
hours: 6
|
|
then: &light-turn-on
|
|
- light.turn_on:
|
|
id: xmas
|
|
brightness: 0.9
|
|
red: 1.0
|
|
green: 1.0
|
|
blue: 1.0
|
|
effect: Random Twinkle
|
|
|
|
- seconds: 0
|
|
minutes: 0
|
|
hours: 0
|
|
then:
|
|
- if:
|
|
condition:
|
|
lambda: |-
|
|
auto time = id(time_sntp).now();
|
|
return time.day_of_month == 1 && time.month == 1;
|
|
then: *light-turn-on
|
|
else: &light-turn-off
|
|
- light.turn_off:
|
|
id: xmas
|
|
|
|
# New Year
|
|
- seconds: 0
|
|
minutes: 0
|
|
hours: 23
|
|
days_of_month: 31
|
|
months: 12
|
|
then:
|
|
- light.turn_on:
|
|
id: xmas
|
|
brightness: 1.0
|
|
effect: Countdown to Midnight
|
|
|
|
#light:
|
|
# - name: xmas
|
|
# id: xmas
|
|
# platform: fastled_clockless
|
|
# chipset: WS2811
|
|
# pin: D1
|
|
# num_leds: 100
|
|
|
|
light:
|
|
- name: xmas
|
|
id: xmas
|
|
platform: neopixelbus
|
|
|
|
pin: D1
|
|
|
|
# WARNING: THIS IS PIN RX
|
|
# pin: 3
|
|
# method:
|
|
# type: esp8266_dma
|
|
|
|
variant: WS2811
|
|
type: RGB
|
|
num_leds: 100
|
|
|
|
effects:
|
|
- addressable_twinkle:
|
|
twinkle_probability: 10%
|
|
- addressable_random_twinkle:
|
|
twinkle_probability: 20%
|
|
- addressable_scan:
|
|
scan_width: 4
|
|
- addressable_scan:
|
|
name: Scan Fast
|
|
scan_width: 5
|
|
move_interval: 5ms
|
|
|
|
- addressable_lambda:
|
|
# linear countdown toward midnight
|
|
name: Countdown to Midnight
|
|
update_interval: 100ms
|
|
lambda: !lambda |-
|
|
const bool reversed = ${countdown_reversed};
|
|
const Color color_fill = ${countdown_fill};
|
|
const Color color_empty = ${countdown_empty};
|
|
|
|
auto time = id(time_sntp).now();
|
|
if (time.is_valid()) {
|
|
it.all() = color_empty;
|
|
if (time.hour >= 12) {
|
|
int n = (24 - time.hour) * 60 - time.minute;
|
|
//ESP_LOGD("midnight", "time.hour=%d time.minute=%d n=%d it.size()=%d", time.hour, time.minute, n, it.size());
|
|
if (!reversed) {
|
|
it.range(max(it.size() - 1 - n, 0), it.size() - 1) = color_fill;
|
|
} else {
|
|
it.range(0, min(n, it.size() - 1)) = color_fill;
|
|
}
|
|
} else {
|
|
//ESP_LOGD("midnight", "time.hour=%d", time.hour);
|
|
}
|
|
} else {
|
|
ESP_LOGD("midnight", "time is invalid");
|
|
it.all() = Color(255, 0, 0);
|
|
}
|