-
Notifications
You must be signed in to change notification settings - Fork 1
/
ESPHome_eink-tasksboard.yaml
1033 lines (986 loc) · 38.5 KB
/
ESPHome_eink-tasksboard.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
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# Inspired by https://github.com/Madelena/esphome-weatherman-dashboard
# And https://blog.wijman.net/e-ink-weather-frame-with-esphome-and-home-assistant/
# With a lot of my own additions, fixes, edits. My github: https://github.com/trip5
substitutions:
name: eink-tasksboard
friendly_name: eInk-TasksBoard
project_name: "Trip5.eInk-TasksBoard"
comment: "eInk-TasksBoard from Trip5"
project_version: "2024.07.14"
time_zone: "Asia/Seoul" # Check https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
adc_pin: GPIO34
sleep_time: 600min # this is the default but is overridden
# Home Assistant entitites:
ha_disable_update: input_boolean.eink_tasksboard_disable_update
ha_disable_deep_sleep: input_boolean.eink_tasksboard_disable_deep_sleep
ha_tasks_data: sensor.eink_tasksboard_data
ha_wake_times: sensor.eink_tasksboard_wake_times
# Waveshare eInk Board:
status_led_pin: GPIO2
mosi_pin: GPIO14
clk_pin: GPIO13
cs_pin: GPIO15
dc_pin: GPIO27
reset_pin: GPIO26
busy_pin: GPIO25
busy_inverted: "true" #needed on most newer boards: check ESPHome or component notes
# Everything here is meant for an 7.5 inch tricolor display, which is not directly supported by ESPHome
# See here for full list of directly-supported displays: https://esphome.io/components/display/waveshare_epaper.html
# if using only BW, then you may need to edit colors below (change red to same as black)
# model: 7.50in-bV2 # Looks good but crazy flashing (use white 100%)
# model: 7.50in-bV3 # a bit washed-out (use white 100%)
# model: 7.50inV2alt # a bit washed-out (use white 100%)
# Two custom components work with the 7.5 inch Waveshare displays... If you want to see the full discussion: https://github.com/esphome/feature-requests/issues/239
# atomicmike's custom component should be closer to the manufacturer's spec but but might have issues - be sure it's specified properly below too! (inverted true)
# model: 7.50inv2b
# reset_duration: 3ms
# There is some speculation that twisterss' custom component might be better - be sure it's specified properly below too! (inverted true)
model: 7.50in-bv2-rb
reset_duration: 2ms
external_components:
# use atomicmike's repo:
# - source:
# type: git
# url: https://github.com/atomicmike/esphome.git
# ref: waveshare-color-2023.12
# components: [ waveshare_epaper ]
# use twisterss' repo:
- source:
type: git
url: https://github.com/twisterss/esphome-dev.git
ref: waveshare-red-black
components: [ waveshare_epaper ]
esphome:
name: $name
comment: "$comment"
project:
name: "$project_name"
version: "$project_version"
on_boot:
priority: 200.0
then:
#- lambda: 'id(recorded_display_refresh) = 2106;' # if you need to manually update the number of refreshes
- script.execute: get_data_then_refresh_screen
esp32:
board: esp32dev
framework:
type: arduino
preferences:
flash_write_interval: 5s # default is 1min but seems sometimes id(recorded_display_refresh) doesn't get saved unless this is short
ota:
- platform: esphome
password: !secret ota_password
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
fast_connect: true
ap:
ssid: $name
password: !secret ap_password
web_server:
port: 80
ota: true
include_internal: true
captive_portal:
# Enable logging (and stops the LED from spamming the log) - it would also be OK to change the main level to ERROR
logger:
level: DEBUG
logs:
light: ERROR
script: ERROR
sensor: ERROR
# Enable Home Assistant API
api:
button:
- platform: restart
name: "$friendly_name Restart"
id: "Restart"
internal: true
- platform: template
name: "$friendly_name Refresh Screen"
entity_category: config
on_press:
- lambda: 'id(data_updated) = true;'
- script.execute: refresh_screen
output:
- platform: ledc
id: statusled
pin:
number: $status_led_pin
ignore_strapping_warning: true
light:
- platform: monochromatic
id: led1
name: "LED"
output: statusled
internal: true
# Define colors - this design is white on black so this is necessary
color:
- id: color_blk
red: 100%
green: 100%
blue: 100%
white: 100%
- id: color_red
red: 100%
green: 0%
blue: 0%
white: 0%
# Pins for Waveshare ePaper ESP Board
spi:
clk_pin: $clk_pin
mosi_pin: $mosi_pin
# Global variables for detecting if the display needs to be refreshed.
globals:
- id: data_updated
type: bool
restore_value: no
initial_value: 'false'
- id: wake_time_helper_updated
type: bool
restore_value: no
initial_value: 'false'
- id: recorded_display_refresh
type: int
restore_value: yes
initial_value: '0'
script:
- id: get_data_then_refresh_screen
mode: restart
then:
- script.execute: led_blink
- wait_until:
condition:
lambda: 'return id(data_updated) == true;'
timeout: 60s
- wait_until: # should wait until the wake_time_helper is actually updated (to evaluate the next condition)
condition:
lambda: 'return id(wake_time_helper_updated) == true;'
timeout: 2min
- if: # with longer sleep delays, the ESP32 tends to wake up a bit too early... if the wake time is within the next 8 minutes, wait for the scheduled wake time (less 30s) (preventing it from updating twice in a row)
condition:
lambda: 'return (id(wake_time_helper).state <= (8 * 60));'
then:
- delay: !lambda 'return (((id(wake_time_helper).state) - 30) * 1000);' # lambdas should return value as ms
- if:
condition:
lambda: 'return id(data_updated) == true;'
then:
- delay: 15s # Wait a bit longer so all the items are received. Might need to be more (5s not enough, 10s sometimes isn't enough)
- logger.log: "Sensor data received."
- script.execute: refresh_screen
else:
- logger.log: "No new data. Skipping display refresh."
- script.execute: deep_sleep_evaluation
- id: refresh_screen
mode: restart
then:
- if:
condition:
binary_sensor.is_off: disable_update
then:
- lambda: 'id(recorded_display_refresh) += 1;'
- lambda: 'id(display_last_update).publish_state(id(homeassistant_time).now().timestamp);'
- output.turn_on: statusled
- logger.log: "Refreshing display..."
- light.turn_on: led1
- component.update: eink_display
- script.execute: led_blink
- lambda: 'id(data_updated) = false;'
- delay: 5s # If deep sleep follows immediately, then we need a short delay here so HA catches the refresh count
else:
- logger.log: "Home Assistant Helper 'Disable Update' is on. Skipping display refresh."
- script.execute: deep_sleep_evaluation
- id: deep_sleep_evaluation
# This dynamic deep sleep script inspired by https://webbinaro.dev/blog/battery-powered-esp-sensors-esphome/
mode: restart
then:
- if:
condition:
binary_sensor.is_on: disable_deep_sleep
then:
- logger.log: 'Deep Sleep Disabled.'
- script.execute: deep_sleep_disabled_check_refresh_time
else:
- wait_until:
condition:
lambda: 'return (id(wake_time_helper).state >= (6 * 60));'
- deep_sleep.enter:
id: deep_sleep_control
sleep_duration: !lambda return id(wake_time_helper).state * 1000; # lambdas should return value as ms
- delay: 60s
- script.execute: deep_sleep_evaluation
- id: deep_sleep_disabled_check_refresh_time
# This will update the screen on the HA helper schedule(ish) even if Deep Sleep is disabled
mode: restart
then:
- if:
condition:
- lambda: 'return id(wake_time_helper).state <= 60;'
then:
- logger.log: 'Time to refresh the screen.'
- script.execute: get_data_then_refresh_screen
- id: led_blink
# This will make a breathing effect on the status LED if the power is on
mode: restart
then:
- delay: 1s
- light.turn_off: led1
- delay: 4s
- light.turn_on: led1
- script.execute: led_blink
deep_sleep:
id: deep_sleep_control
sleep_duration: $sleep_time
time:
- platform: homeassistant
timezone: "$time_zone"
id: homeassistant_time
# if using USB battery, deep sleep is disabled, and more constant refreshes are OK, then you may need this bit:
#on_time:
# - seconds: 0
# minutes: 0,15,30,45
# then:
# - script.execute: get_data_then_refresh_screen
# The following are boolean helpers in Home Assistant
binary_sensor:
- platform: homeassistant
id: disable_deep_sleep
name: "$friendly_name Disable Deep Sleep"
entity_id: '${ha_disable_deep_sleep}'
- platform: homeassistant
id: disable_update
name: "$friendly_name Disable Update"
entity_id: '${ha_disable_update}'
# Include custom fonts:
font:
# Gotham Rounded - for headers and text (by Tobias Frere Jones)
# Get the Book version here: https://fontsgeek.com/fonts/Gotham-Book
# Get the Bold version here: https://fontsgeek.com/fonts/Gotham-Rounded-Bold
# Get the Medium version here: https://fontsgeek.com/fonts/Gotham-Rounded-Medium
# The glyphs must be present or you'll see boxes/blank spaces (no problem unless you edit the Display section below) - don't forget to include a space!
# How to get an easy glyphs list? Copy the code from here: https://www.geeksforgeeks.org/cpp-program-to-remove-duplicates-from-a-given-string/
# ...to here: https://www.onlinegdb.com/online_c++_compiler
- file: 'fonts/Gotham-Rounded-Bold.ttf'
id: font_title
size: 52
glyphs: |
T LOADING
- file: 'fonts/Gotham-Rounded-Bold.ttf'
id: font_small_title
size: 30
glyphs: |
UPCOMING
- file: 'fonts/Gotham-Rounded-Book.ttf'
id: font_refresh_stamp
size: 20
glyphs: |
Refrshd at1234567890:AMPSunoTWFi
# The fonts below this point will be used to display tasks - if you see black squares on your taskboard, you forgot to include it on the glyphs list!
# Easy to forget characters include currency marks and emoji. It is also possible the glyph doesn't exist in the font (for example the Korean Won ₩ character)
- file: 'fonts/Gotham-Rounded-Bold.ttf'
id: font_today_list
size: 26
glyphs: |
! "#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz°₩
- file: 'fonts/Gotham-Rounded-Medium.ttf'
id: font_upcoming_date
size: 20
glyphs: |
! "#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz°₩
- file: 'fonts/Gotham-Rounded-Bold.ttf'
id: font_upcoming_item
size: 22
glyphs: |
! "#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz°₩
# Include Material Design Icons font (for battery icons) (by Austin Andrews / Templarian)
# Get it here: https://github.com/Templarian/MaterialDesign-Webfont/
# Encoding glyphs from here: https://community.home-assistant.io/t/display-materialdesign-icons-on-esphome-attached-to-screen/199790/16
- file: 'fonts/materialdesignicons-webfont.ttf'
id: font_battery_glyphs
size: 22
glyphs: &mdi-battery-glyphs
- "\U000F10CD" # mdi-battery-warning
- "\U000F12A3" # mdi-battery-high
- "\U000F12A2" # mdi-battery-med
- "\U000F12A1" # mdi-battery-low
sensor:
# Create sensors for monitoring the board remotely.
- platform: template
name: "$friendly_name Display Last Update"
device_class: timestamp
entity_category: "diagnostic"
id: display_last_update
update_interval: 3s
- platform: template
name: "$friendly_name Recorded Display Refresh"
accuracy_decimals: 0
unit_of_measurement: "Refreshes"
state_class: "total_increasing"
entity_category: "diagnostic"
lambda: 'return id(recorded_display_refresh);'
update_interval: 3s
- platform: wifi_signal
name: "$friendly_name WiFi Signal Strength"
id: wifisignal
unit_of_measurement: "dBm"
entity_category: "diagnostic"
update_interval: 3s
filters:
#use moving median to smooth spikes
- median:
window_size: 5
send_every: 5
send_first_at: 5
- platform: adc
name: "$friendly_name Battery"
id: battery_adc
pin: $adc_pin
attenuation: 12db
update_interval: 3s
entity_category: "diagnostic"
accuracy_decimals: 2
filters:
# this multiply number may need to be manually adjusted with power on while idle
# I used a LiPo battery: negative pole -> 33K resistor -> ADC GPIO -> 100K resistor -> GND
- multiply: 1.33
#use moving median to smooth spikes
- median:
window_size: 5
send_every: 5
send_first_at: 5
# Call numeric sensors from Home Assistant
- platform: homeassistant
name: "$friendly_name Wake Time Helper"
id: wake_time_helper
entity_id: '${ha_wake_times}'
attribute: wake_time_helper
unit_of_measurement: seconds
on_value:
then:
- lambda: 'id(wake_time_helper_updated) = true;'
text_sensor:
- platform: version
name: "$friendly_name ESPHome Version"
hide_timestamp: true
entity_category: diagnostic
- platform: wifi_info
ip_address:
id: wifi_ip
name: "$friendly_name IP Address"
entity_category: diagnostic
ssid:
id: wifi_ssid
name: "$friendly_name SSID"
entity_category: diagnostic
- platform: template
name: "$friendly_name $project_name Version"
lambda: |-
return {"$project_version"};
entity_category: diagnostic
# Call text sensors from Home Assistant
- platform: homeassistant
entity_id: '${ha_tasks_data}'
attribute: today_0
id: today_0
on_value:
then:
- lambda: 'id(data_updated) = true;'
- platform: homeassistant
entity_id: '${ha_tasks_data}'
attribute: today_1
id: today_1
on_value:
then:
- lambda: 'id(data_updated) = true;'
- platform: homeassistant
entity_id: '${ha_tasks_data}'
attribute: today_2
id: today_2
on_value:
then:
- lambda: 'id(data_updated) = true;'
- platform: homeassistant
entity_id: '${ha_tasks_data}'
attribute: today_3
id: today_3
on_value:
then:
- lambda: 'id(data_updated) = true;'
- platform: homeassistant
entity_id: '${ha_tasks_data}'
attribute: today_4
id: today_4
on_value:
then:
- lambda: 'id(data_updated) = true;'
- platform: homeassistant
entity_id: '${ha_tasks_data}'
attribute: today_5
id: today_5
on_value:
then:
- lambda: 'id(data_updated) = true;'
- platform: homeassistant
entity_id: '${ha_tasks_data}'
attribute: today_6
id: today_6
on_value:
then:
- lambda: 'id(data_updated) = true;'
- platform: homeassistant
entity_id: '${ha_tasks_data}'
attribute: today_7
id: today_7
on_value:
then:
- lambda: 'id(data_updated) = true;'
- platform: homeassistant
entity_id: '${ha_tasks_data}'
attribute: today_8
id: today_8
on_value:
then:
- lambda: 'id(data_updated) = true;'
- platform: homeassistant
entity_id: '${ha_tasks_data}'
attribute: today_9
id: today_9
on_value:
then:
- lambda: 'id(data_updated) = true;'
- platform: homeassistant
entity_id: '${ha_tasks_data}'
attribute: upcoming_date_0
id: upcoming_date_0
on_value:
then:
- lambda: 'id(data_updated) = true;'
- platform: homeassistant
entity_id: '${ha_tasks_data}'
attribute: upcoming_item_0
id: upcoming_item_0
on_value:
then:
- lambda: 'id(data_updated) = true;'
- platform: homeassistant
entity_id: '${ha_tasks_data}'
attribute: upcoming_date_1
id: upcoming_date_1
on_value:
then:
- lambda: 'id(data_updated) = true;'
- platform: homeassistant
entity_id: '${ha_tasks_data}'
attribute: upcoming_item_1
id: upcoming_item_1
on_value:
then:
- lambda: 'id(data_updated) = true;'
- platform: homeassistant
entity_id: '${ha_tasks_data}'
attribute: upcoming_date_2
id: upcoming_date_2
on_value:
then:
- lambda: 'id(data_updated) = true;'
- platform: homeassistant
entity_id: '${ha_tasks_data}'
attribute: upcoming_item_2
id: upcoming_item_2
on_value:
then:
- lambda: 'id(data_updated) = true;'
- platform: homeassistant
entity_id: '${ha_tasks_data}'
attribute: upcoming_date_3
id: upcoming_date_3
on_value:
then:
- lambda: 'id(data_updated) = true;'
- platform: homeassistant
entity_id: '${ha_tasks_data}'
attribute: upcoming_item_3
id: upcoming_item_3
on_value:
then:
- lambda: 'id(data_updated) = true;'
- platform: homeassistant
entity_id: '${ha_tasks_data}'
attribute: upcoming_date_4
id: upcoming_date_4
on_value:
then:
- lambda: 'id(data_updated) = true;'
- platform: homeassistant
entity_id: '${ha_tasks_data}'
attribute: upcoming_item_4
id: upcoming_item_4
on_value:
then:
- lambda: 'id(data_updated) = true;'
- platform: homeassistant
entity_id: '${ha_tasks_data}'
attribute: upcoming_date_5
id: upcoming_date_5
on_value:
then:
- lambda: 'id(data_updated) = true;'
- platform: homeassistant
entity_id: '${ha_tasks_data}'
attribute: upcoming_item_5
id: upcoming_item_5
on_value:
then:
- lambda: 'id(data_updated) = true;'
- platform: homeassistant
entity_id: '${ha_tasks_data}'
attribute: upcoming_date_6
id: upcoming_date_6
on_value:
then:
- lambda: 'id(data_updated) = true;'
- platform: homeassistant
entity_id: '${ha_tasks_data}'
attribute: upcoming_item_6
id: upcoming_item_6
on_value:
then:
- lambda: 'id(data_updated) = true;'
- platform: homeassistant
entity_id: '${ha_tasks_data}'
attribute: upcoming_date_7
id: upcoming_date_7
on_value:
then:
- lambda: 'id(data_updated) = true;'
- platform: homeassistant
entity_id: '${ha_tasks_data}'
attribute: upcoming_item_7
id: upcoming_item_7
on_value:
then:
- lambda: 'id(data_updated) = true;'
- platform: homeassistant
entity_id: '${ha_tasks_data}'
attribute: upcoming_date_8
id: upcoming_date_8
on_value:
then:
- lambda: 'id(data_updated) = true;'
- platform: homeassistant
entity_id: '${ha_tasks_data}'
attribute: upcoming_item_8
id: upcoming_item_8
on_value:
then:
- lambda: 'id(data_updated) = true;'
- platform: homeassistant
entity_id: '${ha_tasks_data}'
attribute: upcoming_date_9
id: upcoming_date_9
on_value:
then:
- lambda: 'id(data_updated) = true;'
- platform: homeassistant
entity_id: '${ha_tasks_data}'
attribute: upcoming_item_9
id: upcoming_item_9
on_value:
then:
- lambda: 'id(data_updated) = true;'
- platform: homeassistant
entity_id: '${ha_tasks_data}'
attribute: upcoming_date_10
id: upcoming_date_10
on_value:
then:
- lambda: 'id(data_updated) = true;'
- platform: homeassistant
entity_id: '${ha_tasks_data}'
attribute: upcoming_item_10
id: upcoming_item_10
on_value:
then:
- lambda: 'id(data_updated) = true;'
- platform: homeassistant
entity_id: '${ha_tasks_data}'
attribute: upcoming_date_11
id: upcoming_date_11
on_value:
then:
- lambda: 'id(data_updated) = true;'
- platform: homeassistant
entity_id: '${ha_tasks_data}'
attribute: upcoming_item_11
id: upcoming_item_11
on_value:
then:
- lambda: 'id(data_updated) = true;'
- platform: homeassistant
entity_id: '${ha_tasks_data}'
attribute: upcoming_date_12
id: upcoming_date_12
on_value:
then:
- lambda: 'id(data_updated) = true;'
- platform: homeassistant
entity_id: '${ha_tasks_data}'
attribute: upcoming_item_12
id: upcoming_item_12
on_value:
then:
- lambda: 'id(data_updated) = true;'
- platform: homeassistant
entity_id: '${ha_tasks_data}'
attribute: upcoming_date_13
id: upcoming_date_13
on_value:
then:
- lambda: 'id(data_updated) = true;'
- platform: homeassistant
entity_id: '${ha_tasks_data}'
attribute: upcoming_item_13
id: upcoming_item_13
on_value:
then:
- lambda: 'id(data_updated) = true;'
- platform: homeassistant
entity_id: '${ha_tasks_data}'
attribute: upcoming_date_14
id: upcoming_date_14
on_value:
then:
- lambda: 'id(data_updated) = true;'
- platform: homeassistant
entity_id: '${ha_tasks_data}'
attribute: upcoming_item_14
id: upcoming_item_14
on_value:
then:
- lambda: 'id(data_updated) = true;'
- platform: homeassistant
entity_id: '${ha_tasks_data}'
attribute: upcoming_date_15
id: upcoming_date_15
on_value:
then:
- lambda: 'id(data_updated) = true;'
- platform: homeassistant
entity_id: '${ha_tasks_data}'
attribute: upcoming_item_15
id: upcoming_item_15
on_value:
then:
- lambda: 'id(data_updated) = true;'
- platform: homeassistant
entity_id: '${ha_tasks_data}'
attribute: upcoming_date_16
id: upcoming_date_16
on_value:
then:
- lambda: 'id(data_updated) = true;'
- platform: homeassistant
entity_id: '${ha_tasks_data}'
attribute: upcoming_item_16
id: upcoming_item_16
on_value:
then:
- lambda: 'id(data_updated) = true;'
- platform: homeassistant
entity_id: '${ha_tasks_data}'
attribute: upcoming_date_17
id: upcoming_date_17
on_value:
then:
- lambda: 'id(data_updated) = true;'
- platform: homeassistant
entity_id: '${ha_tasks_data}'
attribute: upcoming_item_17
id: upcoming_item_17
on_value:
then:
- lambda: 'id(data_updated) = true;'
- platform: homeassistant
entity_id: '${ha_tasks_data}'
attribute: upcoming_date_18
id: upcoming_date_18
on_value:
then:
- lambda: 'id(data_updated) = true;'
- platform: homeassistant
entity_id: '${ha_tasks_data}'
attribute: upcoming_item_18
id: upcoming_item_18
on_value:
then:
- lambda: 'id(data_updated) = true;'
# Now render everything on the ePaper screen.
display:
- platform: waveshare_epaper
id: eink_display
cs_pin:
number: $cs_pin
ignore_strapping_warning: true
dc_pin: $dc_pin
busy_pin:
number: $busy_pin
inverted: $busy_inverted
reset_pin: $reset_pin
reset_duration: $reset_duration
model: $model
update_interval: never
setup_priority: 1000
rotation: 90°
lambda: |-
// Left from Madelena's code... perhaps if you want a black or colored background first (useful for fast-refresh screens?) to fill the background.
// it.fill(color_bg);
// Alignment rectangles! (uncomment to use - useful when first mounting the eInk screen)
// it.rectangle(0, 0, 480, 800);
// it.rectangle(10, 10, 460, 780);
// it.rectangle(20, 20, 440, 760);
// it.rectangle(30, 30, 420, 740);
// it.rectangle(40, 40, 400, 720);
// it.rectangle(50, 50, 380, 700);
// it.rectangle(60, 60, 360, 680);
// it.rectangle(70, 70, 340, 660);
// it.rectangle(80, 80, 320, 640);
// Because this list will dynamically space, we should define the starting column and row and row spacing (in pixels)
// every time an item exists, spacing is added accordingly... center is hard-coded as 240 (assuming 480 width)
int col = 27;
int row = 68;
// make the spacing the font size + a bit more
int spacing_title = 64;
int spacing_today = 30;
int spacing_small_title = 36;
int spacing_upcoming_date = 22;
int spacing_upcoming_item = 28;
int lastrow = 715 - spacing_upcoming_item - spacing_upcoming_date;
int whiteout_row = 0; // this is used to make the left and right sides evenly blank, so the text doesn't look like its running under the frame
// TODAY'S TASKS
it.printf(240, row, id(font_title), color_red, TextAlign::TOP_CENTER, "TO DO");
row = row + spacing_title;
whiteout_row = row;
// The following code is not elegant. I realize it would have been more efficient to have a loop run on arrays and use delimiters.
// But the possibility that the delimiter is actually in the task field was too great so I stuck with this one-by-one method
if (! (id(today_0).state.empty())) {
it.printf(col, row, id(font_today_list), color_blk, TextAlign::TOP_LEFT, "%s", id(today_0).state.c_str());
row = row + spacing_today;
} else {
it.printf(col, row, id(font_today_list), color_blk, TextAlign::TOP_LEFT, "%s", "Nothing today!");
row = row + spacing_today;
}
if (! (id(today_1).state.empty())) {
it.printf(col, row, id(font_today_list), color_blk, TextAlign::TOP_LEFT, "%s", id(today_1).state.c_str());
row = row + spacing_today;
}
if (! (id(today_2).state.empty())) {
it.printf(col, row, id(font_today_list), color_blk, TextAlign::TOP_LEFT, "%s", id(today_2).state.c_str());
row = row + spacing_today;
}
if (! (id(today_3).state.empty())) {
it.printf(col, row, id(font_today_list), color_blk, TextAlign::TOP_LEFT, "%s", id(today_3).state.c_str());
row = row + spacing_today;
}
if (! (id(today_4).state.empty())) {
it.printf(col, row, id(font_today_list), color_blk, TextAlign::TOP_LEFT, "%s", id(today_4).state.c_str());
row = row + spacing_today;
}
if (! (id(today_5).state.empty())) {
it.printf(col, row, id(font_today_list), color_blk, TextAlign::TOP_LEFT, "%s", id(today_5).state.c_str());
row = row + spacing_today;
}
if (! (id(today_6).state.empty())) {
it.printf(col, row, id(font_today_list), color_blk, TextAlign::TOP_LEFT, "%s", id(today_6).state.c_str());
row = row + spacing_today;
}
if (! (id(today_7).state.empty())) {
it.printf(col, row, id(font_today_list), color_blk, TextAlign::TOP_LEFT, "%s", id(today_7).state.c_str());
row = row + spacing_today;
}
if (! (id(today_8).state.empty())) {
it.printf(col, row, id(font_today_list), color_blk, TextAlign::TOP_LEFT, "%s", id(today_8).state.c_str());
row = row + spacing_today;
}
if (! (id(today_9).state.empty())) {
it.printf(col, row, id(font_today_list), color_blk, TextAlign::TOP_LEFT, "%s", id(today_9).state.c_str());
row = row + spacing_today;
}
it.filled_rectangle((it.get_width()-col), whiteout_row, (it.get_width()-col), row, COLOR_OFF);
// UPCOMING TASKS
row = row - spacing_today + (spacing_small_title);
it.printf(240, row, id(font_small_title), color_red, TextAlign::TOP_CENTER, "UPCOMING");
row = row + spacing_small_title;
whiteout_row = row;
if ((row <= lastrow) && (! (id(upcoming_item_0).state.empty()))) {
it.printf(col, row, id(font_upcoming_date), color_blk, TextAlign::TOP_LEFT, "%s", (id(upcoming_date_0).state + ":").c_str());
row = row + spacing_upcoming_date;
it.printf(col, row, id(font_upcoming_item), color_blk, TextAlign::TOP_LEFT, "%s", (" " + id(upcoming_item_0).state).c_str());
row = row + spacing_upcoming_item;
}
if ((row <= lastrow) && (! (id(upcoming_item_1).state.empty()))) {
if (id(upcoming_date_1).state.compare(id(upcoming_date_0).state) != 0) {
it.printf(col, row, id(font_upcoming_date), color_blk, TextAlign::TOP_LEFT, "%s", (id(upcoming_date_1).state + ":").c_str());
row = row + spacing_upcoming_date;
}
it.printf(col, row, id(font_upcoming_item), color_blk, TextAlign::TOP_LEFT, "%s", (" " + id(upcoming_item_1).state).c_str());
row = row + spacing_upcoming_item;
}
if ((row <= lastrow) && (! (id(upcoming_item_2).state.empty()))) {
if (id(upcoming_date_2).state.compare(id(upcoming_date_1).state) != 0) {
it.printf(col, row, id(font_upcoming_date), color_blk, TextAlign::TOP_LEFT, "%s", (id(upcoming_date_2).state + ":").c_str());
row = row + spacing_upcoming_date;
}
it.printf(col, row, id(font_upcoming_item), color_blk, TextAlign::TOP_LEFT, "%s", (" " + id(upcoming_item_2).state).c_str());
row = row + spacing_upcoming_item;
}
if ((row <= lastrow) && (! (id(upcoming_item_3).state.empty()))) {
if (id(upcoming_date_3).state.compare(id(upcoming_date_2).state) != 0) {
it.printf(col, row, id(font_upcoming_date), color_blk, TextAlign::TOP_LEFT, "%s", (id(upcoming_date_3).state + ":").c_str());
row = row + spacing_upcoming_date;
}
it.printf(col, row, id(font_upcoming_item), color_blk, TextAlign::TOP_LEFT, "%s", (" " + id(upcoming_item_3).state).c_str());
row = row + spacing_upcoming_item;
}
if ((row <= lastrow) && (! (id(upcoming_item_4).state.empty()))) {
if (id(upcoming_date_4).state.compare(id(upcoming_date_3).state) != 0) {
it.printf(col, row, id(font_upcoming_date), color_blk, TextAlign::TOP_LEFT, "%s", (id(upcoming_date_4).state + ":").c_str());
row = row + spacing_upcoming_date;
}
it.printf(col, row, id(font_upcoming_item), color_blk, TextAlign::TOP_LEFT, "%s", (" " + id(upcoming_item_4).state).c_str());
row = row + spacing_upcoming_item;
}
if ((row <= lastrow) && (! (id(upcoming_item_5).state.empty()))) {
if (id(upcoming_date_5).state.compare(id(upcoming_date_4).state) != 0) {
it.printf(col, row, id(font_upcoming_date), color_blk, TextAlign::TOP_LEFT, "%s", (id(upcoming_date_5).state + ":").c_str());
row = row + spacing_upcoming_date;
}
it.printf(col, row, id(font_upcoming_item), color_blk, TextAlign::TOP_LEFT, "%s", (" " + id(upcoming_item_5).state).c_str());
row = row + spacing_upcoming_item;
}
if ((row <= lastrow) && (! (id(upcoming_item_6).state.empty()))) {
if (id(upcoming_date_6).state.compare(id(upcoming_date_5).state) != 0) {
it.printf(col, row, id(font_upcoming_date), color_blk, TextAlign::TOP_LEFT, "%s", (id(upcoming_date_6).state + ":").c_str());
row = row + spacing_upcoming_date;
}
it.printf(col, row, id(font_upcoming_item), color_blk, TextAlign::TOP_LEFT, "%s", (" " + id(upcoming_item_6).state).c_str());
row = row + spacing_upcoming_item;
}
if ((row <= lastrow) && (! (id(upcoming_item_7).state.empty()))) {
if (id(upcoming_date_7).state.compare(id(upcoming_date_6).state) != 0) {
it.printf(col, row, id(font_upcoming_date), color_blk, TextAlign::TOP_LEFT, "%s", (id(upcoming_date_7).state + ":").c_str());
row = row + spacing_upcoming_date;
}
it.printf(col, row, id(font_upcoming_item), color_blk, TextAlign::TOP_LEFT, "%s", (" " + id(upcoming_item_7).state).c_str());
row = row + spacing_upcoming_item;
}
if ((row <= lastrow) && (! (id(upcoming_item_8).state.empty()))) {
if (id(upcoming_date_8).state.compare(id(upcoming_date_7).state) != 0) {
it.printf(col, row, id(font_upcoming_date), color_blk, TextAlign::TOP_LEFT, "%s", (id(upcoming_date_8).state + ":").c_str());
row = row + spacing_upcoming_date;
}
it.printf(col, row, id(font_upcoming_item), color_blk, TextAlign::TOP_LEFT, "%s", (" " + id(upcoming_item_8).state).c_str());
row = row + spacing_upcoming_item;
}
if ((row <= lastrow) && (! (id(upcoming_item_9).state.empty()))) {
if (id(upcoming_date_9).state.compare(id(upcoming_date_8).state) != 0) {
it.printf(col, row, id(font_upcoming_date), color_blk, TextAlign::TOP_LEFT, "%s", (id(upcoming_date_9).state + ":").c_str());
row = row + spacing_upcoming_date;
}
it.printf(col, row, id(font_upcoming_item), color_blk, TextAlign::TOP_LEFT, "%s", (" " + id(upcoming_item_9).state).c_str());
row = row + spacing_upcoming_item;
}
if ((row <= lastrow) && (! (id(upcoming_item_10).state.empty()))) {
if (id(upcoming_date_10).state.compare(id(upcoming_date_9).state) != 0) {
it.printf(col, row, id(font_upcoming_date), color_blk, TextAlign::TOP_LEFT, "%s", (id(upcoming_date_10).state + ":").c_str());
row = row + spacing_upcoming_date;
}
it.printf(col, row, id(font_upcoming_item), color_blk, TextAlign::TOP_LEFT, "%s", (" " + id(upcoming_item_10).state).c_str());
row = row + spacing_upcoming_item;
}
if ((row <= lastrow) && (! (id(upcoming_item_11).state.empty()))) {
if (id(upcoming_date_11).state.compare(id(upcoming_date_10).state) != 0) {
it.printf(col, row, id(font_upcoming_date), color_blk, TextAlign::TOP_LEFT, "%s", (id(upcoming_date_11).state + ":").c_str());
row = row + spacing_upcoming_date;
}
it.printf(col, row, id(font_upcoming_item), color_blk, TextAlign::TOP_LEFT, "%s", (" " + id(upcoming_item_11).state).c_str());
row = row + spacing_upcoming_item;
}
if ((row <= lastrow) && (! (id(upcoming_item_12).state.empty()))) {
if (id(upcoming_date_12).state.compare(id(upcoming_date_11).state) != 0) {
it.printf(col, row, id(font_upcoming_date), color_blk, TextAlign::TOP_LEFT, "%s", (id(upcoming_date_12).state + ":").c_str());
row = row + spacing_upcoming_date;
}
it.printf(col, row, id(font_upcoming_item), color_blk, TextAlign::TOP_LEFT, "%s", (" " + id(upcoming_item_12).state).c_str());
row = row + spacing_upcoming_item;
}
if ((row <= lastrow) && (! (id(upcoming_item_13).state.empty()))) {
if (id(upcoming_date_13).state.compare(id(upcoming_date_12).state) != 0) {
it.printf(col, row, id(font_upcoming_date), color_blk, TextAlign::TOP_LEFT, "%s", (id(upcoming_date_13).state + ":").c_str());
row = row + spacing_upcoming_date;
}
it.printf(col, row, id(font_upcoming_item), color_blk, TextAlign::TOP_LEFT, "%s", (" " + id(upcoming_item_13).state).c_str());
row = row + spacing_upcoming_item;
}
if ((row <= lastrow) && (! (id(upcoming_item_14).state.empty()))) {
if (id(upcoming_date_14).state.compare(id(upcoming_date_13).state) != 0) {
it.printf(col, row, id(font_upcoming_date), color_blk, TextAlign::TOP_LEFT, "%s", (id(upcoming_date_14).state + ":").c_str());
row = row + spacing_upcoming_date;
}
it.printf(col, row, id(font_upcoming_item), color_blk, TextAlign::TOP_LEFT, "%s", (" " + id(upcoming_item_14).state).c_str());
row = row + spacing_upcoming_item;
}
if ((row <= lastrow) && (! (id(upcoming_item_15).state.empty()))) {
if (id(upcoming_date_15).state.compare(id(upcoming_date_14).state) != 0) {
it.printf(col, row, id(font_upcoming_date), color_blk, TextAlign::TOP_LEFT, "%s", (id(upcoming_date_15).state + ":").c_str());
row = row + spacing_upcoming_date;
}
it.printf(col, row, id(font_upcoming_item), color_blk, TextAlign::TOP_LEFT, "%s", (" " + id(upcoming_item_15).state).c_str());
row = row + spacing_upcoming_item;
}
if ((row <= lastrow) && (! (id(upcoming_item_16).state.empty()))) {
if (id(upcoming_date_16).state.compare(id(upcoming_date_15).state) != 0) {
it.printf(col, row, id(font_upcoming_date), color_blk, TextAlign::TOP_LEFT, "%s", (id(upcoming_date_16).state + ":").c_str());
row = row + spacing_upcoming_date;
}
it.printf(col, row, id(font_upcoming_item), color_blk, TextAlign::TOP_LEFT, "%s", (" " + id(upcoming_item_16).state).c_str());
row = row + spacing_upcoming_item;
}
if ((row <= lastrow) && (! (id(upcoming_item_17).state.empty()))) {
if (id(upcoming_date_17).state.compare(id(upcoming_date_16).state) != 0) {
it.printf(col, row, id(font_upcoming_date), color_blk, TextAlign::TOP_LEFT, "%s", (id(upcoming_date_17).state + ":").c_str());
row = row + spacing_upcoming_date;
}
it.printf(col, row, id(font_upcoming_item), color_blk, TextAlign::TOP_LEFT, "%s", (" " + id(upcoming_item_17).state).c_str());
row = row + spacing_upcoming_item;