forked from docteurzoidberg/my-esphome
-
Notifications
You must be signed in to change notification settings - Fork 0
/
zillominee.yaml
executable file
·472 lines (423 loc) · 12.1 KB
/
zillominee.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
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
substitutions:
device: "zillominee"
name: "Zillominée"
esphome:
name: $device
build_path: build/$device
platform: ESP32
board: esp32doit-devkit-v1
on_boot:
- priority: 1000
then:
- lambda: |-
fastled_base_fastledlightoutput->get_controller()->setDither(0);
id(boot_colorline_scroller).setup(35,3,5);
id(notif_colorline_scroller).setup(35,2,5);
- switch.turn_on: zillominee_control_display
- lambda: |-
id(zilloscope_main).on_boot();
on_shutdown:
then:
- lambda: |-
id(zilloscope_main).on_shutdown();
external_components:
- source:
type: local
path: components
components: [ zilloscope, color_line_scroller, text_scroller ]
wifi: !include "common/wifimulti.yaml"
logger:
level: DEBUG
api:
services:
- service: start_effect
variables:
name: string
then:
- lambda: |-
id(zilloscope_main).service_effect_start(name);
- service: stop_effect
then:
- lambda: |-
id(zilloscope_main).service_effect_stop();
- service: next_effect
then:
- lambda: |-
id(zilloscope_main).service_effect_next();
- service: previous_effect
then:
- lambda: |-
id(zilloscope_main).service_effect_prev();
- service: mode
variables:
name: string
then:
- lambda: |-
id(zilloscope_main).service_mode(name);
- service: mode_next
then:
- lambda: |-
id(zilloscope_main).service_mode_next();
- service: mode_prev
then:
- lambda: |-
id(zilloscope_main).service_mode_prev();
- service: notify
variables:
type: int
text: string
then:
- lambda: |-
id(zilloscope_main).service_notify(type,text,-1);
- service: start_stream
then:
- lambda: |-
id(zillominee_display).set_enabled(false);
- light.turn_on:
id: zillominee_matrix
effect: "e131"
- service: stop_stream
then:
- light.turn_on:
id: zillominee_matrix
effect: "none"
- lambda: |-
id(zillominee_display).set_enabled(true);
ota:
binary_sensor:
- <<: !include "common/common_binary_sensors.yaml"
button:
- <<: !include "common/common_button.yaml"
- platform: template
name: ${name} Next Mode
on_press:
then:
- lambda: id(zilloscope_main).service_mode_next();
- platform: template
name: ${name} Previous Mode
on_press:
then:
- lambda: id(zilloscope_main).service_mode_prev();
- platform: template
name: ${name} Next Effect
on_press:
then:
- lambda: id(zilloscope_main).service_effect_next();
- platform: template
name: ${name} Previous Effect
on_press:
then:
- lambda: id(zilloscope_main).service_effect_prev();
switch:
- platform: gpio
name: ${name} psu relay
pin: GPIO32
id: relay
restore_mode: ALWAYS_OFF
inverted: no
- platform: template
id: zillominee_control_display
name: ${name} Control Display
lambda: |-
return id(zillominee_display).get_enabled();
turn_on_action:
- lambda: |-
id(zillominee_display).set_enabled(true);
turn_off_action:
- lambda: |-
id(zillominee_display).set_enabled(false);
sensor:
- <<: !include "common/common_sensors.yaml"
- platform: homeassistant
id: esphome_meteo_icon
entity_id: sensor.esphome_meteo_icon
- platform: homeassistant
id: esphome_meteo_current_temp
entity_id: sensor.esphome_meteo_current_temp
# - platform: homeassistant
# id: zillominee_test_bandes
# entity_id: input_number.zillominee_test_bandes
# - platform: homeassistant
# id: zillominee_test_start
# entity_id: input_number.zillominee_test_start
# - platform: ct_clamp
# sensor: adc_sensor
# name: "$friendly_name current"
# update_interval: 5s
#filters:
# - calibrate_linear:
# # Measured value of 0 maps to 0A
# - 0 -> 0
# # Known load: 4.0A
# # Value shown in logs: 0.1333A
# - 0.1333 -> 4.0
# Example source sensor
# - platform: adc
# pin: GPIO33
# id: adc_sensor
e131:
method: multicast
time:
- platform: homeassistant
id: homeassistant_time
timezone: Europe/Paris
light:
- platform: fastled_clockless
chipset: WS2812B
pin: GPIO25
num_leds: 875
rgb_order: GRB
max_refresh_rate: 16ms
id: zillominee_matrix
name: ${name} Matrix
color_correct: [70%, 70%, 70%]
default_transition_length : 0s
#gamma_correct: 0
restore_mode : ALWAYS_ON
on_turn_on:
- switch.turn_on: relay
on_turn_off:
- switch.turn_off: relay
effects:
- e131:
name: 'e131'
universe: 1
channels: RGB
display:
- platform: addressable_light
id: zillominee_display
addressable_light_id: zillominee_matrix
width: 35
height: 25
update_interval: 16ms
lambda: |-
id(zilloscope_main).display_lambdacall(it);
pixel_mapper: |-
if (x % 2 == 0) {
return (x * 25) + (24 - y);
}
return (x * 25) + y;
font:
- id: tinyfont
file: "fonts/pixelmix.ttf"
size: 8
glyphs: '!"%()+,-_.:*=°?~#0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz'
- id: font6px
file: "fonts/6px-Normal.ttf"
size: 8
glyphs: '!"%()+,-_.:*=°?~#0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz'
- id: font_8bithud
file: "fonts/8-bit-hud.ttf"
size: 5
glyphs: '!"%()+,-_.:*=°?~#0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz'
- id: font_monogram
file: "fonts/monogram.ttf"
size: 5
glyphs: '!"%()+,-_.:*=°?~#0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz'
- id: font_clock
file: "fonts/PressStart2P-Regular.ttf"
size: 8
glyphs: '.:0123456789'
animation:
- file: "img/zillominee/splash1.gif"
id: splash_animation
type: RGB24
- file: "img/zillominee/boot-aliens/boot-aliens.gif"
id: boot_animation_aliens
type: RGB24
- file: "img/zillominee/sapins/sapins1.gif"
id: anim_sapins
type: RGB24
- file: "img/zilloscope/meteo/sun1.gif"
id: meteo_sun
type: RGB24
- file: "img/zilloscope/meteo/rain1.gif"
id: meteo_rain
type: RGB24
- file: "img/zilloscope/meteo/cloud1.gif"
id: meteo_cloud
type: RGB24
- file: "img/zilloscope/meteo/fog1.gif"
id: meteo_fog
type: RGB24
color_line_scroller:
- id: notif_colorline_scroller
- id: boot_colorline_scroller
text_scroller:
- id: notif_text_scroller
zilloscope:
id: zilloscope_main
display_id: zillominee_display
time_id: homeassistant_time
use_splash: "true"
default_mode: "time"
modes:
- mode_time:
render_lambda: |-
it.strftime(17, 8, id(font_8bithud), Color(0xFFFFFF), TextAlign::RIGHT, "%H", id(homeassistant_time).now());
it.print(17, 8, id(font_8bithud), Color(0xFFFFFF), ((millis()/1000)%2==0)?":":".");
it.strftime(20, 8, id(font_8bithud), Color(0xFFFFFF), TextAlign::LEFT, "%M", id(homeassistant_time).now());
//Multicolor line scroller
id(notif_colorline_scroller).draw(it, 0, 23);
id(notif_colorline_scroller).scroll();
return false;
- mode_meteo:
render_lambda: |-
it.printf(32, 0, id(font_8bithud), Color(0x61d3e3), TextAlign::RIGHT, "%.0f ", (id(esphome_meteo_current_temp).state + 0.5));
auto icon = (uint8_t)id(esphome_meteo_icon).state;
Animation* anim = nullptr;
if(icon==2) {
anim=id(meteo_rain);
} else if(icon==5) {
anim=id(meteo_cloud);
} else if(icon==16) {
anim=id(meteo_fog);
} else {
anim=id(meteo_sun);
}
it.image(2, 0, anim);
it.rectangle(29,0,3,3,Color(0x61d3e3));
if(frame%7==0) {
anim->next_frame();
}
return true;
- mode_effects:
effects:
#Custom display effect (aliens.gif)
- display_lambda:
name: aliens
lambda: |-
//it=display
//frame= frame counter
id(boot_animation_aliens).next_frame();
it.image(1, 6, id(boot_animation_aliens));
#Custom display effect (trees.gif)
- display_lambda:
name: sapins
lambda: |-
id(anim_sapins).next_frame();
it.image(1, 1, id(anim_sapins));
#Fire display Effect
- display_fire:
name: "lefeu"
width: 35
height: 25
#Bubbles display effect
- display_bubbles:
id: bidule
name: bubulles
speed: 15
width: 35
height: 25
background_color: 0x321911
min_bubble_size: 1
max_bubble_size: 16
#Snow display effect
- display_snow:
name: snow
snow_speed: 15
santa_speed: 15
reindeer_number: 3
width: 35
height: 25
min_snow_size: 1
max_snow_size: 6
background_color: 0x193291
#Matrix display effect
- display_matrix:
name: "matrix"
width: 35
height: 25
#not working
#- display_tiled_puzzle:
# name: "puzzle"
# width: 35
# height: 25
# tile_size: 5
#- mode_paint:
# //TODO
#boot animation forever
render_boot: |-
//it=display
//frame= frame counter
if(frame%6==0) {
id(boot_animation_aliens).next_frame();
}
id(zillominee_display).image(1, 6, id(boot_animation_aliens));
id(boot_colorline_scroller).draw(it, 0, 18);
id(boot_colorline_scroller).scroll();
return true; //continue
#splash screen after boot
render_splash: |-
//it=display
//frame= frame counter
//Une pause de 200 frames (3200ms) a la 50eme frame de l'animation
//frame pause = 50 => +200 = 250
//frame fin = 63 => +200 = 263
if(frame==263) {
return false; //if returning false, it goes to on_ready component side
}
if(frame<49 || frame>250) {
id(splash_animation).next_frame();
}
id(zillominee_display).image(0, 0, id(splash_animation));
return true; //splash continue
#render notifications (top priority over modes)
render_notification: |-
//it=display
//frame= frame counter
//text= notification text
//type= notification type
if(frame==0){
id(notif_text_scroller).setup(it,id(font_8bithud),text,1,1,8);
}
if(type==4) {
//id(bidule).stop();
//Text scroller
id(notif_text_scroller).draw(it, id(font_8bithud),Color(0xFFFFFF));
if(frame%4==0) {
//scroll every 4 frame
if(id(notif_text_scroller).scroll()) {
id(zilloscope_main).end_notification();
return false;
}
}
return true;
}
//Multicolor line scroller
id(notif_colorline_scroller).draw(it, 0, 23);
id(notif_colorline_scroller).scroll();
//Notification type
if(type==1) {
it.print(17, 4, id(font_8bithud), Color(0xebd320), TextAlign::CENTER, "!");
}
else if(type==2) {
it.print(17, 4, id(font_8bithud), Color(0xe35100), TextAlign::CENTER, "alert");
}
else if(type==4) {
}
else {
it.print(17, 4, id(font_8bithud), Color(0x61d3e3), TextAlign::CENTER, "info");
}
//Text scroller
id(notif_text_scroller).draw(it, id(font_8bithud),Color(0xFFFFFF));
if(frame%4==0) {
//scroll every 4 frame
if(id(notif_text_scroller).scroll()) {
id(zilloscope_main).end_notification();
return false;
}
}
return true;
render_ota: |-
//it=display
//frame= frame counter
//TODO
it.print(0, 0, id(tinyfont), Color(0x0000FF), "OTA");
return false;
render_shutdown: |-
//it=display
//frame= frame counter
//TODO
it.print(0, 0, id(tinyfont), Color(0xFF0000), "STOP");
return false;