-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathdisplay-28.yaml
1287 lines (1139 loc) · 42 KB
/
display-28.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
#Substitutions do un nome fisso a delle entita
substitutions:
#Set here your entities
devicename: "display-28"
ssid: Esp32-2432S028 Fallback Hotspot
static_ip: 192.168.0.119
gateway: 192.168.0.1
subnet: 255.255.255.0
#Set here your entities
# Heater entity from home assistant, in my case i used a Shelly 1v3 for open/close contact of my house gas heater.
#You can also use a relay connected to a gpio but I do not recommend it especially if the load is alternating current the absorption peaks could glue the contacts of the cheap relays.
#I also noticed that the electromagnetic peak sometimes crashes the esp32. Since we are talking about a delicated system like a gas heater, it is better to opt for a certified device.
heater: climate.cronotermostato
# Weather entity from home assistant
weather_entity: weather.casa
# Total consumption sensor to import from home assistant i have a Shelly em with 2 amperomeric sensor, this is the first and grab the phase exiting from my energy grid
tc: sensor.potenza_energia_elettrica_power
# Partial consumtion entity like washing machine etc to import from home assistant this is my second amperometric sensor and grab the phase of my garage
pc: sensor.consumo_lavastoviglie_power
#Weather now icon size
icon_xy: '65x65'
#temperatura purificatore config
temperatura_purificatore : sensor.zhimi_airpurifier_mb3_temperature
globals:
- id: menu_pos
restore_value: no
type: int
initial_value: "0"
#definisco coordinate icona pagina succesiva
- id: x_page
type: int
restore_value: no
initial_value: '300'
- id: y_page
type: int
restore_value: no
initial_value: '220'
# display 320x240
esphome:
name: $devicename
friendly_name: Display 2.8
esp32:
board: esp32dev
framework:
type: arduino
# Enable logging
logger:
# Enable Home Assistant API
api:
encryption:
key: "qFyyPu4U4WWJw9iV9+WlCO/aYmtA+DrovMJqmH2PHpg="
services:
# Receive sound from homeassistant as service (only buzzer rtttl)
- service: play_rtttl
variables:
song_str: string
then:
- rtttl.play:
rtttl: !lambda 'return song_str;'
#Buzzer
rtttl:
output: rtttl_out
ota:
password: "b3c2948c5c1aa9c51f9e7b8e6ff9556a"
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: $ssid
password: "TuMHWpSUedAq"
captive_portal:
#page successiva riferimenti definita come variabile globale
spi:
- id: lcd
clk_pin: GPIO14
mosi_pin: GPIO13
miso_pin: GPIO12
- id: touch
clk_pin: GPIO25
mosi_pin: GPIO32
miso_pin: GPIO39
i2c:
sda: GPIO27
scl: GPIO22
scan: true
id: bus_a
#This import arduinojson library for extract weather forecasts
json:
#Definisco imagini
#Weather now images
image:
#0-default.png
- file: "images/0-default.png"
id: wpng_0
type: RGB24
resize: ${icon_xy}
#1-clear-night.png
- file: "images/1-clear-night.png"
id: wpng_1
type: RGB24
resize: ${icon_xy}
#2-cloudy.png
- file: "images/2-cloudy.png"
id: wpng_2
type: RGB24
resize: ${icon_xy}
#3-fog.png
- file: "images/3-fog.png"
id: wpng_3
type: RGB24
resize: ${icon_xy}
#4-hail.png
- file: "images/4-hail.png"
id: wpng_4
type: RGB24
resize: ${icon_xy}
#5-lightning.png
- file: "images/5-lightning.png"
id: wpng_5
type: RGB24
resize: ${icon_xy}
#6-lightning-rainy.png
- file: "images/6-lightning-rainy.png"
id: wpng_6
type: RGB24
resize: ${icon_xy}
#7-partlycloudy.png
- file: "images/7-partlycloudy.png"
id: wpng_7
type: RGB24
resize: ${icon_xy}
#8-pouring.png // rgb565
- file: "images/8-pouring.png"
id: wpng_8
type: RGB24
resize: ${icon_xy}
#9-rainy.png
- file: "images/9-rainy.png"
id: wpng_9
type: RGB24
resize: ${icon_xy}
#10-snowy.png
- file: "images/10-snowy.png"
id: wpng_10
type: RGB24
resize: ${icon_xy}
#11-snowy-rainy.png
- file: "images/11-snowy-rainy.png"
id: wpng_11
type: RGB24
resize: ${icon_xy}
#12-sunny.png
- file: "images/12-sunny.png"
id: wpng_12
type: RGB24
resize: ${icon_xy}
#13-windy.png
- file: "images/13-windy.png"
id: wpng_13
type: RGB24
resize: ${icon_xy}
#14-windy-variant.png
- file: "images/14-windy-variant.png"
id: wpng_14
type: RGB24
resize: ${icon_xy}
#15-exceptional.png
- file: "images/15-exceptional.png"
id: wpng_15
type: RGB24
resize: ${icon_xy}
#16-radio e power
- file: "images/power-off-button.png"
id: on_off_button
- file: "images/radio-station.png"
id: radio
### CUSTOM!!
# menu spunto https://github.com/anton-semeniak/Esphome-TTGO-T-Display-Remote/blob/master/ttgo_menu.yaml
font:
- file: "fonts/Helvetica.ttf"
id: helvetica_48
size: 48
- file: "fonts/Helvetica.ttf"
id: helvetica_36
size: 36
- file: "fonts/Helvetica.ttf"
id: helvetica_24
size: 24
- file: "fonts/Helvetica.ttf"
id: helvetica_12
size: 12
- file: "fonts/arial.ttf"
id: font11
size: 12
- file: "fonts/materialdesignicons-webfont.ttf"
id: icon_font_20
size: 20
glyphs: [
"", # mdi-thermometer
"", # mdi-water-percent
"ﴟ", # mdi-air-filter
"", # mdi-lightbulb-outline
"", # mdi-lightbulb-on
]
#Font declaration
#font date
- file: 'fonts/arial-black.ttf'
id: font1
size: 16
#Time orologio dx
- file: 'fonts/BebasNeue-Regular.ttf'
id: font_clock
size: 30
#Temperature blu outside
- file: 'fonts/BebasNeue-Regular.ttf'
id: font2
size: 35
#Location sensors
- file: 'fonts/arial.ttf'
id: font8
size: 18
# Day name in forecast
- file: 'fonts/arial-black.ttf'
id: font_small
size: 12
#Forecast fonts
- file: 'fonts/arial.ttf'
id: font_small_1
size: 10
#Font icon various sensor
- file: 'fonts/materialdesignicons-webfont.ttf'
id: sensor_font
size: 18
glyphs:
- "\U000F059D" # Wind
- "\U000F050F" # Temperature
- "\U000F04C5" # Pression
- "\U000F058E" # Humidity
- "\U000F0238" # Fire
- "\U000F0F55" # Home thermometer
- "\U000F0BB1" # next page
#Big icons other home stuff
- file: 'fonts/materialdesignicons-webfont.ttf'
id: home_font
size: 52
glyphs:
- "\U000F02DC" # At home
- "\U000F0F9B" # Outside home
- "\U000F0238" # Fire
- "\U000F072A" # Washing machine on
- "\U000F11BD" # Washing machine off
- "\U000F0100" # Camera on
- "\U000F05DF" # Camera off
- "\U000F0241" # Flash
- "\U000F0EF7" # Flash alert
- "\U000F06D0" # Diocane
- "\U000F0425" # OFF
- "\U000F0415" # Plus
- "\U000F0374" # Minus
- "\U000F0335" # lightbulb pieno
- "\U000F0336" # lightbulb vuoto
#Forecast icons
- file: 'fonts/materialdesignicons-webfont.ttf'
id: weather_font
size: 50
glyphs:
- "\U000F0590" # weather-cloudy
- "\U000F0F2F" # weather-cloudy-alert
- "\U000F0E6E" # weather-cloudy-arrow-right
- "\U000F0591" # weather-fog
- "\U000F0592" # weather-hail
- "\U000F0F30" # weather-hazy
- "\U000F0898" # weather-hurricane
- "\U000F0593" # weather-lightning
- "\U000F067E" # weather-lightning-rainy
- "\U000F0594" # weather-night
- "\U000F0F31" # weather-night-partly-cloudy
- "\U000F0595" # weather-partly-cloudy
- "\U000F0F32" # weather-partly-lightning
- "\U000F0F33" # weather-partly-rainy
- "\U000F0F34" # weather-partly-snowy
- "\U000F0F35" # weather-partly-snowy-rainy
- "\U000F0596" # weather-pouring
- "\U000F0597" # weather-rainy
- "\U000F0598" # weather-snowy
- "\U000F0F36" # weather-snowy-heavy
- "\U000F067F" # weather-snowy-rainy
- "\U000F0599" # weather-sunny
- "\U000F0F37" # weather-sunny-alert
- "\U000F14E4" # weather-sunny-off
- "\U000F059A" # weather-sunset
- "\U000F059B" # weather-sunset-down
- "\U000F059C" # weather-sunset-up
- "\U000F0F38" # weather-tornado
- "\U000F059D" # weather-windy
- "\U000F059E" # weather-windy-variant
color:
- id: my_red
red: 100%
green: 0%
blue: 0%
- id: my_yellow
red: 100%
green: 100%
blue: 0%
- id: my_green
red: 0%
green: 100%
blue: 0%
- id: my_blue
red: 0%
green: 0%
blue: 100%
- id: my_gray
red: 50%
green: 50%
blue: 50%
- id: my_orange
red: 100%
green: 50%
blue: 0%
- id: my_teal
red: 0%
green: 100%
blue: 100%
- id: my_white
red: 100%
green: 100%
blue: 100%
#This create the climate entity
climate:
- platform: thermostat
visual:
min_temperature: 16 °C
max_temperature: 30 °C
name: Termostato
id: termostato1
sensor: temp_int
min_heating_off_time: 30s
min_heating_run_time: 30s
min_idle_time: 30s
#This is the service to call on off of the Shelly 1v3 actuator.
heat_action:
homeassistant.service:
service: switch.turn_on
data: {entity_id: $heater}
idle_action:
homeassistant.service:
service: switch.turn_off
data: {entity_id: $heater}
# Pulsanti touchSCREEN
binary_sensor:
- platform: status
name: "Node Status"
id: system_status
#Virtual touch buttons on display 320x240
#Touch key plus pagina avanti
- platform: touchscreen
id: touch_key_plus
x_min: 260
x_max: 320
y_min: 180
y_max: 240
on_press:
- display.page.show_next: schermo
#Touch key meno
- platform: touchscreen
id: touch_key_minus
x_min: 260
x_max: 320
y_min: 0
y_max: 60
on_press:
- display.page.show_previous: schermo
#Touch key climate on/off
- platform: touchscreen
id: touch_key_climate
x_min: 260
x_max: 320
y_min: 100
y_max: 160
# page_id: page1
on_click:
#Thermostat on
- min_length: 50ms
max_length: 500ms
then:
- climate.control:
id: termostato1
mode: "HEAT"
- rtttl.play: 'one short:d=4,o=5,b=100:16e6'
#Thermostat off
- min_length: 1000ms
max_length: 5000ms
then:
- climate.control:
id: termostato1
mode: "OFF"
- rtttl.play: 'one short:d=4,o=5,b=100:16e6'
#Touch key aumenta temperatura
- platform: touchscreen
id: touch_key_aumenta_temp
x_min: 160
x_max: 240
y_min: 180
y_max: 240
page_id: page3
on_press:
- climate.control:
id: termostato1
target_temperature: !lambda return (id(termostato1).target_temperature + 0.5);
- rtttl.play: 'one short:d=4,o=5,b=100:16e6'
#Touch key mdiminuisci temperatira
- platform: touchscreen
id: touch_key_diminuisce_temp
x_min: 160
x_max: 240
y_min: 0
y_max: 60
page_id: page3
on_press:
- climate.control:
id: termostato1
target_temperature: !lambda return (id(termostato1).target_temperature - 0.5);
- rtttl.play: 'one short:d=4,o=5,b=100:16e6'
time:
- platform: homeassistant
id: esptime
sensor:
- platform: uptime
# name: Uptime Sensor
internal: True
id: uptime_sensor
update_interval: 1s
on_raw_value:
then:
- text_sensor.template.publish:
id: uptime_human
state: !lambda |-
int seconds = round(id(uptime_sensor).raw_state);
int days = seconds / (24 * 3600);
seconds = seconds % (24 * 3600);
int hours = seconds / 3600;
seconds = seconds % 3600;
int minutes = seconds / 60;
seconds = seconds % 60;
return (
("Uptime ") +
(days ? to_string(days) + "d " : "") +
(hours ? to_string(hours) + "h " : "") +
(minutes ? to_string(minutes) + "m " : "") +
(to_string(seconds) + "s")
).c_str();
- platform: wifi_signal
# name: "WiFi Signal Sensor"
internal: True
id: wifi_signal_sensor
update_interval: 5s
#Import external temperature
- platform: homeassistant
id: weather_temperature
entity_id: $weather_entity
attribute: temperature
internal: true
#Import Wind speed
- platform: homeassistant
id: vento
entity_id: $weather_entity
attribute: wind_speed
internal: true
#Import Wind dir
- platform: homeassistant
id: wind_bearing
entity_id: $weather_entity
attribute: wind_bearing
internal: true
#Import external Humidity
- platform: homeassistant
id: umidita_ext
entity_id: $weather_entity
attribute: humidity
internal: true
#Import external pressure
- platform: homeassistant
id: pressure_ext
entity_id: $weather_entity
attribute: pressure
internal: true
#Total energy in kw/h
- platform: homeassistant
id: consumo_t
entity_id: $tc
internal: true
#Lavastoviglie energy in kw/h
- platform: homeassistant
id: consumo_c
entity_id: $pc
internal: true
#Bme280 internal sensor su co2 BOX prendo tramite hA
- platform: homeassistant
id: temp_int
entity_id: sensor.co2box_bmp280_temperature
internal: true
- platform: homeassistant
id: pressione_int
entity_id: sensor.co2box_bmp280_pressure
internal: true
- platform: homeassistant
id: co2_int
entity_id: sensor.co2box_mhz19b_carbondioxide
internal: true
#temperatura umidita purificatore
- platform: homeassistant
id: temperatura_pur
entity_id: $temperatura_purificatore
internal: true
- platform: homeassistant
id: umidita_int
entity_id: sensor.zhimi_airpurifier_mb3_humidity
internal: true
#This import heater entity from home assistant (it is a shelly 1v3 that open or close the heater contact)
- platform: homeassistant
name: "Caldaia"
entity_id: $heater
id: sensor_caldaia
internal: true
text_sensor:
- platform: template
# name: Uptime Human Readable
id: uptime_human
icon: mdi:clock-start
internal: True
- platform: wifi_info
ip_address:
# name: ESP IP Address
id: ip_address
# Sensore luci
- platform: homeassistant
id: luci
entity_id: group.all_light
name: "Luci Casa"
#Import Location
- platform: homeassistant
id: weather_location
entity_id: $weather_entity
attribute: friendly_name
internal: true
#Import weather condition now
- platform: homeassistant
id: weather_condition
entity_id: $weather_entity
internal: true
#Import 5 day forecast
- platform: homeassistant
id: forecast_5
entity_id: $weather_entity
attribute: forecast
internal: yes
#Import Sun state
- platform: homeassistant
id: sun_state
entity_id: sun.sun
internal: true
#imposto grafico pagina 4
graph:
# Show multi-trace graph
- id: multi_temperature_graph
duration: 1h
x_grid: 10min
y_grid: 1.0 # degC/div
width: 200
height: 80
max_value: 40
traces:
- sensor: temperatura_pur
line_type: DASHED
line_thickness: 2
color: my_red
- sensor: weather_temperature
line_type: SOLID
line_thickness: 3
color: my_blue
display:
- platform: ili9xxx
model: ILI9341
spi_id: lcd
cs_pin: 15
dc_pin: 2
rotation: 90
id: schermo
pages:
# https://github.com/niahane/meteo-thermostat
- id: page1 # pagina 1
lambda: |-
//Map icons//
std::map<std::string, image::Image *> imgDict;
imgDict["clear-night"] = id(wpng_1);
imgDict["cloudy"] = id(wpng_2);
imgDict["fog"] = id(wpng_3);
imgDict["hail"] = id(wpng_4);
imgDict["lightning"] = id(wpng_5);
imgDict["lightning-rainy"] = id(wpng_6);
imgDict["partlycloudy"] = id(wpng_7);
imgDict["pouring"] = id(wpng_8);
imgDict["rainy"] = id(wpng_9);
imgDict["snowy"] = id(wpng_10);
imgDict["snowy-rainy"] = id(wpng_11);
imgDict["sunny"] = id(wpng_12);
imgDict["windy"] = id(wpng_13);
imgDict["windy-variant"] = id(wpng_14);
imgDict["exceptional"] = id(wpng_15);
imgDict[""] = id(wpng_0);
//Map conditions//
std::map<std::string, const char *> conDict;
conDict["clear-night"] = "Notte serena";
conDict["cloudy"] = "Nuvoloso";
conDict["fog"] = "Nebbia";
conDict["hail"] = "Nevischio";
conDict["lightning"] = "Fulmini";
conDict["lightning-rainy"] = "Fulmini/pioggia";
conDict["partlycloudy"] = "Parz. Nuv.";
conDict["pouring"] = "Rovescio";
conDict["rainy"] = "Pioggia";
conDict["snowy"] = "Neve";
conDict["snowy-rainy"] = "Neve/pioggia";
conDict["sunny"] = "Sereno";
conDict["windy"] = "Vento";
conDict["windy-variant"] = "Vento forte";
conDict["exceptional"] = "Eccezionale";
conDict[""] = "Sconosciuto";
//Map weather fonts//
std::map<std::string, const char *> fonDict;
fonDict["clear-night"] = "\U000F0594";
fonDict["cloudy"] = "\U000F0590";
fonDict["fog"] = "\U000F0591";
fonDict["hail"] = "\U000F0592";
fonDict["lightning"] = "\U000F0593";
fonDict["lightning-rainy"] = "\U000F067E";
fonDict["partlycloudy"] = "\U000F0595";
fonDict["pouring"] = "\U000F0596";
fonDict["rainy"] = "\U000F0597";
fonDict["snowy"] = "\U000F0598";
fonDict["snowy-rainy"] = "\U000F067F";
fonDict["sunny"] = "\U000F0599";
fonDict["windy"] = "\U000F059D";
fonDict["windy-variant"] = "\U000F059E";
fonDict["exceptional"] = "";
//Map days of week//
std::map<int, const char *> dayDict;
dayDict[1] = "Dom";
dayDict[2] = "Lun";
dayDict[3] = "Mar";
dayDict[4] = "Mer";
dayDict[5] = "Gio";
dayDict[6] = "Ven";
dayDict[7] = "Sab";
//Map days of week extended//
std::map<int, const char *> dayDict_ext;
dayDict_ext[1] = "Domenica";
dayDict_ext[2] = "Lunedi";
dayDict_ext[3] = "Martedi";
dayDict_ext[4] = "Mercoledi";
dayDict_ext[5] = "Giovedi";
dayDict_ext[6] = "Venerdi";
dayDict_ext[7] = "Sabato";
//Map month//
std::map<int, const char *> monDict;
monDict[1] = "Gennaio";
monDict[2] = "Febbraio";
monDict[3] = "Marzo";
monDict[4] = "Aprile";
monDict[5] = "Maggio";
monDict[6] = "Giugno";
monDict[7] = "Luglio";
monDict[8] = "Agosto";
monDict[9] = "Settembre";
monDict[10] = "Ottobre";
monDict[11] = "Novembre";
monDict[12] = "Dicembre";
//Today weekday as number
int day = id(esptime).now().day_of_week;
//Month as number
auto month = id(esptime).now().month;
//Day of month as number
auto dom = id(esptime).now().day_of_month;
//Position Y 1 day of week, day of month, month
int h1 = 0;
//Position Y 2 time
int h2 = 5;
//Position Y 3 weather icons, location, home name
int h3 = 18;
//Position Y 4 temperature ext, int,
int h4 = 30;
//Position Y 6 humidity ext, int
int h6 = 50;
//Position Y 7 wind, Pressure int
int h7 = 65;
//Position Y wy forecast
int wy = 85;
//Position X wx forecast
int wx = 32;
//Position X 1 Weather location name, outside temp
int w1 = 70;
//Position Y 2 Outside sensor icon
int w2 = 115;
//Position X 3 Home name, home temperature
int w3 = 200;
//Position X 4 Home sensor icon
int w4 = 250;
//Begin print to screen
// Time
it.printf((it.get_width() / 2), h1, id(font1), id(my_gray), TextAlign::TOP_CENTER, "%s %i %s", dayDict[day], dom, monDict[month]);
it.strftime(it.get_width(), h2, id(font_clock), TextAlign::TOP_RIGHT, "%H:%M", id(esptime).now());
// Weather now if it's night and sunny for display night icon
if (id(sun_state).state == "below_horizon" && id(weather_condition).state == "sunny") {
// Icon of weather condition night
it.image(0, h3, imgDict["clear-night"]);
// Translated weather condition state as text
it.printf(0, h1, id(font_small), id(my_gray), "%s", conDict["clear-night"]);
} else {
// Check if weather_condition has a known state in the dictionary to prevent a crash
if (conDict.count(id(weather_condition).state) > 0) {
// Weather now for other cases
// Icon of weather condition now
it.image(0, h3, imgDict[id(weather_condition).state]);
// Translated weather condition state as text
it.printf(0, h1, id(font_small), id(my_gray), "%s", conDict[id(weather_condition).state]);
} else {
// This is printed in case weather_condition has another or unknown state
it.image(0, h3, imgDict["exceptional"]);
// Translated weather condition state as text
it.printf(0, h1, id(font_small), id(my_gray), "%s", conDict["exceptional"]);
}
}
// Outside temp
if (id(weather_temperature).has_state()) {
it.printf(w1, h4, id(font2), id(my_blue), "%.0f°", id(weather_temperature).state);
}
// Location
if (id(weather_location).has_state()) {
it.printf(w1, h3, id(font8), id(my_blue), "%s", id(weather_location).state.c_str());
}
// Inside temp
if (id(temp_int).has_state()) {
it.printf(w3, h3, id(font8), id(my_red), "Casa");
it.printf(w3, h4, id(font2), id(my_red), "%.0f°", id(temp_int).state);
}
// Today wind
if (id(vento).has_state()) {
it.printf(w2, h7, id(sensor_font), "\U000F059D");
it.printf(w2 + 20, h7, id(font8), id(my_gray), "%.0f km/h", id(vento).state);
}
// External humidity
if (id(umidita_ext).has_state()) {
it.printf(w2, h6, id(sensor_font), "\U000F058E");
it.printf(w2 + 20, h6, id(font8), id(my_gray), "%.0f%%", id(umidita_ext).state);
}
// Internal humidity
if (id(umidita_int).has_state()) {
it.printf(w4, h6, id(sensor_font), "\U000F058E");
it.printf(it.get_width(), h6, id(font8), id(my_gray), TextAlign::TOP_RIGHT, "%.0f%%", id(umidita_int).state);
}
// Atmospheric pressure
if (id(pressione_int).has_state()) {
it.printf(w4, h7, id(sensor_font), "\U000F04C5");
it.printf(it.get_width(), h7, id(font8), id(my_gray), TextAlign::TOP_RIGHT, "%.0fb", id(pressione_int).state);
}
// Imported forecast json deserialization
if (id(forecast_5).has_state()) {
int wxx = 0;
int wyy = 0;
int forday = 1;
DynamicJsonDocument doc(2048);
deserializeJson(doc, (id(forecast_5).state.c_str()));
JsonArray root = doc.as<JsonArray>();
for (int i = 0; i <= 3; ++i) {
JsonObject root_x = root[i];
if (i == 0) {
wxx = wx;
wyy = wy;
forday = (id(esptime).now().day_of_week + 1);
}
if (forday == 8) {
forday = 1;
}
// Day 3-4 go down
// if (i == 2) {wyy += 38;}
// if (i == 2) {wxx = 0;}
std::string root_0_condition = root_x["condition"];
float root_0_precipitation = root_x["precipitation"];
float root_0_temperature = root_x["temperature"];
float root_0_templow = root_x["templow"];
// Print to screen
// Translated day
it.printf(wxx, wyy, id(font_small), id(my_green), TextAlign::TOP_CENTER, "%s", dayDict_ext[forday]);
// Icon condition
if (fonDict.count(root_0_condition) > 0) {
it.printf(wxx, wyy + 12, id(weather_font), TextAlign::TOP_CENTER, "%s", fonDict[root_0_condition.c_str()]);
}
// Temp max
it.printf(wxx, wyy + 60, id(font_small_1), TextAlign::TOP_CENTER, "max %.0f°", root_0_temperature);
// Temp min
it.printf(wxx, wyy + 70, id(font_small_1), TextAlign::TOP_CENTER, "min %.0f°", root_0_templow);
// Rain in mm
it.printf(wxx, wyy + 80, id(font_small_1), TextAlign::TOP_CENTER, "%.0f mm", root_0_precipitation);
// lines
it.line(0, wy, it.get_width(), wy);
it.line(0, wy + 95, it.get_width(), wy + 95);
wxx += 85;
forday += 1;
}
}
// Heater icon
if ((id(termostato1).mode) == 0) {
it.printf((it.get_width() / 2), (it.get_height() - 15), id(home_font), id(my_gray), TextAlign::BASELINE_CENTER, "\U000F0425");
} else {
if (id(sensor_caldaia).state) {
it.printf((it.get_width() / 2), (it.get_height() - 15), id(home_font), id(my_red), TextAlign::BASELINE_CENTER, "\U000F0238");
} else {
it.printf((it.get_width() / 2), (it.get_height() - 15), id(home_font), id(my_gray), TextAlign::BASELINE_CENTER, "\U000F0238");
}
}
// Display thermostat desired temperature
it.printf((it.get_width() / 2), it.get_height(), id(font8), id(my_red), TextAlign::BASELINE_CENTER, "%.1f°", id(termostato1).target_temperature);
// When the motion sensor sees something, draw 2 eyes
// if (id(movimento).state) {
// it.printf(it.get_width(), it.get_height(), id(home_font), id(my_red), TextAlign::BASELINE_RIGHT, "\U000F06D0");
// it.printf(0, it.get_height(), id(home_font), id(my_red), TextAlign::BASELINE_LEFT, "\U000F06D0");
// } else {
// Plus Key
it.printf(it.get_width(), it.get_height(), id(home_font), id(my_gray), TextAlign::BASELINE_RIGHT, "\U000F0415");
// Minus key
it.printf(0, it.get_height(), id(home_font), id(my_gray), TextAlign::BASELINE_LEFT, "\U000F0374");
// }
// Total absorption icon and value
if (id(consumo_t).has_state()) {
if (id(consumo_t).state < 2800) {
it.printf((it.get_width() / 2 - 65), (it.get_height() - 15), id(home_font), id(my_gray), TextAlign::BASELINE_CENTER, "\U000F0241");
it.printf((it.get_width() / 2 - 65), it.get_height(), id(font8), id(my_blue), TextAlign::BASELINE_CENTER, "%.0f W", id(consumo_t).state);
} else {
it.printf((it.get_width() / 2 - 65), (it.get_height() - 15), id(home_font), id(my_red), TextAlign::BASELINE_CENTER, "\U000F0241");
it.printf((it.get_width() / 2 - 65), it.get_height(), id(font8), id(my_red), TextAlign::BASELINE_CENTER, "%.0f W", id(consumo_t).state);
}
}
// Washing machine status and absorption value
if (id(consumo_c).has_state()) {
if (id(consumo_c).state > 20) {
it.printf((it.get_width() / 2 + 65), (it.get_height() - 15), id(home_font), id(my_red), TextAlign::BASELINE_CENTER, "\U000F072A");
it.printf((it.get_width() / 2 + 65), it.get_height(), id(font8), id(my_red), TextAlign::BASELINE_CENTER, "%.0f W", id(consumo_c).state);
} else {
it.printf((it.get_width() / 2 + 65), (it.get_height() - 15), id(home_font), id(my_gray), TextAlign::BASELINE_CENTER, "\U000F11BD");
it.printf((it.get_width() / 2 + 65), it.get_height(), id(font8), id(my_blue), TextAlign::BASELINE_CENTER, "%.0f W", id(consumo_c).state);
}
}
- id: page2 # pagina 2
lambda: |-
// cordinate scritta direzione vento
int DIRx = 110;
int DIRy = 50;
// cordinate centro rosa venti
int cerchio_x = 120;
int cerchio_y = 70;
int raggio = 50;
// Convert wind direction da int a float con nome DIR per fare IF
float dir = id(wind_bearing).state;
// Wind DIREZIONE NANE (do il nome)
std::string name_dir; // definisco variabile locale stringa di nome name_dir dove assegno la direzione del vento in NSEW
std::string name_vento; // definisco variabile locale stringa di nome vento
if (dir>0 && dir<=11) { name_dir = "N"; name_vento = "Tramontana"; }
else {
if (dir>11 && dir<=33) { name_dir = "NEE"; name_vento = "Tramontana"; }
else {
if (dir>33 && dir<=55) { name_dir = "NE"; name_vento = "Greco"; }
else {
if (dir>55 && dir<=77) { name_dir = "ENE"; name_vento = "Greco"; }
else {
if (dir>77 && dir<=99) { name_dir = "E"; name_vento = "Levante"; }
else {
if (dir>99 && dir<=121) { name_dir = "ESE"; name_vento = "Levante"; }
else {
if (dir>121 && dir<=143) { name_dir = "SE"; name_vento = "Scirocco"; }
else {
if (dir>143 && dir<=165) { name_dir = "SSE"; name_vento = "Scirocco"; }
else {
if (dir>165 && dir<=190) { name_dir = "S"; name_vento = "Mezzogiorno"; }
else {
if (dir>190 && dir<=212) { name_dir = "SSW"; name_vento = "Mezzogiorno"; }
else {
if (dir>212 && dir<=234) { name_dir = "SW"; name_vento = "Libeccio"; }
else {
if (dir>234 && dir<=256) { name_dir = "WSW"; name_vento = "Libeccio"; }
else {
if (dir>256 && dir<=278) { name_dir = "W"; name_vento = "Ponente"; }
else {
if (dir>278 && dir<=300) { name_dir = "WNW"; name_vento = "Ponente"; }
else {
if (dir>300 && dir<=322) { name_dir = "NW"; name_vento = "Maestrale"; }
else {
if (dir>322 && dir<=344) { name_dir = "NNW"; name_vento = "Maestrale"; }
else {
if (dir>344 && dir<=360) { name_dir = "N"; name_vento = "Tramontana"; }
else {
} } } } } } } } } } } } } } } } }