-
Notifications
You must be signed in to change notification settings - Fork 0
/
Epapercontroller.yaml
548 lines (508 loc) · 18.3 KB
/
Epapercontroller.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
536
537
538
539
540
541
542
543
544
545
546
547
548
esphome:
name: epapercontroller
esp32:
board: esp32doit-devkit-v1
# platformio_options:
# platform: [email protected]
# board: az-delivery-devkit-v4
# board_build.mcu: esp32
# board_build.f_cpu: 240000000L
substitutions:
devicename: AQI Display
gpio_led_status: GPIO2
gpio_i2c_sda: GPIO21
gpio_i2c_scl: GPIO22
gpio_uart_rx_pin: GPIO16
gpio_uart_tx_pin: GPIO17
gpio_spi_clk_pin: GPIO25
gpio_spi_mosi_pin: GPIO26
gpio_cs_pin: GPIO32
gpio_busy_pin: GPIO33
gpio_reset_pin: GPIO27
gpio_dc_pin: GPIO13
gpio_buzzer: GPIO04
gpio_led_red: GPIO19
gpio_led_green: GPIO23
gpio_led_blue: GPIO18
packages:
wifi: !include /config/esphome/common/wifi.yaml
network_diagnostics: !include /config/esphome/common/network_diagnostics.yaml
base_config: !include /config/esphome/common/base_config.yaml
# UART for MH-Z19C CO2 sensor
uart:
rx_pin: $gpio_uart_rx_pin
tx_pin: $gpio_uart_tx_pin
baud_rate: 9600
# status_led:
# pin:
# number: $gpio_led_status
# inverted: False
spi:
clk_pin: $gpio_spi_clk_pin
mosi_pin: $gpio_spi_mosi_pin
id: epaper_display
binary_sensor:
- platform: status
name: "Board connected"
id: connection
sensor:
- platform: mhz19
id: mhz19_sensor
co2:
name: "MH-Z19 CO2 Value Internal"
accuracy_decimals: 0
id: mhz19_CO2_value_internal
unit_of_measurement: ppm
internal: true
filters:
- exponential_moving_average:
alpha: 0.2
send_every: 1
- or:
- throttle_average: 60s
- delta: 5
temperature:
name: "MH-Z19 Temperature Internal"
id: mhz19_temperature_internal
internal: true
filters:
- sliding_window_moving_average:
window_size: 5
send_every: 1
- or:
- throttle_average: 60s
- delta: 1
update_interval: 5s
automatic_baseline_calibration: false
- platform: template
id: mhz19_CO2_value
name: "MH-Z19 CO2 Value"
internal: false
force_update: true
accuracy_decimals: 0
update_interval: 1s
unit_of_measurement: ppm
lambda: |-
return id(mhz19_CO2_value_internal).state;
filters:
- sliding_window_moving_average:
window_size: 60
send_every: 60
- or:
- throttle_average: 60s
- delta: 5
- platform: template
id: mhz19_temperature
name: "MH-Z19 Temperature"
internal: false
update_interval: 1s
unit_of_measurement: °C
lambda: |-
return id(mhz19_temperature_internal).state;
filters:
- sliding_window_moving_average:
window_size: 60
send_every: 60
- or:
- throttle_average: 60s
- delta: 1
- platform: homeassistant
id: bedroomtemp
entity_id: sensor.temperature_bedroom
#internal: true
- platform: homeassistant
id: livingroomtemp
entity_id: sensor.temperature_livingroom
#internal: true
- platform: homeassistant
id: outsidetemp
entity_id: sensor.temperature_outside
#internal: true
- platform: homeassistant
id: bedroomhumi
entity_id: sensor.humidity_bedroom
#internal: true
- platform: homeassistant
id: livingroomhumi
entity_id: sensor.humidity_livingroom
#internal: true
- platform: homeassistant
id: outsidehumi
entity_id: sensor.humidity_outside
#internal: true
- platform: homeassistant
id: co2concentration
entity_id: sensor.co2_concentration_filtered
- platform: homeassistant
id: bedweight
entity_id: sensor.bed_weight_calibrated
- platform: homeassistant
id: bedweightbalanceupdown
entity_id: sensor.bed_weight_balance_updown
- platform: homeassistant
id: bedweightbalanceleftright
entity_id: sensor.bed_weight_balance_leftright
time:
- platform: sntp
timezone: Europe/Amsterdam
id: sntp_time
servers:
- 0.nl.pool.ntp.org
- ntp1.time.nl
- 193.79.237.14
sun:
latitude: !secret home_latitude
longitude: !secret home_longitude
text_sensor:
- platform: version
name: "Epaperdisplay Version"
- platform: template
name: "Epaperdisplay Uptime"
icon: "mdi:timer"
update_interval: 60s
lambda: |-
int seconds = id(uptime_sensor).state;
int days = seconds / (24 * 3600);
seconds = seconds % (24 * 3600);
int hours = seconds / 3600;
seconds = seconds % 3600;
int minutes = seconds / 60;
return { (String(days) +"d " + String(hours) +"h " + String(minutes) +"m").c_str() };
- platform: sun
name: Sun Next Sunrise
type: sunrise
id: nextsunrise
format: "%H:%M"
- platform: sun
name: Sun Next Sunset
type: sunset
id: nextsunset
format: "%H:%M"
- platform: homeassistant
id: weather
entity_id: weather.home
interval:
- interval: 10s
then:
- display.page.show_next: my_display
- component.update: my_display
button:
- platform: template
name: "Calibrate MH-Z19"
on_press:
then:
- mhz19.calibrate_zero: mhz19_sensor
switch:
- platform: template
name: "Calibrate MH-Z19"
optimistic: true
on_turn_on:
- mhz19.abc_enable: mhz19_sensor
- mhz19.calibrate_zero: mhz19_sensor
on_turn_off:
mhz19.abc_disable: mhz19_sensor
display:
- platform: waveshare_epaper
id: my_display
cs_pin: $gpio_cs_pin
busy_pin: $gpio_busy_pin
reset_pin: $gpio_reset_pin
dc_pin: $gpio_dc_pin
model: 2.90in
rotation: 270°
full_update_every: 300
update_interval: 1s
pages:
- id: page1
lambda: |-
/* Moon icon */
//if(id(moon_icon).has_state()) {
// //ESP_LOGI("Moon icon", "%s", id(moon_icon).state.c_str());
// it.printf(25, 42, id(icon_45_font), TextAlign::BASELINE_CENTER, "%s", id(moon_icon).state.c_str());
//}
int x, y;
x = 0, y = 0;
if (id(weather).has_state()) {
if (id(weather).state == "clear-night") {
it.printf(x, y, id(icon_60_font), TextAlign::TOP_LEFT , "\U000F0594");
} else if (id(weather).state == "cloudy") {
it.printf(x, y, id(icon_60_font), TextAlign::TOP_LEFT , "\U000F0590");
} else if (id(weather).state == "fog") {
it.printf(x, y, id(icon_60_font), TextAlign::TOP_LEFT , "\U000F0591");
} else if (id(weather).state == "hail") {
it.printf(x, y, id(icon_60_font), TextAlign::TOP_LEFT , "\U000F0592");
} else if (id(weather).state == "lightning") {
it.printf(x, y, id(icon_60_font), TextAlign::TOP_LEFT , "\U000F0593");
} else if (id(weather).state == "lightning-rainy") {
it.printf(x, y, id(icon_60_font), TextAlign::TOP_LEFT , "\U000F067E");
} else if (id(weather).state == "partlycloudy") {
it.printf(x, y, id(icon_60_font), TextAlign::TOP_LEFT , "\U000F0595");
} else if (id(weather).state == "pouring") {
it.printf(x, y, id(icon_60_font), TextAlign::TOP_LEFT , "\U000F0596");
} else if (id(weather).state == "rainy") {
it.printf(x, y, id(icon_60_font), TextAlign::TOP_LEFT , "\U000F0597");
} else if (id(weather).state == "snowy") {
it.printf(x, y, id(icon_60_font), TextAlign::TOP_LEFT , "\U000F0598");
} else if (id(weather).state == "snowy-rainy") {
it.printf(x, y, id(icon_60_font), TextAlign::TOP_LEFT , "\U000F067F");
} else if (id(weather).state == "sunny") {
it.printf(x, y, id(icon_60_font), TextAlign::TOP_LEFT , "\U000F0599");
} else if (id(weather).state == "windy") {
it.printf(x, y, id(icon_60_font), TextAlign::TOP_LEFT , "\U000F059D");
} else if (id(weather).state == "windy-variant") {
it.printf(x, y, id(icon_60_font), TextAlign::TOP_LEFT , "\U000F059E");
} else if (id(weather).state == "exceptional") {
it.printf(x, y, id(icon_60_font), TextAlign::TOP_LEFT , "\U000F0F30");
} else {
it.printf(x, y, id(icon_60_font), TextAlign::TOP_LEFT , "\U000F14E4");
}
} else {
it.printf(x, y, id(icon_60_font), TextAlign::BASELINE_CENTER , "\U000F14E4");
}
//sun set-rise
it.printf(85, 22, id(icon_20_font), TextAlign::BASELINE_RIGHT, "");
it.printf(135, 22, id(size_20_font), TextAlign::BASELINE_RIGHT, "%s", id(nextsunrise).state.c_str());
it.printf(85, 44, id(icon_20_font), TextAlign::BASELINE_RIGHT, "");
it.printf(135, 44, id(size_20_font), TextAlign::BASELINE_RIGHT, "%s", id(nextsunset).state.c_str());
//date
it.strftime(210, 43, id(size_50_font), TextAlign::BASELINE_RIGHT, "%d", id(sntp_time).now());
it.printf(213, 43, id(size_14_font), TextAlign::BASELINE_LEFT, "D");
it.strftime(280, 43, id(size_50_font), TextAlign::BASELINE_RIGHT, "%m", id(sntp_time).now());
it.printf(283, 43, id(size_14_font), TextAlign::BASELINE_LEFT, "M");
//line
it.line(0, 54, 296, 54);
//Time
it.strftime(3, 45, id(size_85_font), "%H:%M", id(sntp_time).now());
it.strftime(225, 68, id(size_60_font), "%S", id(sntp_time).now());
it.strftime(250, 58, id(size_14_font), "%a", id(sntp_time).now());
- id: page2
lambda: |-
int x, y;
//ESP_LOGI("display", "Updating..");
//Time
it.strftime(3, 0, id(size_20_font), "%H:%M", id(sntp_time).now());
/* WiFi Signal Strength */
x = 80, y = 20;
if(id(wifi_signal_sensor).has_state()) {
if (id(wifi_signal_sensor).state >= -50) {
//Excellent
it.print(x, y, id(icon_20_font), TextAlign::BOTTOM_RIGHT, "");
//ESP_LOGI("WiFi", "Exellent");
} else if (id(wifi_signal_sensor).state >= -62) {
//Good
it.print(x, y, id(icon_20_font), TextAlign::BOTTOM_RIGHT, "");
//ESP_LOGI("WiFi", "Good");
} else if (id(wifi_signal_sensor).state >= -67) {
//Fair
it.print(x, y, id(icon_20_font), TextAlign::BOTTOM_RIGHT, "");
//ESP_LOGI("WiFi", "Fair");
} else if (id(wifi_signal_sensor).state >= -75) {
//Weak
it.print(x, y, id(icon_20_font), TextAlign::BOTTOM_RIGHT, "");
//ESP_LOGI("WiFi", "Weak");
} else {
//Unlikely working signal
it.print(x, y, id(icon_20_font), TextAlign::BOTTOM_RIGHT, "");
//ESP_LOGI("WiFi", "Unlikely");
}
} else {
// No state, mdi-wifi-strength-off-outline
it.print(x, y, id(icon_20_font), TextAlign::BOTTOM_RIGHT, "\U000F092E");
}
x = 105, y = 20;
if (id(connection).has_state()) {
if (id(connection).state == true) {
it.print(x, y, id(icon_20_font), TextAlign::BOTTOM_RIGHT, ""); //Home assistant icon
} else {
it.print(x, y, id(icon_20_font), TextAlign::BOTTOM_RIGHT, ""); //Server disconnected icon
}
} else {
it.print(x, y, id(icon_20_font), TextAlign::BOTTOM_RIGHT, ""); //Server disconnected icon
}
//Temperature
it.printf(5, 83, id(icon_20_font), TextAlign::BASELINE_LEFT, ""); //bedroom icon
it.printf(5, 103, id(icon_20_font), TextAlign::BASELINE_LEFT, ""); //livingroom icon
it.printf(5, 123, id(icon_20_font), TextAlign::BASELINE_LEFT, ""); //outside icon
it.printf(30, 83, id(icon_20_font), TextAlign::BASELINE_LEFT, ""); //thermometer icon
it.printf(30, 103, id(icon_20_font), TextAlign::BASELINE_LEFT, ""); //thermometer icon
it.printf(30, 123, id(icon_20_font), TextAlign::BASELINE_LEFT, ""); //thermometer icon
it.printf(118, 83, id(size_20_font), TextAlign::BASELINE_RIGHT, "%.1f°C", id(bedroomtemp).state);
it.printf(118, 103, id(size_20_font), TextAlign::BASELINE_RIGHT, "%.1f°C", id(livingroomtemp).state);
it.printf(118, 123, id(size_20_font), TextAlign::BASELINE_RIGHT, "%.1f°C", id(outsidetemp).state);
it.printf(140, 83, id(icon_20_font), TextAlign::BASELINE_RIGHT, "");
it.printf(140, 103, id(icon_20_font), TextAlign::BASELINE_RIGHT, "");
it.printf(140, 123, id(icon_20_font), TextAlign::BASELINE_RIGHT, "");
it.printf(190, 83, id(size_20_font), TextAlign::BASELINE_RIGHT, "%.1f%%", id(bedroomhumi).state);
it.printf(190, 103, id(size_20_font), TextAlign::BASELINE_RIGHT, "%.1f%%", id(livingroomhumi).state);
it.printf(190, 123, id(size_20_font), TextAlign::BASELINE_RIGHT, "%.1f%%", id(outsidehumi).state);
//Bedscale
x = 195, y = 83;
if (id(bedweight).has_state()) {
it.print(x, y, id(icon_20_font), TextAlign::BASELINE_LEFT, "\U000F0472"); // mdi-scale
it.printf(x + 20, y, id(size_20_font), TextAlign::BASELINE_LEFT, "%.2f kg", id(bedweight).state);
it.printf(150 , 50, id(size_50_font), TextAlign::BASELINE_LEFT, "%02.0f", floor(id(bedweight).state));
it.printf(210 , 50, id(size_20_font), TextAlign::BASELINE_LEFT, "%02.0f", ((id(bedweight).state - floor(id(bedweight).state)) * 100));
} else {
it.print(x, y, id(icon_20_font), TextAlign::BASELINE_LEFT, "\U000F105A"); //mdi-scale-off
}
//it.printf(150 , 50, id(size_50_font), TextAlign::BASELINE_LEFT, "%02.0f", floor(id(bedweight).state));
//it.printf(210 , 50, id(size_20_font), TextAlign::BASELINE_LEFT, "%02.0f", ((id(bedweight).state - floor(id(bedweight).state)) * 100));
//CO2value
x = 195, y = 103;
if (id(mhz19_CO2_value).has_state()) {
it.print(x, y, id(icon_20_font), TextAlign::BASELINE_LEFT, "\U000F07E4"); // mdi-co20-molecule
it.printf(x + 20, y, id(size_20_font), TextAlign::BASELINE_LEFT, "%.0f ppm", id(mhz19_CO2_value_internal).state);
} else {
it.print(x, y, id(icon_20_font), TextAlign::BASELINE_LEFT, "NC"); //mdi-scale-off
}
//it.graph(0, 20, id(mhz19_CO2_value_graph));
# graph:
# - id: mhz19_CO2_value_graph
# sensor: mhz19_CO2_value
# duration: 1h
# width: 100
# height: 50
font:
- file: 'fonts/Roboto-Medium.ttf'
id: size_85_font
size: 85
# - file: 'fonts/Roboto-Medium.ttf'
# id: size_75_font
# size: 75
- file: 'fonts/Roboto-Medium.ttf'
id: size_60_font
size: 60
- file: 'fonts/Roboto-Medium.ttf'
id: size_50_font
size: 50
# - file: 'fonts/Roboto-Light.ttf'
# id: size_12_font
# size: 12
- file: 'fonts/Roboto-Light.ttf'
id: size_14_font
size: 14
# - file: 'fonts/Roboto-Medium.ttf'
# id: size_15_font
# size: 15
- file: 'fonts/Roboto-Medium.ttf'
id: size_20_font
size: 20
- file: 'fonts/Roboto-Medium.ttf'
id: size_25_font
size: 25
- file: 'fonts/Roboto-Medium.ttf'
id: size_30_font
size: 30
# - file: 'fonts/materialdesignicons-webfont.ttf'
# id: icon_120_font
# size: 120
# glyphs: [
# # Weather
# "", # mdi-weather-sunny
# "", # mdi-weather-cloudy
# "", # mdi-weather-pouring
# "", # mdi-weather-snowy-rainy
# "s", # mdi-weather-snowy-heavy
# "", # mdi-weather-windy-variant
# "", # mdi-weather-fog
# "n", # mdi-weather-night-partly-cloudy
# "", # mdi-weather-partly-cloudy
# "", # mdi-weather-rainy
# "", # mdi-weather-snowy
# "", # mdi-weather-clear-night
# "", # unknown
# '', # mdi-thermometer
# ]
# - file: 'fonts/materialdesignicons-webfont.ttf'
# id: icon_45_font
# size: 45
# glyphs: [
# # Moon
# # "", # new_moon
# # "ト", # waxing_crecent
# # "セ", # first_quarter
# # "ナ", # waxing_gibbous
# # "", # full_moon
# # "テ", # waning_gibbous
# # "タ", # last_quarter
# # "ツ", # waning_crescent
# '', # mdi-thermometer
# ]
- file: 'fonts/materialdesignicons-webfont.ttf'
id: icon_60_font
size: 60
glyphs: [
# Weather
"\U000F0594", #clear-night
"\U000F0590", #cloudy
"\U000F0591", #fog
"\U000F0592", #hail
"\U000F0593", #lightning
"\U000F067E", #lightning-rainy
"\U000F0595", #partlycloudy
"\U000F0596", #pouring
"\U000F0597", #rainy
"\U000F0598", #snowy
"\U000F067F", #snowy-rainy
"\U000F0599", #sunny
"\U000F059D", #windy
"\U000F059E", #windy-variant
"\U000F0F30", #exceptional
"\U000F14E4", # mdi-weather-sunny-off
# # Moon
# "", # new_moon
# "ト", # waxing_crecent
# "セ", # first_quarter
# "ナ", # waxing_gibbous
# "", # full_moon
# "テ", # waning_gibbous
# "タ", # last_quarter
# "ツ", # waning_crescent
'', # mdi-thermometer
'', #humidity
]
- file: 'fonts/materialdesignicons-webfont.ttf'
id: icon_20_font
size: 20
glyphs: [
"", # sun rise
"", # sun set
# Wifi
'', # mdi-wifi-strength-outline
'', # mdi-wifi-strength-1
'', # mdi-wifi-strength-2
'', # mdi-wifi-strength-3
'', # mdi-wifi-strength-4
"\U000F092E", #mdi-wifi-strength-off-outline
'', # mdi-home-assistant
'', # mdi-server-network-off
'', #bedroom
'', #bathroom
'', #tree
'', #sprout
'', #couch
'', #humidity
'', # mdi-thermometer
"\U000F07E4", #mdi-molecule-co2
"\U000F0472", #mdi-scale
"\U000F105A", #mdi-scale-off
]
# - file: 'fonts/materialdesignicons-webfont.ttf'
# id: weather_temp_icon_font
# size: 25
# glyphs: [
# "﹢", # mdi-down
# "﹣", # mdi-up
# "", # raindrop
# "", # wind
# ]
# - file: 'fonts/materialdesignicons-webfont.ttf'
# id: home_icon_font
# size: 15
# glyphs: [
# "ﵜ", # mdi-house1
# "ﵝ", # mdi-house2
# "ﵞ", # mdi-house3
# "", # mdi-bowl
# "", #mdi-knifeandfork
# ]