-
Notifications
You must be signed in to change notification settings - Fork 0
/
lobby-led-light.yaml
234 lines (215 loc) · 6.74 KB
/
lobby-led-light.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
globals:
- id: intensity_red
type: float
restore_value: no
initial_value: '0'
- id: intensity_green
type: float
restore_value: no
initial_value: '0'
- id: intensity_blue
type: float
restore_value: no
initial_value: '0'
# moon/sun color, 1-1-1 for sun.
- id: luminary_red
type: float
restore_value: no
initial_value: '1'
- id: luminary_green
type: float
restore_value: no
initial_value: '0.88'
- id: luminary_blue
type: float
restore_value: no
initial_value: '0'
substitutions:
device_name: lobby-led-light
latitude: !secret gps_latitude_str
longitude: !secret gps_longitude_str
elevation: !secret gps_elevation_str
packages:
device_common: !include .device_common.yaml
esphome:
name: ${device_name}
platform: ESP32
board: esp32doit-devkit-v1
includes:
- includes/led_rect_effect.h
- includes/luminary_effect.h
libraries:
- marscaper/Ephemeris
on_boot:
priority: 300.0
then:
- script.execute: turn_on_light
- lambda: |-
//Ephemeris::setLocationOnEarth(latitude, longitude);
//Ephemeris::flipLongitude(true);
//Ephemeris::setAltitude(elevation);
LuminaryEffect::setup_effect(${latitude}, ${longitude}, ${elevation});
number:
- platform: template
id: wheel_angle
name: Wheel angle
mode: slider
min_value: 0
max_value: 360
step: 1
optimistic: true
- platform: template
id: led_num
name: Led number
mode: slider
min_value: 0
max_value: 300
step: 1
optimistic: true
light:
- platform: fastled_clockless
id: lobbyledlight
chipset: WS2812B
pin: GPIO13
num_leds: 300
rgb_order: GRB
name: "Lobby Led Light"
restore_mode: ALWAYS_OFF
default_transition_length: 1500ms
effects:
- flicker:
name: flicker
alpha: 95%
intensity: 1.5%
- addressable_rainbow:
- addressable_lambda:
name: "LedRect auto wheel effect"
update_interval: 20ms
lambda: |-
static int16_t angle = 0;
uint8_t red = to_uint8_scale(id(intensity_red));
uint8_t green = to_uint8_scale(id(intensity_green));
uint8_t blue = to_uint8_scale(id(intensity_blue));
Color background_color = Color(red, green, blue);
uint8_t effect_red = to_uint8_scale(id(luminary_red));
uint8_t effect_green = to_uint8_scale(id(luminary_green));
uint8_t effect_blue = to_uint8_scale(id(luminary_blue));
Color effect_color = Color(effect_red, effect_green, effect_blue);
it.all().set(background_color);
LedRectEffect::set_effect(it, effect_color, angle);
angle += 1;
if (angle > 360) {
angle -= 360;
}
- addressable_lambda:
name: "LedRect manual wheel effect"
update_interval: 20ms
lambda: |-
uint16_t angle = static_cast<uint16_t>(id(wheel_angle).state);
uint8_t red = to_uint8_scale(id(intensity_red));
uint8_t green = to_uint8_scale(id(intensity_green));
uint8_t blue = to_uint8_scale(id(intensity_blue));
Color background_color = Color(red, green, blue);
uint8_t effect_red = to_uint8_scale(id(luminary_red));
uint8_t effect_green = to_uint8_scale(id(luminary_green));
uint8_t effect_blue = to_uint8_scale(id(luminary_blue));
Color effect_color = Color(effect_red, effect_green, effect_blue);
it.all().set(background_color);
LedRectEffect::set_effect(it, effect_color, angle);
- addressable_lambda:
name: "Set individual led"
update_interval: 20ms
lambda: |-
uint16_t num = static_cast<uint16_t>(id(led_num).state);
uint8_t red = to_uint8_scale(id(intensity_red));
uint8_t green = to_uint8_scale(id(intensity_green));
uint8_t blue = to_uint8_scale(id(intensity_blue));
Color background_color = Color(red, green, blue);
it.all().set(background_color);
it[num] = Color(255, 0, 0);
- addressable_lambda:
name: "Moon/sun location"
update_interval: 60s
lambda: |-
uint8_t red = to_uint8_scale(id(intensity_red));
uint8_t green = to_uint8_scale(id(intensity_green));
uint8_t blue = to_uint8_scale(id(intensity_blue));
Color background_color = Color(red, green, blue);
uint8_t effect_red = to_uint8_scale(id(luminary_red));
uint8_t effect_green = to_uint8_scale(id(luminary_green));
uint8_t effect_blue = to_uint8_scale(id(luminary_blue));
Color effect_color = Color(effect_red, effect_green, effect_blue);
ESPTime time = id(sntp_time)->now();
LuminaryEffect::do_effect(time, it, background_color, effect_color);
time:
- id: !extend sntp_time
on_time_sync:
then:
- script.execute: set_daylight_color
sun:
id: sun_id
latitude: !secret gps_latitude
longitude: !secret gps_longitude
on_sunrise:
then:
- script.execute: set_daylight_color
on_sunset:
then:
- script.execute: set_daylight_color
script:
- id: turn_on_light
then:
- light.turn_on:
id: lobbyledlight
brightness: 80%
red: 1
green: 1
blue: 1
effect: none
- id: set_light_color
then:
- light.control:
id: lobbyledlight
red: !lambda |-
return id(intensity_red);
green: !lambda |-
return id(intensity_green);
blue: !lambda |-
return id(intensity_blue);
transition_length: 1000ms
- id: set_daylight_color
then:
- script.wait: turn_on_light
- if:
condition:
sun.is_above_horizon
then:
- globals.set:
id: intensity_red
value: '1.0'
- globals.set:
id: intensity_green
value: '.67'
- globals.set:
id: intensity_blue
value: '.11'
- globals.set:
id: luminary_red
value: '1.0'
- globals.set:
id: luminary_green
value: '1.0'
- globals.set:
id: luminary_blue
value: '1.0'
else:
- globals.set:
id: intensity_red
value: '.0'
- globals.set:
id: intensity_green
value: '1.0'
- globals.set:
id: intensity_blue
value: '1.0'
- script.execute: set_light_color