-
Notifications
You must be signed in to change notification settings - Fork 10
/
display_node.yaml
457 lines (416 loc) · 15.1 KB
/
display_node.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
esphome:
name: display_node
platform: ESP32
board: esp32dev
on_boot:
- output.turn_off: onboard_led
wifi:
networks:
- ssid: "Erlandssons IOT"
password: !secret wifi_iot_password
hidden: true
priority: 256
- ssid: "Fredrik_AP"
password: !secret wifi_password
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Display_node Fallback Hotspot"
password: "N9sWXNGtarny"
captive_portal:
# Enable logging
logger:
level: debug
# Enable Home Assistant API
api:
password: !secret api_password
ota:
password: !secret ota_password
spi:
clk_pin: 13
mosi_pin: 14
# s= '@!"%()+,-_.:°0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz.'
# print([','.join(_) for _ in s])
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: temp_font
size: 32
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: 18
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: chia_font
size: 16
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: 'MaterialDesign-Webfont/fonts/materialdesignicons-webfont.ttf'
id: icon_font_small
size: 22
glyphs: [
'', # mdi-leaf
]
- file: 'MaterialDesign-Webfont/fonts/materialdesignicons-webfont.ttf'
id: icon_font_new
size: 32
glyphs: [
'', # mdi-home-thermometer
'', # mdi-lighthouse
'', # home-automation
'', # mdi-home-variant-outline
'', # beach
'', # swim
"", # mdi-home-thermometer-outline
'', # umbrella
'', # mdi-pool-thermometer
# Sun
"", # mdi-weather-sunset-down
"", # mdi-weather-sunset-up
]
- file: 'MaterialDesign-Webfont/fonts/materialdesignicons-webfont.ttf'
id: wifi_font
size: 32
glyphs: [
# Wifi
'', # mdi-wifi-strength-1
'', # mdi-wifi-strength-2
'', # mdi-wifi-strength-3
'', # mdi-wifi-strength-4
'', # mdi-wifi-strength-alert-outline
]
- file: 'MaterialDesign-Webfont/fonts/materialdesignicons-webfont.ttf'
id: weather_font
size: 50
glyphs: [
# Weather
"", # mdi-weather-sunny
"", # mdi-weather-night
"", # mdi-weather-cloudy
"", # mdi-weather-pouring
"", # mdi-weather-snowy-rainy
"", # mdi-weather-snowy-heavy
"", # mdi-weather-windy-variant
"", # mdi-weather-fog
"", # mdi-weather-night-partly-cloudy
"", # mdi-weather-partly-cloudy
]
- file: 'MaterialDesign-Webfont/fonts/materialdesignicons-webfont.ttf'
id: moon_font
size: 50
glyphs: [
# Moon
"", # first_quarter
"", # full_moon
"", # last_quarter
"", # new_moon
"", # waning_crescent
"", # waning_gibbous
"", # waxing_crescent
"", # waxing_gibbous
]
display:
- platform: waveshare_epaper
id: epaper
cs_pin: 15
busy_pin: 25
reset_pin: 26
dc_pin: 27
model: 4.20in
rotation: 180°
# full_update_every: 30
update_interval: 3600s
lambda: |-
int x, y, c;
ESP_LOGI("display", "Updating..");
/* Print time in HH:MM format */
it.strftime(125, -10, id(clock_font), TextAlign::TOP_CENTER, "%H:%M", id(current_time).now());
it.line(259, -10, 259, 200);it.line(261, 0, 261, 200);it.line(260, 0, 260, 200);
it.line(0, 200, 259, 200);it.line(0, 201, 261, 201);it.line(0, 202, 260, 202);
it.line(0, 201, 500, 201); //it.line(0, 201, 261, 201);it.line(0, 202, 260, 202);
/* Moon icon */
if(id(moon_icon).has_state()) {
y = 155, x = 230;
ESP_LOGI("Moon", "%s", id(moon_icon).state.c_str());
it.printf(x, y, id(moon_font), TextAlign::BASELINE_CENTER, "%s", id(moon_icon).state.c_str());
}
/* WiFi Signal Strenght */
if(id(wifisignal).has_state()) {
x = 398, y = 298;
if (id(wifisignal).state >= -50) {
//Excellent
it.print(x, y, id(wifi_font), TextAlign::BOTTOM_RIGHT, "");
ESP_LOGI("WiFi", "Exellent, ");
} else if (id(wifisignal).state >= -60) {
//Good
it.print(x, y, id(wifi_font), TextAlign::BOTTOM_RIGHT, "");
ESP_LOGI("WiFi", "Good, ");
} else if (id(wifisignal).state >= -67) {
//Fair
it.print(x, y, id(wifi_font), TextAlign::BOTTOM_RIGHT, "");
ESP_LOGI("WiFi", "Fair, ");
} else if (id(wifisignal).state >= -70) {
//Weak
it.print(x, y, id(wifi_font), TextAlign::BOTTOM_RIGHT, "");
ESP_LOGI("WiFi", "Weak, ");
} else {
//Unlikely working signal
it.print(x, y, id(wifi_font), TextAlign::BOTTOM_RIGHT, "");
ESP_LOGI("WiFi", "Unlikely, ");
}
}
// Current weather
if(id(weather_forecast_today).has_state()) {
std::string str = id(weather_forecast_today).state;
ESP_LOGI("Weather", "%s", str.c_str());
std::size_t current, previous = 0;
char delim = ';';
current = str.find(delim);
int y = 140, x = 5;
for (int i=0; i<3; i++) {
if(i == 0) {
it.printf(x, y-2, id(weather_font),
TextAlign::BASELINE_LEFT,
"%s", str.substr(previous, current - previous).c_str());
} else if (i == 1) {
ESP_LOGD("weather","%dx%d %s", (i % 1 ? 270 : 320), x,
str.substr(previous, current - previous).c_str());
/* it.printf(y, x, id(status_font),
TextAlign::TOP_LEFT,
"%s", str.substr(previous, current - previous).c_str());
*/
} else if (i == 2) { // Chance for rain
it.printf(x, y + 2, id(icon_font_new), TextAlign::TOP_LEFT, ""); // Umbrella
it.printf(x + 30, y + 10, id(status_font),
TextAlign::TOP_LEFT,
"%s%%", str.substr(previous, current - previous).c_str());
}
// y += 100;
previous = current + 1;
current = str.find(delim, previous);
}
}
// Print inside temperature (from homeassistant sensor)
y = 138, x = 110;
if (id(inside_temperature).has_state()) {
it.print(x, y-6, id(icon_font_new), TextAlign::BOTTOM_RIGHT, "");
it.printf(x+2, y, id(temp_font), TextAlign::BOTTOM_LEFT , "%5.1f°", id(inside_temperature).state);
}
y += 40;
// Print outside temperature (from homeassistant sensor)
if (id(outside_temperature).has_state()) {
it.print(x, y-6, id(icon_font_new), TextAlign::BOTTOM_RIGHT, "");
it.printf(x+2, y, id(temp_font), TextAlign::BOTTOM_LEFT, "%5.1f°", id(outside_temperature).state);
}
y = 245, x = 40;
// Print ekorrbo temp
if (id(ekorrbo_temperature).has_state()) {
it.printf(x+1, y, id(temp_font), TextAlign::BOTTOM_LEFT, "%5.1f°", id(ekorrbo_temperature).state);
it.print(x, y-6, id(icon_font_new), TextAlign::BOTTOM_RIGHT, "");
}
/*
x = 165;
if (id(tallholmen_temperature).has_state()) {
// Print tallholmen temp
it.printf(x+1, y, id(temp_font), TextAlign::BOTTOM_LEFT, "%5.1f°", id(tallholmen_temperature).state);
it.print(x, y-6, id(icon_font_new), TextAlign::BOTTOM_RIGHT, "");
}
x += 165 - 40;
if (id(pool_temperature).has_state()) {
// Print pool temp
it.printf(x+1, y, id(temp_font), TextAlign::BOTTOM_LEFT, "%5.1f°", id(pool_temperature).state);
it.print(x, y-6, id(icon_font_new), TextAlign::BOTTOM_RIGHT, "");
}
*/
// Print chia
if(id(chia_balance).has_state() && id(flexpool_balance).has_state()) {
it.print(1, 267, id(icon_font_small), TextAlign::BOTTOM_LEFT, "");
if (id(flexpool_update).has_state()) {
//it.printf(23, 270, id(chia_font), TextAlign::BOTTOM_LEFT, "%.2f xch, (%s)", id(chia_balance).state + id(flexpool_balance).state, id(flexpool_update).state.c_str());
//ESP_LOGI("", "%s", id(flexpool_update).state.c_str());
int seconds = round(id(current_time).now().timestamp - atoi(id(flexpool_last_seen_raw).state.c_str()));
int days = seconds / (24 * 3600);
seconds = seconds % (24 * 3600);
int hours = seconds / 3600;
seconds = seconds % 3600;
int minutes = seconds / 60;
seconds = seconds % 60;
ESP_LOGI("", "%.2f xch (%s ago)", id(chia_balance).state + id(flexpool_balance).state, (
(days ? to_string(days) + "d " : "") +
(hours ? to_string(hours) + "h " : "") +
(minutes ? to_string(minutes) + "m" : "")
//+ (to_string(seconds) + "s")
).c_str());
it.printf(23, 270, id(chia_font), TextAlign::BOTTOM_LEFT, "%.2f xch (%s ago)", id(chia_balance).state + id(flexpool_balance).state,
(
(days ? to_string(days) + "d " : "") +
(hours ? to_string(hours) + "h " : "") +
(minutes ? to_string(minutes) + "m" : "")
//+ (to_string(seconds) + "s")
).c_str()
);
} else {
it.printf(23, 270, id(chia_font), TextAlign::BOTTOM_LEFT, "%.2f xch", id(chia_balance).state + id(flexpool_balance).state);
}
}
// std::string str = "mon:cloud:12.1:30%:tue:rain:10.2:40%:wed:sunny:18.0:0%:thu:snow:-12.2:10%";
if(id(weather_forecast).has_state()) {
std::string str = id(weather_forecast).state;
ESP_LOGI("Weather", "%s", str.c_str());
std::size_t current, previous = 0;
char delim = ';';
current = str.find(delim);
int x = 340, y = 2;
for (int i=0; i<4; i++) {
//ESP_LOGI("t", "%d", i);
for (int j=0; j<4; j++) {
if(j == 1) { // Weather icon.
it.printf(x - 65, y + 25, id(weather_font),
TextAlign::BASELINE_LEFT,
"%s", str.substr(previous, current - previous).c_str());
} else {
ESP_LOGD("Weather","%s", str.substr(previous, current - previous).c_str());
it.printf((j == 0 ? x - 10 : 390), y,
id(status_font),
(j == 0 ? TextAlign::TOP_LEFT : TextAlign::TOP_RIGHT),
"%s", str.substr(previous, current - previous).c_str());
y += 16;
}
previous = current + 1;
current = str.find(delim, previous);
}
//y += 2;
}
}
// Print consumer
if (id(top_consumer).has_state()) {
it.printf(1, 295, id(status_font), TextAlign::BOTTOM_LEFT , "Total: %.0f W, %s W", id(sparsnas).state, id(top_consumer).state.c_str());
ESP_LOGI("", "Total: %.0f W, %s W", id(sparsnas).state, id(top_consumer).state.c_str());
}
// it.line(0, 299, 400, 299);
it.graph(239, 201, id(nordpool_graph));
// Print consumer
if (id(nordpool_se4).has_state()) {
it.printf(239, 252, id(chia_font), TextAlign::TOP_LEFT , "SE4: %.02f kr/kWh", id(nordpool_se4).state);
ESP_LOGI("", "SE4: %.02f", id(nordpool_se4).state);
}
output:
- platform: gpio
id: onboard_led
pin:
number: 2
inverted: False
light:
- platform: binary
name: "Onboard LED"
output: onboard_led
time:
#- platform: homeassistant
- platform: sntp
# id: sntp_time
id: current_time
timezone: Europe/Stockholm
on_time:
# Every 1 minutes
- seconds: 0
then:
- component.update: epaper
graph:
- id: nordpool_graph
sensor: nordpool_se4
duration: 32h
width: 160
height: 50
sensor:
- platform: homeassistant
id: inside_temperature
entity_id: sensor.vit_inne_temperature
internal: true
- platform: homeassistant
id: outside_temperature
entity_id: sensor.ute_temperature
internal: true
- platform: homeassistant
id: ekorrbo_temperature
entity_id: sensor.minut_ekorrbo_temperature
internal: true
- platform: homeassistant
id: tallholmen_temperature
entity_id: sensor.badtemp_tallholmen
internal: true
- platform: homeassistant
id: pool_temperature
entity_id: sensor.pool_temperature
internal: true
- platform: homeassistant
entity_id: sensor.qpyjyywb_import_power
id: sparsnas
internal: true
- platform: homeassistant
entity_id: sensor.dark_sky_precip_probability
id: precip_probability
internal: true
- platform: homeassistant
entity_id: sensor.chia_current_balance
id: chia_balance
internal: true
- platform: homeassistant
entity_id: sensor.flexpool_current_balance
id: flexpool_balance
internal: true
- platform: homeassistant
entity_id: sensor.nordpool_kwh_se4_sek_3_10_025
id: nordpool_se4
internal: true
- platform: wifi_signal
name: "WiFi Signal Sensor"
id: wifisignal
update_interval: 60s
text_sensor:
- platform: homeassistant
id: top_consumer
entity_id: sensor.iotawatt_top_consumer
internal: true
- platform: homeassistant
name: forecast
id: weather_forecast
entity_id: sensor.forecast
internal: true
- platform: homeassistant
name: forecast
id: weather_forecast_today
entity_id: sensor.forecast_today
internal: true
- platform: homeassistant
id: moon_icon
entity_id: sensor.moon_tpl
- platform: homeassistant
id: flexpool_payout
entity_id: sensor.flexpool_time_to_payout
internal: true
- platform: homeassistant
id: flexpool_update
entity_id: sensor.flexpool_worker_last_seen
- platform: homeassistant
id: flexpool_last_seen_raw
entity_id: sensor.flexpool_worker_last_seen_raw