-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathf1pitboard.yaml
More file actions
469 lines (384 loc) · 15.6 KB
/
f1pitboard.yaml
File metadata and controls
469 lines (384 loc) · 15.6 KB
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
esphome:
name: "f1pitboard"
on_boot:
priority: 200.0
then:
- component.update: eink_display
- wait_until:
condition:
lambda: 'return id(data_updated) == true;'
- delay: 5s
- logger.log: "Initial sensor data received: Refreshing display..."
- lambda: 'id(initial_data_received) = true;'
- script.execute: update_screen_f1pitboard
esp32:
board: esp32dev
framework:
type: arduino
# Enable logging
logger:
# Enable Home Assistant API
api:
ota:
- platform: esphome
# Creates buttons in Home Assistant to
button:
- platform: shutdown
name: "F1 Pit Board - Shutdown"
- platform: restart
name: "F1 Pit Board - Restart"
- platform: template
name: "F1 Pit Board - Refresh Screen"
entity_category: config
on_press:
- script.execute: update_screen_f1pitboard
# Global variables for detecting if the display needs to be refreshed. (Thanks @paviro!)
globals:
- id: data_updated
type: bool
restore_value: no
initial_value: 'false'
- id: initial_data_received
type: bool
restore_value: no
initial_value: 'false'
- id: recorded_display_refresh
type: int
restore_value: yes
initial_value: '0'
# Script for updating screen - Refresh display and publish refresh count and time. (Thanks @paviro!)
script:
- id: update_screen_f1pitboard
then:
- lambda: 'id(data_updated) = false;'
- component.update: eink_display
- lambda: 'id(recorded_display_refresh) += 1;'
- lambda: 'id(display_last_update).publish_state(id(homeassistant_time).now().timestamp);'
# Check whether the display needs to be refreshed every minute,
# based on whether new data is received or motion is detected. (Thanks @paviro!)
time:
- platform: homeassistant
id: homeassistant_time
on_time:
- seconds: 0
hours: /1
then:
- if:
condition:
lambda: 'return id(data_updated);'
then:
- logger.log: "Sensordata uppdaterad: Refreshing display..."
- lambda: 'id(data_updated) = false;'
- script.execute: update_screen_f1pitboard
else:
- logger.log: "Ingen ny data, hoppar över uppdatering."
- hours: 6
minutes: 0
seconds: 0
then:
- logger.log: "Schemalagd uppdatering kl 06:00"
- script.execute: update_screen_f1pitboard
- hours: 9
minutes: 0
seconds: 0
days_of_week: [5, 6, 7]
then:
- logger.log: "Schemalagd uppdatering fre-sön)"
- script.execute: update_screen_f1pitboard
- hours: 12
minutes: 0
seconds: 0
then:
- logger.log: "Schemalagd uppdatering fre-sön)"
- script.execute: update_screen_f1pitboard
- hours: 15
minutes: 0
seconds: 0
days_of_week: [5, 6, 7]
then:
- logger.log: "Schemalagd uppdatering fre-sön)"
- script.execute: update_screen_f1pitboard
- hours: 18
minutes: 0
seconds: 0
then:
- logger.log: "Schemalagd uppdatering fre-sön)"
- script.execute: update_screen_f1pitboard
- hours: 21
minutes: 0
seconds: 0
days_of_week: [5, 6, 7]
then:
- logger.log: "Schemalagd uppdatering fre-sön)"
- script.execute: update_screen_f1pitboard
# Wifi information
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
use_address: 192.168.1.231
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: !secret wifi_ssid
password: !secret wifi_password
# Include custom fonts
font:
# - file: 'fonts/TitilliumWeb-Regular.ttf'
- file: 'fonts/GothamRnd-Book.ttf'
id: font_small_book
size: 18
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', 'å', 'ä', 'ö', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', ':', '-', ' ', '°', '.', ',', 'ó', 'í', 'ã']
# - file: 'fonts/TitilliumWeb-Bold.ttf'
- file: 'fonts/GothamRnd-Bold.ttf'
id: font_title
size: 108
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', 'å', 'ä', 'ö', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', ':', '-', ' ', '°', '.', ',', 'ó', 'í', 'ã', 'é']
- file: 'fonts/GothamRnd-Bold.ttf'
id: font_nr_big
size: 220
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', 'å', 'ä', 'ö', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', ':', '-', ' ', '°', '.', ',', 'ó', 'í', 'ã', 'é']
# - file: 'fonts/TitilliumWeb-Bold.ttf'
- file: 'fonts/GothamRnd-Bold.ttf'
id: font_title_small
size: 30
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', 'å', 'ä', 'ö', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', ':', '-', ' ', '°', '.', ',', 'ó', 'í', 'ã', 'é']
# - file: 'fonts/TitilliumWeb-Bold.ttf'
- file: 'fonts/GothamRnd-Bold.ttf'
id: font_medium_bold
size: 24
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', 'å', 'ä', 'ö', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', ':', '-', ' ', '°', '.', ',', 'ó', 'í', 'ã', 'é']
# - file: 'fonts/TitilliumWeb-Bold.ttf'
- file: 'fonts/GothamRnd-Bold.ttf'
id: font_small_bold
size: 18
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', 'å', 'ä', 'ö', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', ':', '-', ' ', '°', '.', ',', 'ó', 'í', 'ã', 'é']
# - file: 'fonts/TitilliumWeb-Bold.ttf'
- file: 'fonts/GothamRnd-Bold.ttf'
id: font_title_bold
size: 54
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', 'å', 'ä', 'ö', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', ':', '-', ' ', '°', '.', ',', 'ó', 'í', 'ã', 'é']
# - file: 'fonts/TitilliumWeb-Bold.ttf'
- file: 'fonts/GothamRnd-Bold.ttf'
id: font_title_bold_medium
size: 36
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', 'å', 'ä', 'ö', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', ':', '-', ' ', '°', '.', ',', 'ó', 'í', 'ã', 'é']
- file: 'fonts/materialdesignicons-webfont.ttf'
id: font_mdi_medlarge
size: 36
glyphs:
- "\U000F02A4" # GitHub
- "\U000F04D2" # Star
- "\U000F04FC" # Tag
- file: 'fonts/materialdesignicons-webfont.ttf'
id: font_mdi_icon
size: 24
glyphs:
- "\U000F02A4" # GitHub
- "\U000F04D2" # Star
- "\U000F04FC" # Tag
# Include Images
image:
- file: "images/f1.png"
id: image_f1
type: RGB565
transparency: alpha_channel
sensor:
- platform: template
name: "F1 Pit Board - Display Last Update"
device_class: timestamp
entity_category: "diagnostic"
id: display_last_update
- platform: template
name: "F1 Pit Board - Recorded Display Refresh"
accuracy_decimals: 0
unit_of_measurement: "Refreshes"
state_class: "total_increasing"
entity_category: "diagnostic"
lambda: 'return id(recorded_display_refresh);'
# Call information from HA
text_sensor:
- platform: homeassistant
entity_id: sensor.f1_data_race
attribute: next_race_day_days_countdown
id: next_race_day_days_countdown
on_value:
then:
- lambda: 'id(data_updated) = true;'
- platform: homeassistant
entity_id: sensor.dagar_till_f1_2026
id: dagar_till_f1_2026
on_value:
then:
- lambda: 'id(data_updated) = true;'
- platform: homeassistant
entity_id: sensor.github_f1_sensor
id: git_hub_stars
on_value:
then:
- lambda: 'id(data_updated) = true;'
- platform: homeassistant
entity_id: sensor.github_f1_sensor
attribute: tag_name
id: github_tag
on_value:
then:
- lambda: 'id(data_updated) = true;'
- platform: homeassistant
entity_id: sensor.github_f1_sensor
attribute: download_count
id: github_downloads
on_value:
then:
- lambda: 'id(data_updated) = true;'
- platform: homeassistant
entity_id: sensor.f1_data_race
attribute: next_race_GP
id: next_race_GP
on_value:
then:
- lambda: 'id(data_updated) = true;'
- platform: homeassistant
entity_id: sensor.f1_data_race
attribute: next_race_day_and_time
id: next_race_day_and_time
on_value:
then:
- lambda: 'id(data_updated) = true;'
- platform: homeassistant
entity_id: sensor.f1_data_race
attribute: next_race_circuit
id: next_race_circuit
on_value:
then:
- lambda: 'id(data_updated) = true;'
- platform: homeassistant
entity_id: sensor.f1_data_race
attribute: next_race_location
id: next_race_location
on_value:
then:
- lambda: 'id(data_updated) = true;'
- platform: homeassistant
entity_id: sensor.f1_data_race
attribute: next_race_quali_and_time
id: next_race_quali_and_time
on_value:
then:
- lambda: 'id(data_updated) = true;'
- platform: homeassistant
entity_id: sensor.f1_data_race
attribute: next_race_fp1_and_time
id: next_race_fp1_and_time
on_value:
then:
- lambda: 'id(data_updated) = true;'
- platform: homeassistant
entity_id: sensor.f1_data_race
attribute: next_race_fp2_and_time
id: next_race_fp2_and_time
on_value:
then:
- lambda: 'id(data_updated) = true;'
- platform: homeassistant
entity_id: sensor.f1_data_race
attribute: next_race_fp3_and_time
id: next_race_fp3_and_time
on_value:
then:
- lambda: 'id(data_updated) = true;'
- platform: homeassistant
entity_id: sensor.f1_data_race
attribute: next_race_sprint_quali_and_time
id: next_race_sprint_quali_and_time
on_value:
then:
- lambda: 'id(data_updated) = true;'
- platform: homeassistant
entity_id: sensor.f1_data_race
attribute: next_race_sprint_and_time
id: next_race_sprint_and_time
on_value:
then:
- lambda: 'id(data_updated) = true;'
- platform: homeassistant
entity_id: sensor.f1_data_race
attribute: race_schedule_plus1
id: race_schedule_plus1
on_value:
then:
- lambda: 'id(data_updated) = true;'
- platform: homeassistant
entity_id: sensor.f1_data_race
attribute: race_schedule_plus2
id: race_schedule_plus2
on_value:
then:
- lambda: 'id(data_updated) = true;'
- platform: homeassistant
entity_id: sensor.f1_data_race
attribute: race_schedule_plus3
id: race_schedule_plus3
on_value:
then:
- lambda: 'id(data_updated) = true;'
# Pins for Waveshare ePaper ESP Board
spi:
clk_pin: GPIO13
mosi_pin: GPIO14
# Now render everything on the ePaper screen.
display:
- platform: waveshare_epaper
id: eink_display
cs_pin: GPIO15
dc_pin: GPIO27
busy_pin:
number: GPIO25
inverted: true
reset_pin: GPIO26
reset_duration: 2ms
model: 7.50inV2alt
update_interval: never
rotation: 90°
lambda: |-
if (id(initial_data_received) == false) {
// 1. Visa "loading screen"
it.printf(240, 350, id(font_small_bold), TextAlign::TOP_CENTER, "LIGHTS OUT AND AWAY WE GO");
it.image(150, 200, id(image_f1));
} else {
// 2. Visa raceinformation (alltid när data finns)
it.image(60, 140, id(image_f1));
it.printf(320, 100, id(font_title), TextAlign::TOP_CENTER, "%s", id(next_race_day_days_countdown).state.c_str());
it.printf(260, 200, id(font_medium_bold), TextAlign::TOP_LEFT, "dagar till");
it.printf(50, 250, id(font_title_small), TextAlign::TOP_LEFT, "%s", id(next_race_GP).state.c_str());
it.printf(50, 290, id(font_medium_bold), TextAlign::TOP_LEFT, "%s", id(next_race_day_and_time).state.c_str());
it.printf(50, 330, id(font_small_bold), TextAlign::TOP_LEFT, "%s", id(next_race_circuit).state.c_str());
it.printf(50, 355, id(font_small_book), TextAlign::TOP_LEFT, "%s", id(next_race_location).state.c_str());
int countdown = atoi(id(next_race_day_days_countdown).state.c_str());
if (countdown >= 1 && countdown <= 4) {
it.printf(50, 400, id(font_small_bold), TextAlign::TOP_LEFT, "%s", id(next_race_quali_and_time).state.c_str());
it.printf(50, 430, id(font_small_book), TextAlign::TOP_LEFT, "%s", id(next_race_fp1_and_time).state.c_str());
if (
id(next_race_sprint_quali_and_time).state == "" &&
id(next_race_sprint_and_time).state == ""
) {
it.printf(50, 460, id(font_small_book), TextAlign::TOP_LEFT, "%s", id(next_race_fp2_and_time).state.c_str());
it.printf(50, 490, id(font_small_book), TextAlign::TOP_LEFT, "%s", id(next_race_fp3_and_time).state.c_str());
} else if (
id(next_race_sprint_quali_and_time).state != "" &&
id(next_race_sprint_and_time).state != ""
) {
it.printf(50, 460, id(font_small_book), TextAlign::TOP_LEFT, "%s", id(next_race_sprint_quali_and_time).state.c_str());
it.printf(50, 490, id(font_small_book), TextAlign::TOP_LEFT, "%s", id(next_race_sprint_and_time).state.c_str());
}
}
it.rectangle(20, 535, 410, 1);
it.printf(50, 560, id(font_small_bold), TextAlign::TOP_LEFT, "Kommande race:");
it.printf(50, 585, id(font_small_book), TextAlign::TOP_LEFT, "%s", id(race_schedule_plus1).state.c_str());
it.printf(50, 610, id(font_small_book), TextAlign::TOP_LEFT, "%s", id(race_schedule_plus2).state.c_str());
it.printf(50, 635, id(font_small_book), TextAlign::TOP_LEFT, "%s", id(race_schedule_plus3).state.c_str());
// Refresh timestamp längst ner
char str[17];
time_t currTime = id(homeassistant_time).now().timestamp;
strftime(str, sizeof(str), "%d %b %H:%M", localtime(&currTime));
it.printf(210, 710, id(font_small_book), TextAlign::TOP_CENTER, "%s", str);
}
captive_portal: