-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheink-weather-board.yaml
executable file
·508 lines (438 loc) · 17.5 KB
/
eink-weather-board.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
substitutions:
devicename: eink-weather-board
upper_devicename: "eInk Weather Board"
esphome:
name: ${devicename}
friendly_name: ${upper_devicename}
comment: ${upper_devicename}
name_add_mac_suffix: true
esp32:
board: nodemcu-32s
framework:
type: esp-idf
version: recommended
external_components:
- source: github://tsunglung/esphome_epaper
components: [ display, waveshare_epaper ]
wifi:
networks:
- ssid: !secret wifi_ssid
password: !secret wifi_password
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: ${devicename}
password: "12345678"
captive_portal:
# Enable logging
logger:
# Enable Home Assistant API
api:
reboot_timeout: 0s
# on_client_connected:
# - component.update: my_display
ota:
- platform: esphome
web_server:
# Include custom fonts
font:
- file: 'fonts/GothamRnd-Book.ttf'
id: font_year
size: 60
glyphs:
['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']
- file: 'fonts/GothamRnd-Book.ttf'
id: font_month
size: 80
glyphs:
['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/GothamRnd-Bold.ttf'
id: font_day
size: 100
glyphs:
['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']
- file: 'fonts/GothamRnd-Bold.ttf'
id: font_weekday
size: 70
glyphs:
['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/materialdesigniconswebfont.ttf'
id: icon_today
size: 220
glyphs: &mdi-weather-glyphs
- "\U000F0590" # mdi-weather-cloudy
- "\U000F0F2F" # mdi-weather-cloudy-alert
- "\U000F0E6E" # mdi-weather-cloudy-arrow-right
- "\U000F0591" # mdi-weather-fog
- "\U000F0592" # mdi-weather-hail
- "\U000F0F30" # mdi-weather-hazy
- "\U000F0898" # mdi-weather-hurricane
- "\U000F0593" # mdi-weather-lightning
- "\U000F067E" # mdi-weather-lightning-rainy
- "\U000F0594" # mdi-weather-night
- "\U000F0F31" # mdi-weather-night-partly-cloudy
- "\U000F0595" # mdi-weather-partly-cloudy
- "\U000F0F32" # mdi-weather-partly-lightning
- "\U000F0F33" # mdi-weather-partly-rainy
- "\U000F0F34" # mdi-weather-partly-snowy
- "\U000F0F35" # mdi-weather-partly-snowy-rainy
- "\U000F0596" # mdi-weather-pouring
- "\U000F0597" # mdi-weather-rainy
- "\U000F0598" # mdi-weather-snowy
- "\U000F0F36" # mdi-weather-snowy-heavy
- "\U000F067F" # mdi-weather-snowy-rainy
- "\U000F0599" # mdi-weather-sunny
- "\U000F0F37" # mdi-weather-sunny-alert
- "\U000F14E4" # mdi-weather-sunny-off
- "\U000F059A" # mdi-weather-sunset
- "\U000F059B" # mdi-weather-sunset-down
- "\U000F059C" # mdi-weather-sunset-up
- "\U000F0F38" # mdi-weather-tornado
- "\U000F059D" # mdi-weather-windy
- "\U000F059E" # mdi-weather-windy-variant
#today temp
- file: 'fonts/GothamRnd-Bold.ttf'
id: font_today_temp
size: 50
glyphs: '♡ÆØÅæøå!"%()+,-_.:*=°?~#/³0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyzµ'
- file: 'fonts/GothamRnd-Bold.ttf'
id: font_today_precipitation
size: 70
glyphs: '♡ÆØÅæøå!"%()+,-_.:*=°?~#/³0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyzµ'
#forecast time & temp
- file: 'fonts/GothamRnd-Bold.ttf'
id: font_medium_bold
size: 40
glyphs: '♡ÆØÅæøå!"%()+,-_.:*=°?~#/³0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyzµ'
#forecast icon
- file: 'fonts/materialdesigniconswebfont.ttf'
id: icon_forecast
size: 70
glyphs: *mdi-weather-glyphs
#update time
- file: 'fonts/GothamRnd-Book.ttf'
id: font_smallest
size: 12
glyphs: '♡ÆØÅæøå!"%()+,-_.:*=°?~#/³0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyzµ'
- file: 'fonts/materialdesigniconswebfont.ttf'
id: font_mdi_others
size: 30
glyphs: [
"\U000F050F", # mdi-thermometer
"\U000F0F55", # mdi-home-thermometer-outline
"\U000F18D6", # mdi-sun-thermometer
"\U000F058E", # mdi-water-percent
"\U000F029A", # mdi-gauge
"\U000F059B", # mdi-weather-sunset-down
"\U000F059C", # mdi-weather-sunset-up
"\U000F10C2", # mdi-thermometer-high
"\U000F10C3", # mdi-thermometer-low
"\U000F05A9", # mdi-wifi
"\U000F05AA", # mdi-wifi-off
]
# Include Background
image:
- file: "images/background.png"
id: eink_pannel
type: BINARY
binary_sensor:
- platform: status
name: "WiFi Status"
id: wifistatus
button:
- platform: safe_mode
name: Safe Mode Boot
entity_category: diagnostic
- platform: restart
name: "Restart"
- platform: template
name: 'Screen Refresh'
icon: 'mdi:update'
on_press:
then:
- component.update: 'my_display'
internal: false
color:
- id: color_black
red: 100%
green: 100%
blue: 100%
white: 100%
- id: color_white
red: 0%
green: 0%
blue: 0%
white: 0%
- id: color_red
red: 100%
green: 0%
blue: 0%
white: 0%
spi:
clk_pin: GPIO18
mosi_pin: GPIO23
# Now render everything on the ePaper screen.
display:
- platform: waveshare_epaper
cs_pin: GPIO27 # A17
dc_pin: GPIO14 # A16
busy_pin:
number: GPIO13 # A14
inverted: True
reset_pin: GPIO12 # A15
model: 7.5in-gooddisplay
full_update_every: 10
reset_duration: 10ms
update_interval: never
id: my_display
rotation: 270°
lambda: |-
// background
it.image(0, 0, id(eink_pannel));
//************************ WiFi ************************
if (id(wifisignal).has_state()) {
if (id(wifisignal).state != 0) {
it.print(390, 16, id(font_mdi_others), id(color_white), "\U000F05A9");
}
} else {
it.print(390, 16, id(font_mdi_others), id(color_red), "\U000F05AA");
}
//************************ TODAY ************************
if (id(ha_time)) {
// month
it.strftime(20, 75, id(font_month), id(color_black), TextAlign::TOP_LEFT, "%b", id(ha_time).now());
// day
it.strftime(245, 62, id(font_day), id(color_red), TextAlign::TOP_CENTER, "%d", id(ha_time).now());
// year
it.strftime(390, 93, id(font_year), id(color_black), TextAlign::TOP_CENTER, "%Y", id(ha_time).now());
// weekday
it.strftime(240, 170, id(font_weekday), id(color_black), TextAlign::TOP_CENTER, "%A", id(ha_time).now());
} else {
// month
it.strftime(20, 75, id(font_month), id(color_black), TextAlign::TOP_LEFT, "%b", id(sntp_time).now());
// day
it.strftime(245, 62, id(font_day), id(color_red), TextAlign::TOP_CENTER, "%d", id(sntp_time).now());
// year
it.strftime(390, 93, id(font_year), id(color_black), TextAlign::TOP_CENTER, "%Y", id(sntp_time).now());
// weekday
it.strftime(240, 170, id(font_weekday), id(color_black), TextAlign::TOP_CENTER, "%A", id(sntp_time).now());
}
//************************ TODAY WEATHER ************************
if (id(today_weather).has_state()) {
// Map weather states to MDI characters.
std::map<std::string, std::string> weather_icon_map
{
{"cloudy", "\U000F0590"},
{"cloudy-alert", "\U000F0F2F"},
{"cloudy-arrow-right", "\U000F0E6E"},
{"fog", "\U000F0591"},
{"hail", "\U000F0592"},
{"hazy", "\U000F0F30"},
{"hurricane", "\U000F0898"},
{"lightning", "\U000F0593"},
{"lightning-rainy", "\U000F067E"},
{"night", "\U000F0594"},
{"night-partly-cloudy", "\U000F0F31"},
{"partlycloudy", "\U000F0595"},
{"partly-lightning", "\U000F0F32"},
{"partly-rainy", "\U000F0F33"},
{"partly-snowy", "\U000F0F34"},
{"partly-snowy-rainy", "\U000F0F35"},
{"pouring", "\U000F0596"},
{"rainy", "\U000F0597"},
{"snowy", "\U000F0598"},
{"snowy-heavy", "\U000F0F36"},
{"snowy-rainy", "\U000F067F"},
{"sunny", "\U000F0599"},
{"sunny-alert", "\U000F0F37"},
{"sunny-off", "\U000F14E4"},
{"sunset", "\U000F059A"},
{"sunset-down", "\U000F059B"},
{"sunset-up", "\U000F059C"},
{"tornado", "\U000F0F38"},
{"windy", "\U000F059D"},
{"windy-variant", "\U000F059E"},
};
int today_temp_y = 315;
char temp[256];
// icon
it.printf(105, 310, id(icon_today), id(color_black), TextAlign::TOP_CENTER, "%s", weather_icon_map[id(today_weather).state.c_str()].c_str());
// outdoor temperature
it.print(285, today_temp_y + 45, id(font_mdi_others), id(color_black), TextAlign::TOP_LEFT, "\U000F18D6");
if (atoi(id(today_temperature).state.c_str()) > 30)
it.printf(265, today_temp_y, id(font_today_temp), id(color_red), TextAlign::TOP_LEFT, "%s", id(today_temperature).state.c_str());
else
it.printf(265, today_temp_y, id(font_today_temp), id(color_black), TextAlign::TOP_LEFT, "%s", id(today_temperature).state.c_str());
// outdoor humidity
if (atoi(id(today_humidity).state.c_str()) > 60)
it.printf(265, today_temp_y + 80, id(font_today_temp), id(color_red), TextAlign::TOP_LEFT, "%s", id(today_humidity).state.c_str());
else
it.printf(265, today_temp_y + 80, id(font_today_temp), id(color_black), TextAlign::TOP_LEFT, "%s", id(today_humidity).state.c_str());
// indoor temperature
it.print(385, today_temp_y + 45, id(font_mdi_others), id(color_black), TextAlign::TOP_LEFT, "\U000F0F55");
if(id(temperature_inside).has_state()) {
sprintf(temp, "%2.0f°", id(temperature_inside).state);
if (id(temperature_inside).state > 60)
it.print(365, today_temp_y, id(font_today_temp), id(color_red), TextAlign::TOP_LEFT, ((std::string) temp).c_str());
else
it.print(365, today_temp_y, id(font_today_temp), id(color_black), TextAlign::TOP_LEFT, ((std::string) temp).c_str());
}
// indoor humidity
if(id(humidity_inside).has_state()) {
sprintf(temp, "%2.0f%%", id(humidity_inside).state);
if (id(humidity_inside).state > 60)
it.print(365, today_temp_y + 80, id(font_today_temp), id(color_red), TextAlign::TOP_LEFT, ((std::string) temp).c_str());
else
it.print(365, today_temp_y + 80, id(font_today_temp), id(color_black), TextAlign::TOP_LEFT, ((std::string) temp).c_str());
}
// precipitation
if (atoi(id(today_precipitation).state.c_str()) > 50)
it.printf(285, today_temp_y + 150, id(font_today_precipitation), id(color_red), TextAlign::TOP_LEFT, "%s", id(today_precipitation).state.c_str());
else
it.printf(285, today_temp_y + 150, id(font_today_precipitation), id(color_black), TextAlign::TOP_LEFT, "%s", id(today_precipitation).state.c_str());
//************************ FORECAST ************************
int forecast_y=610;
int forecast_icon_gap=45;
int forecast_data_gap=130;
// HOUR1
// weekday
it.printf(60, forecast_y, id(font_medium_bold), id(color_black), TextAlign::TOP_CENTER, "%s", id(forecast_weekday_1).state.c_str());
// icon
it.printf(60, forecast_y+forecast_icon_gap, id(icon_forecast), id(color_black), TextAlign::TOP_CENTER, "%s", weather_icon_map[id(forecast_weather_1).state.c_str()].c_str());
// temperature
if (atoi(id(forecast_temperature_1).state.c_str()) >= 30)
it.printf(60, forecast_y+forecast_data_gap, id(font_medium_bold), id(color_red), TextAlign::TOP_CENTER, "%s", id(forecast_temperature_1).state.c_str());
else
it.printf(60, forecast_y+forecast_data_gap, id(font_medium_bold), id(color_black), TextAlign::TOP_CENTER, "%s", id(forecast_temperature_1).state.c_str());
// HOUR2
// weekday
it.printf(180, forecast_y, id(font_medium_bold), id(color_black), TextAlign::TOP_CENTER, "%s", id(forecast_weekday_2).state.c_str());
// icon
it.printf(180, forecast_y+forecast_icon_gap, id(icon_forecast), id(color_black), TextAlign::TOP_CENTER, "%s", weather_icon_map[id(forecast_weather_2).state.c_str()].c_str());
// temperature
if (atoi(id(forecast_temperature_2).state.c_str()) >= 30)
it.printf(183, forecast_y+forecast_data_gap, id(font_medium_bold), id(color_red), TextAlign::TOP_CENTER, "%s", id(forecast_temperature_2).state.c_str());
else
it.printf(183, forecast_y+forecast_data_gap, id(font_medium_bold), id(color_black), TextAlign::TOP_CENTER, "%s", id(forecast_temperature_2).state.c_str());
// HOUR3
// weekday
it.printf(300, forecast_y, id(font_medium_bold), id(color_black), TextAlign::TOP_CENTER, "%s", id(forecast_weekday_3).state.c_str());
// icon
it.printf(300, forecast_y+forecast_icon_gap, id(icon_forecast), id(color_black), TextAlign::TOP_CENTER, "%s", weather_icon_map[id(forecast_weather_3).state.c_str()].c_str());
// temperature
if (atoi(id(forecast_temperature_3).state.c_str()) >= 30)
it.printf(303, forecast_y+forecast_data_gap, id(font_medium_bold), id(color_red), TextAlign::TOP_CENTER, "%s", id(forecast_temperature_3).state.c_str());
else
it.printf(303, forecast_y+forecast_data_gap, id(font_medium_bold), id(color_black), TextAlign::TOP_CENTER, "%s", id(forecast_temperature_3).state.c_str());
// HOUR4
// weekday
it.printf(425, forecast_y, id(font_medium_bold), id(color_black), TextAlign::TOP_CENTER, "%s", id(forecast_weekday_4).state.c_str());
// icon
it.printf(425, forecast_y+forecast_icon_gap, id(icon_forecast), id(color_black), TextAlign::TOP_CENTER, "%s", weather_icon_map[id(forecast_weather_4).state.c_str()].c_str());
// temperature
if (atoi(id(forecast_temperature_4).state.c_str()) >= 30)
it.printf(425, forecast_y+forecast_data_gap, id(font_medium_bold), id(color_red), TextAlign::TOP_CENTER, "%s", id(forecast_temperature_4).state.c_str());
else
it.printf(425, forecast_y+forecast_data_gap, id(font_medium_bold), id(color_black), TextAlign::TOP_CENTER, "%s", id(forecast_temperature_4).state.c_str());
}
//last update time
it.strftime(2, 786, id(font_smallest), id(color_black), TextAlign::TOP_LEFT, "%m/%d %H:%M", id(ha_time).now());
sensor:
- platform: uptime
name: Uptime
filters:
- lambda: return x / 3600;
unit_of_measurement: "h"
accuracy_decimals: 1
- platform: wifi_signal
name: "WiFi Signal"
id: wifisignal
update_interval: 60s
- platform: homeassistant # Inside humidity
id: humidity_inside
entity_id: sensor.humidity_158d000227f68f
- platform: homeassistant # Inside temperature
id: temperature_inside
entity_id: sensor.temperature_158d000227f68f
text_sensor:
- platform: version
name: "ESPHome Version"
- platform: wifi_info
ip_address:
name: "IP Address"
- platform: homeassistant
entity_id: sensor.eink_sensors
id: today_weather
- platform: homeassistant
entity_id: sensor.eink_sensors
attribute: today_temperature
id: today_temperature
- platform: homeassistant
entity_id: sensor.eink_sensors
attribute: today_humidity
id: today_humidity
- platform: homeassistant
entity_id: sensor.eink_sensors
attribute: today_precipitation
id: today_precipitation
- platform: homeassistant
entity_id: sensor.eink_sensors
attribute: forecast_weekday_1
id: forecast_weekday_1
- platform: homeassistant
entity_id: sensor.eink_sensors
attribute: forecast_condition_1
id: forecast_weather_1
- platform: homeassistant
entity_id: sensor.eink_sensors
attribute: forecast_temperature_1
id: forecast_temperature_1
- platform: homeassistant
entity_id: sensor.eink_sensors
attribute: forecast_weekday_2
id: forecast_weekday_2
- platform: homeassistant
entity_id: sensor.eink_sensors
attribute: forecast_condition_2
id: forecast_weather_2
- platform: homeassistant
entity_id: sensor.eink_sensors
attribute: forecast_temperature_2
id: forecast_temperature_2
- platform: homeassistant
entity_id: sensor.eink_sensors
attribute: forecast_weekday_3
id: forecast_weekday_3
- platform: homeassistant
entity_id: sensor.eink_sensors
attribute: forecast_condition_3
id: forecast_weather_3
- platform: homeassistant
entity_id: sensor.eink_sensors
attribute: forecast_temperature_3
id: forecast_temperature_3
- platform: homeassistant
entity_id: sensor.eink_sensors
attribute: forecast_weekday_4
id: forecast_weekday_4
- platform: homeassistant
entity_id: sensor.eink_sensors
attribute: forecast_condition_4
id: forecast_weather_4
- platform: homeassistant
entity_id: sensor.eink_sensors
attribute: forecast_temperature_4
id: forecast_temperature_4
time:
- platform: homeassistant
id: ha_time
- platform: sntp
id: sntp_time
timezone: Asia/Taipei