-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathepaper.yaml
535 lines (505 loc) · 11.7 KB
/
epaper.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
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
substitutions:
name: epaper
friendly_name: Epaper
static_ip: !secret epaper_static_ip
wifi_ap_password: !secret ap_password
ota_password: !secret epaper_ota_password
encryption_key: !secret epaper_encryption_key
version: v1
packages:
device_base: !include packages/device_base.yaml
esphome:
platform: ESP32
board: esp32doit-devkit-v1
name: ${name}
friendly_name: ${friendly_name}
project:
name: golles.${friendly_name}
version: ${version}
api:
services:
service: refresh_display
then:
- component.update: epaperdisplay
- lambda: |-
id(refresh_needed) = 0;
globals:
- id: refresh_needed
type: int
restore_value: false
initial_value: "0"
bluetooth_proxy:
active: true
font:
- file: "fonts/Roboto-Medium.ttf"
id: roboto_med_30
size: 30
- file: "fonts/Roboto-Regular.ttf"
id: footer_font
size: 15
glyphs:
[
"&",
"@",
"!",
",",
".",
'"',
"%",
"(",
")",
"+",
"-",
"_",
":",
"°",
"0",
"1",
"2",
"3",
"4",
"5",
"6",
"7",
"8",
"9",
"A",
"B",
"C",
"D",
"E",
"F",
"G",
"H",
"I",
"J",
"K",
"L",
"M",
"N",
"O",
"P",
"Q",
"R",
"S",
"T",
"U",
"V",
"W",
"X",
"Y",
"Z",
" ",
"a",
"b",
"c",
"d",
"e",
"f",
"g",
"h",
"i",
"j",
"k",
"l",
"m",
"n",
"o",
"p",
"q",
"r",
"s",
"t",
"u",
"v",
"w",
"x",
"y",
"z",
"å",
"ä",
"ö",
"/",
"º",
"µ",
"³"
]
- file: "fonts/Roboto-Regular.ttf"
id: main_sensor_unit
size: 20
glyphs:
[
"&",
"@",
"!",
",",
".",
'"',
"%",
"(",
")",
"+",
"-",
"_",
":",
"°",
"0",
"1",
"2",
"3",
"4",
"5",
"6",
"7",
"8",
"9",
"A",
"B",
"C",
"D",
"E",
"F",
"G",
"H",
"I",
"J",
"K",
"L",
"M",
"N",
"O",
"P",
"Q",
"R",
"S",
"T",
"U",
"V",
"W",
"X",
"Y",
"Z",
" ",
"a",
"b",
"c",
"d",
"e",
"f",
"g",
"h",
"i",
"j",
"k",
"l",
"m",
"n",
"o",
"p",
"q",
"r",
"s",
"t",
"u",
"v",
"w",
"x",
"y",
"z",
"å",
"ä",
"ö",
"/",
"º",
"µ",
"³"
]
- file: "fonts/Roboto-Medium.ttf"
id: sub_sensor_font
size: 30
glyphs:
[
"&",
"@",
"!",
",",
".",
'"',
"%",
"(",
")",
"+",
"-",
"_",
":",
"°",
"0",
"1",
"2",
"3",
"4",
"5",
"6",
"7",
"8",
"9",
"A",
"B",
"C",
"D",
"E",
"F",
"G",
"H",
"I",
"J",
"K",
"L",
"M",
"N",
"O",
"P",
"Q",
"R",
"S",
"T",
"U",
"V",
"W",
"X",
"Y",
"Z",
" ",
"a",
"b",
"c",
"d",
"e",
"f",
"g",
"h",
"i",
"j",
"k",
"l",
"m",
"n",
"o",
"p",
"q",
"r",
"s",
"t",
"u",
"v",
"w",
"x",
"y",
"z",
"å",
"ä",
"ö",
"/",
"º",
"µ",
"³"
]
- file: "fonts/Roboto-Bold.ttf"
id: main_sensor_font
size: 80
- file: "fonts/materialdesignicons-webfont.ttf"
id: mdi_small
size: 31
glyphs:
# Wifi
[
"", # mdi-wifi-strength-alert-outline
"", # mdi-wifi-strength-1
"", # mdi-wifi-strength-2
"", # mdi-wifi-strength-3
"", # mdi-wifi-strength-4
"", # mdi-thermometer
"" # mdi-water-percent
]
- file: "fonts/materialdesignicons-webfont.ttf"
id: mdi_wifi
size: 20
glyphs:
# Wifi
[
"", # mdi-wifi-strength-alert-outline
"", # mdi-wifi-strength-1
"", # mdi-wifi-strength-2
"", # mdi-wifi-strength-3
"" # mdi-wifi-strength-4
]
- file: "fonts/materialdesignicons-webfont.ttf"
id: mdi_med
size: 33
glyphs:
# Wifi
[
"", # mdi-wifi-strength-alert-outline
"", # mdi-wifi-strength-1
"", # mdi-wifi-strength-2
"", # mdi-wifi-strength-3
"", # mdi-wifi-strength-4
"" # mdi-alert
]
sensor:
- platform: homeassistant
id: pm25_indoor
entity_id: sensor.air_purifier_pm2_5
on_value:
then:
- lambda: |-
id(refresh_needed) = 1;
- platform: homeassistant
id: temp_indoor
entity_id: climate.woonkamer
attribute: current_temperature
on_value:
then:
- lambda: |-
id(refresh_needed) = 1;
- platform: homeassistant
id: humid_indoor
entity_id: climate.woonkamer
attribute: current_humidity
on_value:
then:
- lambda: |-
id(refresh_needed) = 1;
- platform: homeassistant
id: temp_outdoor
entity_id: weather.knmi_purmerend
attribute: temperature
on_value:
then:
- lambda: |-
id(refresh_needed) = 1;
- platform: homeassistant
id: humid_outdoor
entity_id: weather.knmi_purmerend
attribute: humidity
on_value:
then:
- lambda: |-
id(refresh_needed) = 1;
- platform: homeassistant
id: pm25_outdoor
entity_id: sensor.particulate_matter_pm_2_5
on_value:
then:
- lambda: |-
id(refresh_needed) = 1;
spi:
clk_pin: GPIO13 # D13
mosi_pin: GPIO14 # D14 / DIN
interval:
- interval: 900s
then:
- if:
condition:
lambda: |-
return id(refresh_needed) == 1;
then:
- component.update: epaperdisplay
- lambda: |-
id(refresh_needed) = 0;
# - display.page.show_next: epaperdisplay
display:
- platform: waveshare_epaper
id: epaperdisplay
cs_pin: GPIO15 # D15
dc_pin: GPIO27 # D27
update_interval: never
busy_pin: GPIO25 # D25
reset_pin: GPIO26 # D26
model: 4.20in
lambda: |-
int pm25_danger_thres = 40;
float indoor_temp = id(temp_indoor).state;
float indoor_humid = id(humid_indoor).state;
float indoor_pm25 = id(pm25_indoor).state;
float outdoor_temp = id(temp_outdoor).state;
float outdoor_humid = id(humid_outdoor).state;
float outdoor_pm25 = id(pm25_outdoor).state;
/* INTSIDE */
it.print(10, 10, id(main_sensor_unit), "BINNEN");
it.filled_rectangle(80, 21, 303, 3);
it.print(375, 75, id(mdi_small), TextAlign::BASELINE_CENTER, "");
it.print(375, 115, id(mdi_small), TextAlign::BASELINE_CENTER, "");
if (indoor_temp > -100 && indoor_temp < 100) {
it.printf(357, 75, id(sub_sensor_font), TextAlign::BASELINE_RIGHT, "%.1fºc", indoor_temp);
} else {
it.print(357, 75, id(sub_sensor_font), TextAlign::BASELINE_RIGHT, " - ºc");
}
if (indoor_humid >= 0 && indoor_humid <= 100) {
it.printf(357, 115, id(sub_sensor_font), TextAlign::BASELINE_RIGHT, "%.1f%%", indoor_humid);
} else {
it.print(357, 115, id(sub_sensor_font), TextAlign::BASELINE_RIGHT, " - %");
}
if (indoor_pm25 >= 0 && indoor_pm25 < 255) {
if (indoor_pm25 > 99) {
it.printf(205, 114, id(main_sensor_font), TextAlign::BASELINE_RIGHT , "%.0f", indoor_pm25);
it.print(210, 114, id(main_sensor_unit),TextAlign::BASELINE_LEFT, "µg/m³");
} else {
it.printf(175, 114, id(main_sensor_font), TextAlign::BASELINE_RIGHT , "%.0f", indoor_pm25);
it.print(180, 114, id(main_sensor_unit),TextAlign::BASELINE_LEFT, "µg/m³");
}
if (indoor_pm25 >= pm25_danger_thres) {
it.print(37, 87, id(mdi_med), TextAlign::BASELINE_CENTER, "");
}
} else {
it.print(175, 114, id(main_sensor_font), TextAlign::BASELINE_RIGHT , "- ");
it.print(180, 114, id(main_sensor_unit),TextAlign::BASELINE_LEFT, "µg/m³");
}
/* OUTSIDE */
int offsetY = 137;
it.print(10, 10 + offsetY, id(main_sensor_unit), "BUITEN");
it.filled_rectangle(78, 21 + offsetY, 305, 3);
it.print(375, 75 + offsetY, id(mdi_small), TextAlign::BASELINE_CENTER, "");
it.print(375, 115 + offsetY, id(mdi_small), TextAlign::BASELINE_CENTER, "");
if (outdoor_temp > -100 && outdoor_temp < 100) {
it.printf(357, 75 + offsetY, id(sub_sensor_font), TextAlign::BASELINE_RIGHT, "%.1fºc", outdoor_temp);
} else {
it.print(357, 75 + offsetY, id(sub_sensor_font), TextAlign::BASELINE_RIGHT, " - ºc");
}
if (outdoor_humid >= 0 && outdoor_humid <= 100) {
it.printf(357, 115 + offsetY, id(sub_sensor_font), TextAlign::BASELINE_RIGHT, "%.1f%%", outdoor_humid);
} else {
it.print(357, 115 + offsetY, id(sub_sensor_font), TextAlign::BASELINE_RIGHT, " - %");
}
if (outdoor_pm25 >= 0 && outdoor_pm25 < 255) {
if (outdoor_pm25 > 99) {
it.printf(205, 114 + offsetY, id(main_sensor_font), TextAlign::BASELINE_RIGHT , "%.0f", outdoor_pm25);
it.print(210, 114 + offsetY, id(main_sensor_unit),TextAlign::BASELINE_LEFT, "µg/m³");
} else {
it.printf(175, 114 + offsetY, id(main_sensor_font), TextAlign::BASELINE_RIGHT , "%.0f", outdoor_pm25);
it.print(180, 114 + offsetY, id(main_sensor_unit),TextAlign::BASELINE_LEFT, "µg/m³");
}
if (outdoor_pm25 >= pm25_danger_thres) {
it.print(37, 87 + offsetY, id(mdi_med), TextAlign::BASELINE_CENTER, "");
}
} else{
it.print(175, 114 + offsetY, id(main_sensor_font), TextAlign::BASELINE_RIGHT , "- ");
it.print(180, 114 + offsetY, id(main_sensor_unit),TextAlign::BASELINE_LEFT, "µg/m³");
}
/* FOOTER */
it.strftime(355, 295, id(footer_font), TextAlign::BASELINE_RIGHT, "Updated at %d/%b/%Y %H:%M", id(homeassistant_time).now());
if (id(${name}_esphome_wifi_signal).has_state()) {
int x = 375;
int y = 295;
if (id(${name}_esphome_wifi_signal).state >= -50) {
it.print(x, y, id(mdi_wifi), TextAlign::BASELINE_CENTER, "");
} else if (id(${name}_esphome_wifi_signal).state >= -60) {
it.print(x, y, id(mdi_wifi), TextAlign::BASELINE_CENTER, "");
} else if (id(${name}_esphome_wifi_signal).state >= -75) {
it.print(x, y, id(mdi_wifi), TextAlign::BASELINE_CENTER, "");
} else if (id(${name}_esphome_wifi_signal).state >= -100) {
it.print(x, y, id(mdi_wifi), TextAlign::BASELINE_CENTER, "");
} else {
it.print(x, y, id(mdi_wifi), TextAlign::BASELINE_CENTER, "");
}
}