-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathesp32epaper.yaml
477 lines (410 loc) · 17.1 KB
/
esp32epaper.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
substitutions:
devicename: esp32epaper
globals:
- id: prevent_sleep
type: bool
restore_value: no
initial_value: "false"
- id: globalDisplayVal
type: std::vector<std::string>
restore_value: no
- id: displayWaitTime
type: int
initial_value: '5000'
restore_value: no
esphome:
name: $devicename
platform: ESP32
board: esp-wrover-kit
project:
name: "krikk.esp32_E-Paper_Display"
version: "0.0.13"
platformio_options:
upload_speed: 921600
board_build.f_flash: 80000000L
on_boot:
priority: -100
then:
- lambda: "adc_power_acquire();"
on_shutdown:
then:
# - lambda: "adc_power_off(); my_display->deep_sleep();"
- lambda: "adc_power_release(); my_display->deep_sleep();"
packages:
wifi: !include wifi.yaml
# ble: !include ble.yaml
mqtt:
broker: !secret mqtt_host
username: !secret mqtt_user
password: !secret mqtt_password
discovery: false
client_id: $devicename
birth_message:
topic: tele/$devicename/LWT
payload: Online
will_message:
topic: tele/$devicename/LWT
payload: Offline
# Enable logging
logger:
level: DEBUG
#level: INFO
text_sensor:
- platform: mqtt_subscribe
id: mqttDisplayValues
topic: $devicename/input/DisplayValues
on_value:
then:
- lambda: |-
ESP_LOGD("mqttDisplayValues", "The mqttDisplayValues is: %s", id(mqttDisplayValues).state.c_str());
std::string str = id(mqttDisplayValues).state;
id(globalDisplayVal).clear();
char * token;
char seps[] = "#";
token = strtok (&str[0],seps);
while (token != NULL)
{
id(globalDisplayVal).push_back(token);
token = strtok (NULL, seps);
}
/*
for ( std::string s : id(globalDisplayVal) ) {
ESP_LOGD("mqttDisplayValues", "String to Vector: %s", s.c_str());
}
ESP_LOGD("mqttDisplayValues", "String time: %s", id(globalDisplayVal).at(1).c_str());
ESP_LOGD("mqttDisplayValues", "String Sleeptime: %s", id(globalDisplayVal).at(22).c_str());
ESP_LOGD("mqttDisplayValues", "String OTA: %s", id(globalDisplayVal).at(23).c_str());
*/
// activate OTA mode if requested
if (id(globalDisplayVal).at(23) == "1") {
id(prevent_sleep) = true;
id(deep_sleep_1).prevent_deep_sleep();
ESP_LOGD("mqttDisplayValues", "OTA: 1");
}
else {
id(prevent_sleep) = false;
ESP_LOGD("mqttDisplayValues", "OTA: 0");
}
// set deep sleep time in seconds
int sleepsec = atoi( id(globalDisplayVal).at(22).c_str());
id(deep_sleep_1).set_sleep_duration(sleepsec*1000);
// update battery and wifi sensor when requested
if (id(globalDisplayVal).at(24) == "1") {
id(battery).update();
id (wifisignal).update();
ESP_LOGD("mqttDisplayValues", "Sensors Battery Voltage and Wifi signal updated.");
}
// update display only when presense is set to 1
if (id(globalDisplayVal).at(25) != "0") {
id(my_display).update();
id(displayWaitTime) = atoi( id(globalDisplayVal).at(25).c_str());
ESP_LOGD("mqttDisplayValues", "updating Display, displayWaitTime is: %d ms", id(displayWaitTime));
}
else {
id(displayWaitTime) = 0;
ESP_LOGD("mqttDisplayValues", "displayWaitTime else is: %d", id(displayWaitTime));
}
- delay: !lambda 'return id(displayWaitTime);'
- if:
condition:
lambda: 'return id(prevent_sleep);'
then:
- logger.log:
format: "OTA Mode"
tag: "mqttDisplayValues"
- delay: 54s
else:
- deep_sleep.enter: deep_sleep_1
sensor:
# - platform: uptime
# name: "$devicename Uptime Sensor"
- platform: wifi_signal
name: "WiFi Signal"
id: wifisignal
update_interval: never
- platform: adc
pin: GPIO36
#attenuation: 11db
attenuation: auto
id: battery
name: "Battery Voltage"
update_interval: never
# filters:
# - calibrate_linear:
# Map 0.0 (from sensor) to 0.0 (true value)
# - 2.62 -> 100
# - 1.56 -> 0
spi:
clk_pin: GPIO19
mosi_pin: GPIO18
# miso_pin: GPIO5
font:
- file: 'fonts/Google_Sans_Bold.ttf'
id: clock_font
size: 90
glyphs: [0, 1, 2, 3, 4, 5, 6, 7 ,8, 9, ':']
- file: 'fonts/Google_Sans_Medium.ttf'
id: font_100
size: 100
- file: 'fonts/Google_Sans_Medium.ttf'
id: font_30
size: 30
- file: 'fonts/Google_Sans_Medium.ttf'
id: font_14
size: 14
glyphs: [k, m, /, h, p, 3]
- file: 'fonts/Google_Sans_Medium.ttf'
id: font_40
size: 40
- file: 'fonts/Google_Sans_Medium.ttf'
id: font_55
size: 55
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/Google_Sans_Bold.ttf'
id: status_font
size: 36
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', 'å', 'ä', 'ö', '/']
# Preview https://pictogrammers.github.io/@mdi/font/6.5.95/
# Download: https://cdnjs.com/libraries/MaterialDesign-Webfont/6.5.95
- file: 'fonts/materialdesignicons-webfont_6.5.95.ttf'
id: weather_font
size: 50
glyphs: [
# Wifi
'', # F092F mdi-wifi-strength-outline
'', # F091F mdi-wifi-strength-1
'', # F0922 mdi-wifi-strength-2
'', # F0925 mdi-wifi-strength-3
'', # F0928 mdi-wifi-strength-4
# Battery
'', # F007A mdi-battery-10
'', # F007B mdi-battery-20
'', # F007C mdi-battery-30
'', # F007D mdi-battery-40
'', # F007E mdi-battery-50
'', # F007F mdi-battery-60
'', # F0080 mdi-battery-70
'', # F0081 mdi-battery-80
'', # F0082 mdi-battery-90
'', # F0079 mdi-battery 100
]
# Preview https://pictogrammers.github.io/@mdi/font/6.5.95/
# Download: https://cdnjs.com/libraries/MaterialDesign-Webfont/6.5.95
- file: 'fonts/materialdesignicons-webfont_6.5.95.ttf'
id: icon_70
size: 70
glyphs: [
'', # F0899 mdi-account-heart
'', # F050F mdi-thermometer
'', # F0E02 mdi-thermometer-chevron-down Tempmin
'', # F0E03 mdi-thermometer-chevron-up Tempmax
'', # F1137 mdi-fire-hydrant
'', # F058E mdi-water-percent
'', # F054A mdi-umbrella
'', # F0F55 mdi-home-thermometer-outline
'', # F0F54 mdi-home-thermometer
'', # F07E4 mdi-molecule-co2
'', # F0A72 mdi-solar-power
'', # F06A5 mdi-power-plug
'', # F059D mdi-weather-windy
'', # F0FD3 mdi-bed-double-outline
'', # F029A mdi-gauge
'', # F15FA mdi-windsock
'', # F058C mdi-water
'', # F0150 mdi-clock-outline Clock
'', # F11DB mdi-window-closed-variant
'', # F11DC mdi-window-open-variant
# Sun
'', # F059B mdi-weather-sunset-down
'', # F059C mdi-weather-sunset-up
# Moon
"", # F0F64 mdi-moon-new new_moon
"", # F0F67 mdi-moon-waxing-crescent waxing_crecent
"", # F0F61 mdi-moon-first-quarter first_quarter
"", # F0F68 mdi-moon-waxing-gibbous waxing_gibbous
"", # F0F62 mdi-moon-full full_moon
"", # F0F66 mdi-moon-waning-gibbous waning_gibbous
"", # F0F63 mdi-moon-last-quarter last_quarter
"", # F0F65 mdi-moon-waning-crescent waning_crescent
# room icons
'', # F156D mdi-sofa-outline
'', # F05F2 mdi-food-fork-drink
'', # F0FD1 mdi-bed-king-outline
'', # F064D mdi-human-male
'', # F0649 mdi-human-female
'', # F09A0 mdi-shower
]
- file: 'fonts/materialdesignicons-webfont_6.5.95.ttf'
id: icon_40
size: 40
glyphs: [
'', # F0E02 mdi-thermometer-chevron-down Tempmin
'', # F0E03 mdi-thermometer-chevron-up Tempmax
'', # F058E mdi-water-percent
]
- file: 'fonts/materialdesignicons-webfont_6.5.95.ttf'
id: icon_55
size: 55
glyphs: [
'', # F058E mdi-water-percent
]
display:
- platform: waveshare_epaper
cs_pin: GPIO15
dc_pin: GPIO14
busy_pin: GPIO21
reset_pin: GPIO22
model: 7.50inV2
update_interval: never
id: my_display
lambda: |
int x, y;
// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
//console.info("out: Date Time PVWatt TotalWatt AussenT AusTMin AusTMax AussenH WohnzT WohnzH BadT BadH SchlT SchlH SZiT SZiH LZiT LZiH CO2 Wind Mond");
// out: 2022-02-28#14:24:57#491#-303#4.5#-1.2#4.5#39#23.5#46#23.1#59#19.9#56#19.8#57#20.5#54#1180#12
/* Print time in HH:MM format */
it.printf(400, 495, id(clock_font), TextAlign::BOTTOM_CENTER, "%s", id(globalDisplayVal).at(1).c_str());
it.printf(245, 400, id(font_55), TextAlign::BOTTOM_LEFT, "%s", id(globalDisplayVal).at(0).c_str());
/* WiFi Signal Strenght
if(id(wifisignal).has_state()) {
x = 545, y = 466;
if (id(wifisignal).state >= -50) {
//Excellent
it.print(x, y, id(weather_font), TextAlign::BOTTOM_CENTER, "");
ESP_LOGI("WiFi", "Exellent");
} else if (id(wifisignal).state >= -60) {
//Good
it.print(x, y, id(weather_font), TextAlign::BOTTOM_CENTER, "");
ESP_LOGI("WiFi", "Good");
} else if (id(wifisignal).state >= -67) {
//Fair
it.print(x, y, id(weather_font), TextAlign::BOTTOM_CENTER, "");
ESP_LOGI("WiFi", "Fair");
} else if (id(wifisignal).state >= -70) {
//Weak
it.print(x, y, id(weather_font), TextAlign::BOTTOM_CENTER, "");
ESP_LOGI("WiFi", "Weak");
} else {
//Unlikely working signal
it.print(x, y, id(weather_font), TextAlign::BOTTOM_CENTER, "");
ESP_LOGI("WiFi", "Unlikely");
}
}
*/
/* Battery Voltage */
if(id(battery).has_state()) {
x = 233, y = 466;
if (id(battery).state >= 2.8) {
// 100 %
it.print(x, y, id(weather_font), TextAlign::BOTTOM_LEFT, "");
} else if (id(battery).state >= 2.7) {
// 90 %
it.print(x, y, id(weather_font), TextAlign::BOTTOM_LEFT, "");
} else if (id(battery).state >= 2.6) {
// 80%
it.print(x, y, id(weather_font), TextAlign::BOTTOM_LEFT, "");
} else if (id(battery).state >= 2.5) {
// 70%
it.print(x, y, id(weather_font), TextAlign::BOTTOM_LEFT, "");
} else if (id(battery).state >= 2.4) {
// 60%
it.print(x, y, id(weather_font), TextAlign::BOTTOM_LEFT, "");
} else if (id(battery).state >= 2.3) {
// 50%
it.print(x, y, id(weather_font), TextAlign::BOTTOM_LEFT, "");
} else if (id(battery).state >= 2.2) {
// 40%
it.print(x, y, id(weather_font), TextAlign::BOTTOM_LEFT, "");
} else if (id(battery).state >= 2.1) {
// 30%
it.print(x, y, id(weather_font), TextAlign::BOTTOM_LEFT, "");
} else if (id(battery).state >= 2.0) {
// 20%
it.print(x, y, id(weather_font), TextAlign::BOTTOM_LEFT, "");
} else {
// 10%
it.print(x, y, id(weather_font), TextAlign::BOTTOM_LEFT, "");
}
}
// pv power
it.print(645, 480, id(icon_70), TextAlign::BOTTOM_RIGHT, "");
it.printf(800, 480, id(font_55), TextAlign::BOTTOM_RIGHT , "%sW", id(globalDisplayVal).at(2).c_str());
// total power
it.print(-13, 480, id(icon_70), TextAlign::BOTTOM_LEFT, "");
it.printf(45, 480, id(font_55), TextAlign::BOTTOM_LEFT , "%sW", id(globalDisplayVal).at(3).c_str());
// outside temperature
it.print(400, 0, id(font_30), TextAlign::TOP_LEFT, "OUT:");
it.printf(800, -19, id(font_100), TextAlign::TOP_RIGHT, "%s°C", id(globalDisplayVal).at(4).c_str());
// outside min temperature
it.print(400, 120, id(icon_40), TextAlign::CENTER_LEFT, "");
it.printf(440, 120, id(font_40), TextAlign::CENTER_LEFT, "%s°C", id(globalDisplayVal).at(5).c_str());
// outside max temperature
it.print(678, 120, id(icon_40), TextAlign::CENTER_RIGHT, "");
it.printf(800, 120, id(font_40), TextAlign::CENTER_RIGHT, "%s°C", id(globalDisplayVal).at(6).c_str());
// outside humidity
it.printf(812, 200, id(icon_55), TextAlign::CENTER_RIGHT, "");
it.printf(766, 200, id(font_55), TextAlign::CENTER_RIGHT, "%s", id(globalDisplayVal).at(7).c_str());
// livingroom temperature
it.print(0, 35, id(icon_70), TextAlign::CENTER_LEFT, "");
it.printf(90, 35, id(font_40), TextAlign::CENTER_LEFT , "%s°", id(globalDisplayVal).at(8).c_str());
// livingroom humidity
it.printf(315, 35, id(icon_40), TextAlign::CENTER_RIGHT, "");
it.printf(235, 35, id(font_40), TextAlign::CENTER_LEFT , "%s", id(globalDisplayVal).at(9).c_str());
// Bath temperature
it.print(0, 105, id(icon_70), TextAlign::CENTER_LEFT, "");
it.printf(90, 105, id(font_40), TextAlign::CENTER_LEFT , "%s°", id(globalDisplayVal).at(10).c_str());
// bath humitidy
it.printf(315, 105, id(icon_40), TextAlign::CENTER_RIGHT, "");
it.printf(235, 105, id(font_40), TextAlign::CENTER_LEFT , "%s", id(globalDisplayVal).at(11).c_str());
// bedroom temperature
it.print(0, 175, id(icon_70), TextAlign::CENTER_LEFT, "");
it.printf(90, 175, id(font_40), TextAlign::CENTER_LEFT , "%s°", id(globalDisplayVal).at(12).c_str());
// bedroom humidity
it.printf(315, 175, id(icon_40), TextAlign::CENTER_RIGHT, "");
it.printf(235, 175, id(font_40), TextAlign::CENTER_LEFT , "%s", id(globalDisplayVal).at(13).c_str());
// boys-room temperature
it.print(0, 245, id(icon_70), TextAlign::CENTER_LEFT, "");
it.printf(90, 245, id(font_40), TextAlign::CENTER_LEFT , "%s°", id(globalDisplayVal).at(14).c_str());
// boys-room humidity
it.printf(315, 245, id(icon_40), TextAlign::CENTER_RIGHT, "");
it.printf(235, 245, id(font_40), TextAlign::CENTER_LEFT , "%s", id(globalDisplayVal).at(15).c_str());
// girl-room temperature
it.print(0, 315, id(icon_70), TextAlign::CENTER_LEFT, "");
it.printf(90, 315, id(font_40), TextAlign::CENTER_LEFT , "%s°", id(globalDisplayVal).at(16).c_str());
// girl-room humidity
it.printf(315, 315, id(icon_40), TextAlign::CENTER_RIGHT, "");
it.printf(235, 315, id(font_40), TextAlign::CENTER_LEFT , "%s", id(globalDisplayVal).at(17).c_str());
/* CO2 icon */
it.print(666, 280, id(icon_70), TextAlign::CENTER_RIGHT, "");
it.printf(773, 280, id(font_55), TextAlign::CENTER_RIGHT, "%s", id(globalDisplayVal).at(18).c_str());
it.printf(800, 300, id(font_14), TextAlign::BASELINE_RIGHT, "ppm");
/* wind */
it.print(400, 280, id(icon_70), TextAlign::CENTER_LEFT, "");
it.printf(525, 280, id(font_55), TextAlign::CENTER_RIGHT, "%s", id(globalDisplayVal).at(19).c_str());
it.printf(525, 280, id(font_14), TextAlign::CENTER_LEFT, "km/h");
/* Moon icon */
//ESP_LOGI("Moon icon", "%s", id(moonPhase).state.c_str());
it.printf(800, 360, id(icon_70), TextAlign::CENTER_RIGHT, "%s", id(globalDisplayVal).at(20).c_str());
/* rain next 3 h */
it.print(400, 190, id(icon_70), TextAlign::CENTER_LEFT, "");
it.printf(550, 190, id(font_55), TextAlign::CENTER_RIGHT, "%s", id(globalDisplayVal).at(21).c_str());
it.printf(555, 190, id(font_14), TextAlign::CENTER_LEFT, "mm");
it.printf(444, 200, id(font_14), TextAlign::CENTER_LEFT, "3h");
// it.line(0, 299, 400, 299);
# Example configuration entry
deep_sleep:
run_duration: 15s
sleep_duration: 33s
id: deep_sleep_1