-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathicicle-light2.yaml
341 lines (316 loc) · 10 KB
/
icicle-light2.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
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
# -------------------------------------
# ---- Implemented on Mirabella Genio Icicle Controller ----
# -------------------------------------
substitutions:
devicename: icicle_light2
esphome:
name: ${devicename}
platform: ESP8266
board: esp01_1m
# includes:
# - my_custom_component.h
wifi:
#power_save_mode: light # power reduced from 1.2w to 0.8w
#fast_connect: true
networks:
- ssid: !secret wifi_ssid
password: !secret wifi_password
hidden: True
manual_ip:
static_ip: !secret ip_icicle_light2
gateway: !secret ip_gateway
subnet: 255.255.255.0
domain: .homelan
ap: # Enable fallback hotspot (captive portal) in case wifi connection fails
ssid: "${devicename} Hotspot"
password: !secret password
captive_portal:
# Enable logging
logger:
# Enable Home Assistant API
api:
reboot_timeout: 0s # Dont reboot..
encryption:
key: !secret encryption_key
ota:
password: !secret password
web_server:
port: 80
auth:
username: admin
password: !secret password
binary_sensor:
- platform: gpio
pin:
number: GPIO5
inverted: true
mode: INPUT_PULLUP
name: "${devicename} Button"
on_press:
then:
- light.toggle: mainlight
output:
- platform: esp8266_pwm
id: pina
pin: GPIO14
- platform: esp8266_pwm
id: pinb
pin: GPIO12
# https://esphome.io/api/classesphome_1_1light_1_1_light_color_values.html
light:
- platform: hbridge
id: mainlight
name: "${devicename} Light"
pin_a: pina
pin_b: pinb
effects:
- lambda:
name: Blink
update_interval: 500ms
lambda: |-
static int state = 0;
static float bright = 0;
if (initial_run) {
bright = id(mainlight).current_values.get_brightness();
}
auto call = id(mainlight).turn_on();
if (state == 0) {
call.set_brightness(bright);
state = 1;
} else {
call.set_brightness(0);
state = 0;
}
call.set_transition_length(0);
call.perform();
- lambda:
name: Slide
update_interval: 500ms
lambda: |-
static int state = 0;
auto call = id(mainlight).make_call();
call.set_state(true);
if (state == 0) {
call.set_color_temperature(153.0);
state = 1;
} else if (state == 1) {
state = 2;
} else if (state == 2) {
call.set_color_temperature(500.0);
state = 3;
} else {
state = 0;
}
call.set_transition_length(0.3);
call.perform();
- lambda:
name: Chainsaw
update_interval: 100ms
lambda: |-
static int state = 0;
static float bright = 0;
if (initial_run) {
bright = id(mainlight).current_values.get_brightness();
}
bool change = false;
auto call = id(mainlight).make_call();
if (state == 0 || state == 10 || state == 20 || state == 30 || state == 40) {
change = true;
call.set_brightness(bright);
call.set_color_temperature(153.0);
}
else if (state == 5 || state == 15 || state == 25 || state == 35 || state == 45) {
change = true;
call.set_brightness(bright);
call.set_color_temperature(500.0);
}
else if (state == 50 || state == 52 || state == 54 || state == 56) {
change = true;
call.set_brightness(bright);
call.set_color_temperature(153.0);
}
else if (state == 51 || state == 53 || state == 55 || state == 57) {
change = true;
call.set_brightness(0);
}
else if (state == 58 || state == 60 || state == 62 || state == 64) {
change = true;
call.set_brightness(bright);
call.set_color_temperature(500.0);
}
else if (state == 59 || state == 61 || state == 63 || state == 65) {
change = true;
call.set_brightness(0);
}
state = state + 1;
if (state > 65) {
state = 0;
}
if (change) {
call.set_state(true);
call.set_transition_length(0);
call.perform();
}
- lambda:
name: InWave
update_interval: 1s
lambda: |-
static int state = 0;
auto call = id(mainlight).make_call();
call.set_state(true);
if (state == 0) {
call.set_color_temperature(153.0);
state = 1;
} else if (state == 1) {
call.set_color_temperature(500.0);
state = 0;
} else {
state = 0;
}
call.set_transition_length(1000);
call.perform();
# - lambda:
# name: Slow Glo
# update_interval: 1s
# lambda: |-
# static int state = 0;
# static float bright = 0;
# if (initial_run) {
# bright = id(mainlight).current_values.get_brightness();
# }
#
# auto call = id(mainlight).make_call();
#
# if (state == 0) {
# call.set_color_temperature(153.0);
# call.set_brightness(0);
# call.set_transition_length(0);
# call.perform();
#
# call.set_brightness(bright);
# } else if (state == 2) {
# call.set_color_temperature(500.0);
# call.set_brightness(0);
# call.set_transition_length(0);
# call.perform();
#
# call.set_brightness(bright);
# } else if (state == 1 || state == 3) {
# call.set_brightness(0);
# }
#
# call.set_state(true);
# call.set_transition_length(1000);
# call.perform();
#
# state = state + 1;
# if (state > 3) {
# state = 0;
# }
- lambda:
name: Sequential
update_interval: 150ms
lambda: |-
static int state = 0;
static float bright = 0;
if (initial_run) {
bright = id(mainlight).current_values.get_brightness();
}
bool change = false;
auto call = id(mainlight).make_call();
if (state == 0 || state == 10 || state == 20 || state == 30 || state == 40) {
change = true;
call.set_brightness(bright);
call.set_color_temperature(153.0);
}
else if (state == 5 || state == 15 || state == 25 || state == 35 || state == 45) {
change = true;
call.set_brightness(bright);
call.set_color_temperature(500.0);
}
if (state == 50 || state == 54 || state == 58 || state == 62 || state == 66 || state == 70 || state == 74 || state == 78 || state == 82 || state == 86) {
change = true;
call.set_brightness(bright);
call.set_color_temperature(153.0);
}
if (state == 52 || state == 56 || state == 60 || state == 64 || state == 68 || state == 72 || state == 76 || state == 80 || state == 84 || state == 88) {
change = true;
call.set_brightness(bright);
call.set_color_temperature(500.0);
}
if (state == 89 || state == 91 || state == 93 || state == 95 || state == 97 || state == 99 || state == 101 || state == 103 || state == 105 || state == 107 || state == 109 || state == 111 || state == 113 || state == 115 || state == 117 || state == 119 || state == 121 || state == 123 || state == 125 || state == 127) {
change = true;
call.set_brightness(bright);
call.set_color_temperature(153.0);
}
if (state == 90 || state == 92 || state == 94 || state == 96 || state == 98 || state == 100 || state == 102 || state == 104 || state == 106 || state == 108 || state == 110 || state == 112 || state == 114 || state == 116 || state == 118 || state == 120 || state == 122 || state == 124 || state == 126 || state == 128) {
change = true;
call.set_brightness(bright);
call.set_color_temperature(500.0);
}
state = state + 1;
if (state > 128) {
state = 0;
}
if (change) {
call.set_state(true);
call.set_transition_length(0);
call.perform();
}
- lambda:
name: Slow Fade
update_interval: 3s
lambda: |-
static int state = 0;
static float bright = 0;
if (initial_run) {
bright = id(mainlight).current_values.get_brightness();
}
auto call = id(mainlight).turn_on();
if (state == 0) {
call.set_brightness(bright);
state = 1;
} else {
call.set_brightness(0);
state = 0;
}
call.set_transition_length(3000); // = 3s
call.perform();
- lambda:
name: Twinkle
update_interval: 100ms
lambda: |-
static int state = 0;
static float bright = 0;
if (initial_run) {
bright = id(mainlight).current_values.get_brightness();
}
bool change = false;
auto call = id(mainlight).make_call();
if (state == 0 || state == 2 || state == 4 || state == 6) {
change = true;
call.set_brightness(bright);
call.set_color_temperature(153.0);
}
else if (state == 8 || state == 10 || state == 12 || state == 14) {
change = true;
call.set_brightness(bright);
call.set_color_temperature(500.0);
}
else {
change = true;
call.set_brightness(0);
}
state = state + 1;
if (state > 15) {
state = 0;
}
if (change) {
call.set_state(true);
call.set_transition_length(0);
call.perform();
}
status_led:
pin:
number: GPIO4
# inverted: yes