-
Notifications
You must be signed in to change notification settings - Fork 3
/
EHLPClock.yaml
955 lines (926 loc) · 31.4 KB
/
EHLPClock.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
# My github: https://github.com/trip5
substitutions:
name: led-pixelclock
friendly_name: Led-PixelClock
comment: "EHLPClock from Trip5"
project_version: "2024.11.11"
project_name: Trip5.EspHomeLedPixelClock
waiting: " . EHLPClock . ." # shows when waiting for time
# Time zone can be Olsen type ("Asia/Seoul") # Check https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
# or POSIX format: (ie "KST-9" & "PST8PDT,M3.2.0/2:00:00,M11.1.0/2:00:00" & "AST4ADT,M3.2.0,M11.1.0")
# Most can be viewed here: https://github.com/nayarsystems/posix_tz_db/blob/master/zones.csv
# or here: https://support.cyberdata.net/portal/en/kb/articles/010d63c0cfce3676151e1f2d5442e311
# If you need to make a custom POSIX format you can look here: https://developer.ibm.com/articles/au-aix-posix/)
# or even better, use this POSIX Generator (courtesy of TopYuan): https://www.topyuan.top/posix
time_zone: "AST4ADT,M3.2.0,M11.1.0"
# time and date formats: https://esphome.io/components/time/?highlight=strftime#strftime and https://strftime.org/
# time_format: "%H:%M" (13:25) / "%H:%M:%S" (13:25:59) / "%I:%M%p" (01:25PM) / "%l:%M%p" (1:25PM)
time_format12: "%l:%M%p"
time_format24: "%H:%M:%S"
# date_format: "%m.%d" (02.28) / "%y.%m.%d" (23.02.28) / "%b %d" (Feb 08) / "%a %d" (Tue 08)
date_format: "%b %d" # Jan 01
# date_formatA, if turned on, will split the time of the date display with the main date (and occur before):
date_formatA: "%a" # Mon
# Special note that ESPHome can't seem to use any locale for time other than English. In the text_sensors section, you can find filters that allow substitutions.
# Please be sure to add those needed characters to the glyphs as well, or those special characters will not be displayed!
# Pins for Display
clk_pin: GPIO14
mosi_pin: GPIO13
cs_pin: GPIO15
# Pins for I2C RTC
scl_pin: GPIO4
sda_pin: GPIO5
# Other Pins
status_led_pin: GPIO2
download_button_pin: GPIO0
rotation_pin: GPIO16
# Hard-coded variables (removed from UI because of memory constraints)
wifi_stop_seek_time: "180" # How many seconds to give up trying to connect to Wifi: 60 to 315 (do not go outside these numbers)
time_sync_interval: "8" # How often to sync the RTC: 1 to 24 (hours)
display_off_time: "0" # How many minutes until the display turns off (while connected) (0 = disable, do not go above 255)
display_off_no_wifi_time: "0" # How many seconds until the display turns off (while disconnected) (0 = disable, do not go above 255)
esphome:
name: ${name}
comment: "${comment}"
project:
name: "${project_name}"
version: "${project_version}"
min_version: 2023.11.0
on_boot:
- priority: 600
then:
- ds1307.read_time:
- globals.set:
id: sync_time
value: !lambda 'return ${time_sync_interval};'
- globals.set:
id: wifi_stop_seek_time
value: !lambda 'return (${wifi_stop_seek_time} - 60);'
- globals.set:
id: display_off_time
value: !lambda 'return (${display_off_time});'
- globals.set:
id: display_off_no_wifi_time
value: !lambda 'return (${display_off_no_wifi_time});'
- priority: -100
then:
- wait_until:
condition:
- lambda: 'return (id(my_time).now().is_valid());'
- ds1307.write_time:
esp8266:
board: esp12e
restore_from_flash: True
wifi:
ssid: !secret wifi_ssid_DNB
password: !secret wifi_password
reboot_timeout: 0s # reboot if no wifi (must be disabled for wifi to be turned off)
enable_on_boot: True
id: wifi_id
ap:
ssid: ${name}
password: !secret ap_password
ap_timeout: 10s # this has to be short, especially if using Stop Seek Wifi
on_connect:
- logger.log: "Wifi connected"
- light.turn_off: led1
- delay: 1s
- button.press: display_ip
- lambda: |-
id(wifi_stop_seek_time_count) = 0;
id(my_time)->update();
on_disconnect:
- if:
condition:
- lambda: 'return (id(wifi_stop_seek) == true);'
then:
- logger.log: "Wifi disconnected - will be disabled soon (stop seek is on)..."
else:
- logger.log: "Wifi disconnected"
- delay: 1s
- button.press: display_ip
font:
# Get the fonts from https://github.com/trip5/MatrixClockFonts (but you can use others too!)
# 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? Click here and edit the s = string to your needs: https://www.onlinegdb.com/fork/zh1VszNT1
# It's the Java code from here: https://www.geeksforgeeks.org/cpp-program-to-remove-duplicates-from-a-given-string/
# ...to here (OnlineGDB's Java handles Unicode a bit better than the C++ compiler): https://www.onlinegdb.com/online_java_compiler
- file: fonts/MatrixChunky8X.ttf
id: default_font
size: 8
glyphs: |
0123456789:.Sun MoTesWdhFriatAPJbpylgOcNvD오후전일월화수목금토요
# Above covers Sun Mon Tues Wed Thu Fri Sat AM PM Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec as well as Korean Dates
- file: fonts/MatrixLight8X.ttf
id: message_font
size: 8
glyphs: |
%0123456789 EHLPClock.DatenfWiONI:SpTAr
# Above should cover the system messages: "EHLPClock . / Wifi Off / No Wifi / IP: / Date on / Date off / StopSeek / Seek... / OTA % / Done / Error"
time:
- platform: sntp # use SNTP as a time source
id: my_time
timezone: "${time_zone}"
update_interval: 24h # This seems like the longest safe amount of time - actual configured update happens in interval section
- platform: ds1307 # even though it's a ds3231
id: my_time_ds
update_interval: never
timezone: "${time_zone}"
script:
- id: sync_the_time
mode: restart
then:
- lambda: 'id(my_time)->update();'
- ds1307.write_time:
- id: display_off_activate
mode: restart
then:
- lambda: |-
id(display_off) = true;
- id: display_off_deactivate
mode: restart
then:
- lambda: |-
id(display_off_time_count) = 0;
id(display_off) = false;
api:
reboot_timeout: 0s # Must be disabled to allow the Wifi enable/disable to function
mdns:
disabled: false # needs to be on to connect to HA
# Enable logging (and stops the various sensors/switches from spamming the log)
# Note that increasing the level uses up memory (which this device has very little available) and may cause errors and/or crashing
logger:
level: DEBUG
logs:
sensor: ERROR
text_sensor: NONE
switch: NONE
light: NONE
number: NONE
rtttl: NONE
ota:
- platform: esphome
password: !secret ota_password
on_begin:
then:
- lambda: |-
id(matrix)->clear();
id(matrix)->print(0, 0, id(message_font), "OTA...");
id(matrix)->loop();
- logger.log: "OTA Update started."
on_progress:
then:
- lambda: |-
if (x > 9) {
id(matrix)->clear();
id(matrix)->printf(0, 0, id(message_font), "OTA %d%%", (int)x);
id(matrix)->loop();
}
- logger.log:
format: "OTA progress %0.1f%%"
args: ["x"]
on_end:
then:
- lambda: |-
id(matrix)->clear();
id(matrix)->print(0, 0, id(message_font), "OTA Done");
id(matrix)->loop();
- logger.log: "OTA end"
on_error:
then:
- lambda: |-
id(matrix)->clear();
id(matrix)->print(0, 0, id(message_font), "Error!");
id(matrix)->loop();
- logger.log:
format: "OTA update error %d"
args: ["x"]
web_server:
port: 80
ota: true
# include_internal: true # probably not necessary, as it will expose more than needed to the Web UI
version: 2
local: true # will download www.js and serve it directly from the clock
captive_portal:
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 to_string("${project_version}");'
entity_category: diagnostic
update_interval: 1h
- platform: template
name: "${friendly_name} Time Zone"
lambda: 'return {"${time_zone}"};'
entity_category: diagnostic
update_interval: 1h
# Below this point are text sensors to hold time and date and allow for substitutions... you can delete/edit the filters, just don't delete the entire text sensor
# The github repo should also contain methods to change the time into other localized formats.
- platform: template
id: time_text
name: "${friendly_name} Replacement Time Text"
entity_category: diagnostic
update_interval: never
internal: true
filters:
- lambda: |-
// Korean generally puts the 오후/오전 before the time, so let's just use a different format entirely "%p%l%M" (PM1:25) and run a substitute on it
if (id(hour12_mode) == 1) {
int offset = 0;
if (id(tzoffset_on) != 0) {
offset = (int)(60 * 60 * (id(tzoffset)));
}
std::time_t tz1time = (id(my_time).now().timestamp + offset);
std::tm *tz1time_astm = localtime(&tz1time);
char display_tmdt[20];
strftime(display_tmdt, 20, "%p%l:%M", tz1time_astm);
std::string tmdt(display_tmdt);
return tmdt;
} else {
return x;
}
- append: ""
- prepend: ""
- substitute:
- "AM -> 오전"
- "PM -> 오후"
- platform: template
id: date_text
name: "${friendly_name} Replacement Date Text"
entity_category: diagnostic
update_interval: never
internal: true
filters:
- append: "일"
- prepend: ""
- substitute:
- "Jan -> 1월"
- "Feb -> 2월"
- "Mar -> 3월"
- "Apr -> 4월"
- "May -> 5월"
- "Jun -> 6월"
- "Jul -> 7월"
- "Aug -> 8월"
- "Sep -> 9월"
- "Oct -> 10월"
- "Nov -> 11월"
- "Dec -> 12월"
- platform: template
id: dateA_text
name: "${friendly_name} Replacement Date A Text"
entity_category: diagnostic
update_interval: never
internal: true
filters:
- append: ""
- prepend: ""
- substitute:
- "Sun -> 일요일"
- "Mon -> 월요일"
- "Tue -> 화요일"
- "Wed -> 수요일"
- "Thu -> 목요일"
- "Fri -> 금요일"
- "Sat -> 토요일"
output:
- platform: esp8266_pwm
id: statusled
pin:
number: ${status_led_pin}
inverted: true
light:
- platform: monochromatic
id: led1
name: "${friendly_name} Status LED"
output: statusled
internal: true
preferences:
flash_write_interval: 15s # 0 does immediate write to memory with no mem buffer (not recommended) (only saves when persistent variables have changed)
i2c:
sda: ${sda_pin}
scl: ${scl_pin}
scan: true
id: i2cbus
spi:
clk_pin: ${clk_pin}
mosi_pin: ${mosi_pin}
# Some info how to handle multi_click options: https://community.home-assistant.io/t/esphome-button-held-double-press/136083/10
binary_sensor:
- platform: status
name: "${friendly_name} Status"
- platform: gpio
pin:
number: ${download_button_pin}
inverted: true
name: "${friendly_name} Download Button"
filters:
- delayed_on: 10ms
- delayed_off: 10ms
on_multi_click:
#Click will toggle Date display mode (or turn screen on again)
- timing:
- ON for at most 0.5s
- OFF for at least 0.5s
then:
if:
condition:
- lambda: 'return id(display_off);'
then:
- script.execute: display_off_deactivate
else:
- switch.toggle: date_mode_select
#Double-Click will toggle 12-hour mode (or turn screen on again)
- timing:
- ON for at most 1s
- OFF for at most 0.5s
- ON for at most 1s
- OFF for at least 0.1s
then:
if:
condition:
- lambda: 'return id(display_off);'
then:
- script.execute: display_off_deactivate
else:
- switch.toggle: hour12_select
#Click once, then Hold will toggle TZ Offset (or turn screen on again)
- timing:
- ON for at most 1s
- OFF for at most 0.5s
- ON for at least 1s
then:
if:
condition:
- lambda: 'return id(display_off);'
then:
- script.execute: display_off_deactivate
else:
- switch.toggle: tzoffset_on_select
#Hold 2s will show the IP (or other wifi status) (or turn screen on again)
- timing:
- ON for at least 2s
- OFF for at least 0.5s
then:
if:
condition:
- lambda: 'return id(display_off);'
then:
- script.execute: display_off_deactivate
else:
- button.press: display_ip
#Hold 5s will toggle the wifi timeout (or turn screen on again)
- timing:
- ON for at least 5s
then:
if:
condition:
- lambda: 'return id(display_off);'
then:
- script.execute: display_off_deactivate
else:
- switch.toggle: wifi_stop_seek_select
- platform: gpio
pin:
number: ${rotation_pin}
inverted: true
name: "${friendly_name} Rotation Mode"
id: rotation_mode
on_state:
then:
if:
condition:
- lambda: 'return id(display_off);'
then:
- script.execute: display_off_deactivate
display:
- platform: max7219digit
id: matrix
cs_pin: ${cs_pin}
num_chips: 4
update_interval: 1s
reverse_enable: true # true for button-side up / false for down (be warned that if you change these 2 settings you may get a garbled display)
rotate_chip: 0 # 0 for button-side up (default) / 180 for down (you could switch them but then I would recommend go change the inverted settting for the gpio)
scroll_mode: continuous
lambda: |-
// Display the message if all conditions are met
if (id(my_time).now().is_valid() && !id(display_off)) {
if ((id(message_alive_time) != 0) && (id(message_clock_time_count) >= id(message_clock_time))) {
ESP_LOGD("main", "Showing Message");
id(message_display_time_count) += 1;
id(message_alive_time_count) += 1;
std::string message_text = id(message);
it.print(0, 0, id(message_font), message_text.c_str());
if (id(message_display_time_count) >= id(message_display_time)) {
id(message_display_time_count) = 0;
id(message_clock_time_count) = 0;
if (id(message_alive_time_count) >= id(message_alive_time)) {
id(message_alive_time_count) = 0;
id(message_alive_time) = 0;
ESP_LOGD("main", "Message Alive Time finished.");
}
}
} else {
if ((id(message_alive_time) != 0) && (id(message_clock_time) != 0)) {
id(message_clock_time_count) += 1;
id(message_alive_time_count) += 1;
}
// apply offset if needed https://community.home-assistant.io/t/multiple-time-zones/435315/12
int offset = 0;
if (id(tzoffset_on) != false) {
offset = (int)(60 * 60 * (id(tzoffset)));
}
std::time_t tz1time = (id(my_time).now().timestamp + offset);
std::tm *tz1time_astm = localtime(&tz1time);
char display_tmdt[20];
// check if the date should be displayed
if ((id(time_display_count) >= (id(time_display_time))) && (id(date_display_mode) != false)) {
id(date_display_count) += 1;
// if date_formatA is on, display it for 50% of the time first, after the 1st...
if ((id(date_A_mode) == true) && (id(date_display_count) <= (id(date_display_time) / 2))) {
strftime(display_tmdt, 20, "${date_formatA}", tz1time_astm);
// check if Date A text replacement should be made
if (id(replace_mode_auto) == true) {
std::string tmdt(display_tmdt);
id(dateA_text).publish_state(tmdt);
strcpy(display_tmdt, id(dateA_text).state.c_str());
}
} else {
strftime(display_tmdt, 20, "${date_format}", tz1time_astm);
// check if Date text replacement should be made
if (id(replace_mode_auto) == true) {
std::string tmdt(display_tmdt);
id(date_text).publish_state(tmdt);
strcpy(display_tmdt, id(date_text).state.c_str());
}
}
} else {
id(date_display_count) = 0;
id(time_display_count) += 1;
// choose which time format to display
if (id(hour12_mode) == true) {
strftime(display_tmdt, 20, "${time_format12}", tz1time_astm);
} else {
strftime(display_tmdt, 20, "${time_format24}", tz1time_astm);
}
// check if Time text replacement should be made
if (id(replace_mode_auto) == true) {
std::string tmdt(display_tmdt);
id(time_text).publish_state(tmdt);
strcpy(display_tmdt, id(time_text).state.c_str());
}
}
// print the date / time
it.printf((32 / 2), (8 / 2), id(default_font), TextAlign::CENTER, "%s", display_tmdt);
if (((id(date_display_count) >= id(date_display_time)) && (id(date_display_mode) != false)) || ((id(time_display_count) >= id(time_display_time)) && (id(date_display_mode) == false))) {
id(time_display_count) = 0;
// check if Replace Interval is active, count or reset, when date display is finished - or after the interval, depending
if (id(replace_interval) > 0) {
id(replace_interval_count) += 1;
if (id(replace_interval_count) >= id(replace_interval)) {
id(replace_interval_count) = 0;
id(replace_mode_auto) = (! id(replace_mode_auto));
}
}
}
}
} else {
if (!id(display_off)) {
it.print(0, 0, id(message_font), "${waiting}");
}
}
// This next bit handles the display_off stuff
if (id(display_off)) {
it.clear();
} else {
it.intensity(id(brightness_level));
}
// This next section allows the rotation sensor to work - need to directly change settings in the component: https://esphome.io/api/max7219_8h
if (id(rotation_mode).state == true) {
it.set_reverse(0);
it.set_chip_orientation(2);
} else {
it.set_reverse(1);
it.set_chip_orientation(0);
}
interval:
- interval: 1min # check if the time should be synced, and if so, do it
then:
- lambda: |-
id(sync_time_count) += 1;
if (id(sync_time_count) >= (id(sync_time) * 60)) {
id(sync_time_count) = 0;
id(sync_the_time).execute();
}
- interval: 1s # check if the wifi should be turned off, and if so, do it (or turn on if stop seek has been disabled) and blink led while seeking wifi, and check if display off should be activated
then:
- lambda: |-
if (id(wifi_stop_seek) == true && !id(wifi_id).is_connected() && !id(wifi_id).is_disabled()){
id(wifi_stop_seek_time_count) += 1;
if (id(wifi_stop_seek_time_count) >= id(wifi_stop_seek_time) + 60) {
id(wifi_stop_seek_time_count) = 0;
id(wifi_id)->disable();
id(display_ip).press();
}
}
if (id(wifi_stop_seek) == false && id(wifi_id).is_disabled()) {
id(wifi_stop_seek_time_count) = 0;
id(wifi_id)->enable();
id(display_ip).press();
}
if (!id(wifi_id).is_connected() && !id(wifi_id).is_disabled()) {
id(seek_blink_led) += 1;
if (id(wifi_stop_seek) == false) {
if (id(seek_blink_led) % 1 == 0) {
auto call = id(led1).toggle();
call.perform();
}
} else {
if (id(seek_blink_led) % 2 == 0) {
auto call = id(led1).toggle();
call.perform();
}
}
}
if (id(led1).current_values.is_on() && (id(wifi_id).is_connected() || id(wifi_id).is_disabled())) {
auto call = id(led1).turn_off();
call.perform();
}
if (id(my_time).now().is_valid() && !id(display_off)) {
if (id(display_off_no_wifi_time) != 0 || id(display_off_time) != 0) {
id(display_off_time_count) = id(display_off_time_count) + 1;
}
if ((id(display_off_time) != 0 && id(display_off_time_count) >= (id(display_off_time) * 60)) || (id(display_off_no_wifi_time) != 0 && id(display_off_time_count) >= id(display_off_no_wifi_time) && (!id(wifi_id).is_connected() || id(wifi_id).is_disabled()))) {
id(display_off_activate).execute();
}
}
globals:
- id: brightness_level
type: uint8_t
restore_value: true
initial_value: '1'
- id: hour12_mode
type: bool
restore_value: true
initial_value: 'false'
- id: date_A_mode
type: bool
restore_value: true
initial_value: 'false'
- id: replace_mode
type: bool
restore_value: true
initial_value: 'false'
- id: replace_mode_auto
type: bool
restore_value: false
initial_value: 'false'
- id: replace_interval
type: uint8_t
restore_value: true
initial_value: '0'
- id: replace_interval_count
type: uint8_t
restore_value: false
initial_value: '0'
- id: message
type: std::string
restore_value: false
initial_value: ''
- id: message_display_time
type: uint8_t
restore_value: false
initial_value: '0'
- id: message_clock_time
type: uint8_t
restore_value: false
initial_value: '0'
- id: message_alive_time
type: uint8_t
restore_value: false
initial_value: '0'
- id: message_display_time_count
type: uint8_t
restore_value: false
initial_value: '0'
- id: message_clock_time_count
type: uint8_t
restore_value: false
initial_value: '0'
- id: message_alive_time_count
type: uint8_t
restore_value: false
initial_value: '0'
- id: date_display_mode
type: bool
restore_value: true
initial_value: 'false'
- id: time_display_time
type: uint8_t
restore_value: true
initial_value: '11'
- id: date_display_time
type: uint8_t
restore_value: true
initial_value: '4'
- id: time_display_count
type: uint8_t
restore_value: false
initial_value: '0'
- id: date_display_count
type: uint8_t
restore_value: false
initial_value: '0'
- id: sync_time
type: uint8_t
restore_value: false
initial_value: '8'
- id: sync_time_count
type: uint8_t
restore_value: false
initial_value: '0'
# TZ Offset Variables
- id: tzoffset
type: int8_t
restore_value: true
initial_value: '0'
- id: tzoffset_on
type: bool
restore_value: true
initial_value: 'false'
# Wifi Stop Seek Variables
- id: wifi_stop_seek
type: bool
restore_value: true
initial_value: 'false'
- id: wifi_stop_seek_time
type: uint8_t
restore_value: false
initial_value: '120'
- id: wifi_stop_seek_time_count
type: uint8_t
restore_value: false
initial_value: '0'
- id: seek_blink_led
type: uint8_t
restore_value: false
initial_value: '0'
# Display Off Variables
- id: display_off
type: bool
restore_value: false
initial_value: 'false'
- id: display_off_time
type: uint8_t
restore_value: true
initial_value: '0'
- id: display_off_time_count
type: uint16_t
restore_value: false
initial_value: '0'
- id: display_off_no_wifi_time
type: uint8_t
restore_value: true
initial_value: '0'
button:
- platform: restart
id: restart_button
name: "${friendly_name} Restart"
entity_category: diagnostic
- platform: template
id: display_ip
name: "Display IP Address"
internal: true
entity_category: diagnostic
on_press:
- if:
condition:
not:
wifi.connected:
then:
- lambda: |-
if (id(wifi_id).is_disabled()) {
id(message) = ("Wifi Off");
} else {
id(message) = ("No Wifi");
}
id(message_alive_time) = 3;
id(message_display_time) = 3;
id(message_clock_time) = 0;
else:
- lambda: |-
id(message) = (" IP : " + id(wifi_ip).state + " . . . . ");
id(message_alive_time) = 9;
id(message_display_time) = 9;
id(message_clock_time) = 0;
switch:
- platform: template
name: "${friendly_name} 12 Hour Mode"
id: hour12_select
restore_mode: RESTORE_DEFAULT_OFF
lambda: 'return id(hour12_mode);'
turn_on_action:
- lambda: |-
ESP_LOGD("main", "12 Hour Mode On");
id(hour12_mode) = true;
turn_off_action:
- lambda: |-
ESP_LOGD("main", "12 Hour Mode Off");
id(hour12_mode) = false;
- platform: template
name: "${friendly_name} Date A Mode"
id: date_A_select
restore_mode: RESTORE_DEFAULT_OFF
lambda: 'return id(date_A_mode);'
turn_on_action:
- lambda: |-
ESP_LOGD("main", "Date A Mode On");
id(date_A_mode) = true;
turn_off_action:
- lambda: |-
ESP_LOGD("main", "Date A Mode Off");
id(date_A_mode) = false;
- platform: template
name: "${friendly_name} Replacement Mode"
id: replace_mode_select
restore_mode: RESTORE_DEFAULT_OFF
lambda: 'return id(replace_mode);'
turn_on_action:
- lambda: |-
ESP_LOGD("main", "Replace Mode On");
id(replace_mode) = true;
id(replace_mode_auto_select).turn_on();
auto call = id(replace_interval_select).make_call();
call.set_value(0);
call.perform();
turn_off_action:
- lambda: |-
ESP_LOGD("main", "Replace Mode Off");
id(replace_mode) = false;
id(replace_mode_auto_select).turn_off();
- platform: template
id: replace_mode_auto_select
restore_mode: DISABLED
internal: true
turn_on_action:
- lambda: |-
ESP_LOGD("main", "Replace Mode Auto On");
id(replace_mode_auto) = true;
turn_off_action:
- lambda: |-
ESP_LOGD("main", "Replace Mode Auto Off");
id(replace_mode_auto) = false;
- platform: template
name: "${friendly_name} Time Zone Offset On"
id: tzoffset_on_select
restore_mode: RESTORE_DEFAULT_OFF
lambda: 'return id(tzoffset_on);'
turn_on_action:
- lambda: |-
ESP_LOGD("main", "TZ Offset On");
id(tzoffset_on) = true;
turn_off_action:
- lambda: |-
ESP_LOGD("main", "TZ Offset Off");
id(tzoffset_on) = false;
- platform: template
name: "${friendly_name} Date Display Mode"
id: date_mode_select
restore_mode: RESTORE_DEFAULT_OFF
lambda: 'return id(date_display_mode);'
turn_on_action:
- lambda: |-
ESP_LOGD("main", "Date on");
id(date_display_mode) = true;
id(message) = ("Date on");
id(message_alive_time) = 1;
id(message_display_time) = 1;
id(message_clock_time) = 0;
turn_off_action:
- lambda: |-
ESP_LOGD("main", "Date off");
id(date_display_mode) = false;
id(message) = ("Date off");
id(message_alive_time) = 1;
id(message_display_time) = 1;
id(message_clock_time) = 0;
- platform: template
name: "${friendly_name} Wifi Stop Seek"
id: wifi_stop_seek_select
restore_mode: RESTORE_DEFAULT_OFF
lambda: 'return id(wifi_stop_seek);'
turn_on_action:
- delay: 1s
- lambda: |-
ESP_LOGD("main", "Wifi Stop Seek on");
id(wifi_stop_seek) = true;
id(message) = ("StopSeek");
id(message_alive_time) = 1;
id(message_display_time) = 1;
id(message_clock_time) = 0;
turn_off_action:
- delay: 1s
- lambda: |-
ESP_LOGD("main", "Wifi Stop Seek off");
id(wifi_stop_seek) = false;
id(message) = ("Seek...");
id(message_alive_time) = 1;
id(message_display_time) = 1;
id(message_clock_time) = 0;
number:
- platform: template
name: "${friendly_name} Brightness"
id: brightness_select
restore_value: true
optimistic: true
step: 1
min_value: 0
max_value: 15
initial_value: 1
mode: slider
set_action:
then:
- lambda: |-
id(brightness_level) = x;
ESP_LOGD("main", "Brightness: %d", id(brightness_level));
- platform: template
name: "${friendly_name} Time Display Time"
id: time_display_time_select
restore_value: true
optimistic: true
step: 1
min_value: 1
max_value: 60
initial_value: 8
mode: box
unit_of_measurement: seconds
set_action:
then:
- lambda: |-
id(time_display_time) = x;
ESP_LOGD("main", "Time Display Time: %d seconds", id(time_display_time));
- platform: template
name: "${friendly_name} Date Display Time"
id: date_display_time_select
restore_value: true
optimistic: true
step: 1
min_value: 1
max_value: 60
initial_value: 2
mode: box
unit_of_measurement: seconds
set_action:
then:
- lambda: |-
id(date_display_time) = x;
ESP_LOGD("main", "Date Display Time: %d seconds", id(date_display_time));
- platform: template
name: "${friendly_name} Auto Replacement Interval"
id: replace_interval_select
restore_value: true
optimistic: true
step: 1
min_value: 0
max_value: 10
initial_value: 0
mode: box
unit_of_measurement: intervals
set_action:
then:
- lambda: |-
id(replace_interval) = x;
ESP_LOGD("main", "Auto Replacement Interval: %d", id(replace_interval));
if (id(replace_interval) > 0) {
if (id(replace_mode) == true) {
id(replace_mode_select).turn_off(); // was on
}
}
- platform: template
name: "${friendly_name} Time Zone Offset"
id: tzoffset_select
restore_value: true
optimistic: true
step: 0.25
min_value: -26
max_value: 26
initial_value: 0
mode: box
unit_of_measurement: hours
set_action:
then:
- lambda: |-
id(tzoffset) = x;
ESP_LOGD("main", "Time Zone Offset: %.2f hours", id(tzoffset));