-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnspanel-kitchen.yaml
861 lines (800 loc) · 27 KB
/
nspanel-kitchen.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
# -------------------------------------
# ---- SONOFF NSPanel - Kitchen ----
# Product - https://itead.cc/product/sonoff-nspanel-smart-scene-wall-switch/
# Use https://esphome.io/api/nextion__commands_8cpp_source.html for commands
# Use FontAwesome for icons - https://fontawesome.com/search?o=r&m=free
# -------------------------------------
#Power 1.7w-0.7w (full screen - screen off)
# RTTTL list - https://github.com/hitov/megamelody/tree/master/ringtones
# StarWars:d=4,o=5,b=180:8f,8f,8f,2a#.,2f.6,8d#6,8d6,8c6,2a#.6,f.6,8d#6,8d6,8c6,2a#.6,f.6,8d#6,8d6,8d#6,2c6,p,8f,8f,8f,2a#.,2f.6,8d#6,8d6,8c6,2a#.6,f.6,8d#6,8d6,8c6,2a#.6,f.6,8d#6,8d6,8d#6,2c6
substitutions:
devicename: nspanel-kitchen
friendly_name: "NSPanel Kitchen"
ha_speaker: media_player.zone_15
ha_aircon: climate.air_conditioner
ha_exportPower: sensor.mainsin
ha_carBoost: input_number.chargerboostamps
# ha_outdoorTemp: sensor.tank_minder_temperature
esphome:
name: ${devicename}
esp32:
board: esp32dev
wifi:
networks:
- ssid: !secret wifi_ssid
password: !secret wifi_password
hidden: True
manual_ip:
static_ip: !secret ip_nspanel_kitchen
gateway: !secret ip_gateway
subnet: 255.255.255.0
domain: .homelan
ap: # Enable fallback hotspot (captive portal) in case wifi connection fails
ssid: "${friendly_name} Hotspot"
password: !secret password
captive_portal:
# Enable logging
logger:
# level: WARN
# Enable Home Assistant API
api:
reboot_timeout: 0s # Dont reboot..
encryption:
key: !secret encryption_key
services:
# Service to play a song
- service: play_rtttl
variables:
song_str: string
then:
- rtttl.play:
rtttl: !lambda 'return song_str;'
# Service to upload a new screen file (TFT)
- service: upload_tft
then:
- lambda: 'id(disp1)->upload_tft();'
- service: send_command
variables:
cmd: string
then:
- lambda: 'id(disp1).send_command_printf("%s", cmd.c_str());'
# Service to control the visible page from Home Assistant
- service: set_page
variables:
page: int
then:
- lambda: 'id(disp1).send_command_printf("page %i", page);'
# Service to show a notification on the screen for 20 s. Tap or wait to close
- service: notification
variables:
header: string
message: string
then:
- lambda: |-
id(disp1).send_command_printf("page 5");
id(disp1).set_component_text("message.txtMessHead", header.c_str());
id(disp1).set_component_text("message.txtMessBody", message.c_str());
- rtttl.play: "twobits:d=16,o=5,b=180:c,e,g,c6,8p,c,16p,e,c"
- delay: 40s
- lambda: id(disp1).send_command_printf("page 1");
- service: set_text
variables:
component: string
text: string
then:
- lambda: |-
id(disp1).set_component_text(component.c_str(),text.c_str());
- service: set_value
variables:
component: string
value: int
then:
- lambda: |-
id(disp1).set_component_value(component.c_str(), value);
- service: set_brightness
variables:
brightness: float
then:
- lambda: |-
id(disp1).set_backlight_brightness(brightness);
- service: set_background_color
variables:
component: string
color: int
then:
- lambda: |-
id(disp1).set_component_background_color(component.c_str(), color);
- service: set_font_color
variables:
component: string
color: int
then:
- lambda: |-
id(disp1).set_component_font_color(component.c_str(), color);
- service: set_font
variables:
component: string
font_id: int
then:
- lambda: |-
id(disp1).set_component_font(component.c_str(), font_id);
- service: set_picc
variables:
component: string
pic_id: int
then:
- lambda: |-
id(disp1).set_component_picc(component.c_str(), pic_id);
- service: set_pic
variables:
component: string
pic_id: int
then:
- lambda: |-
id(disp1).set_component_pic(component.c_str(), pic_id);
ota:
password: !secret password
web_server:
port: 80
auth:
username: admin
password: !secret password
#-------------------------------------------------------------------------------
# Sync time with Home Assistant.
time:
- platform: homeassistant
id: homeassistant_time
timezone: "Australia/Sydney"
on_time:
- seconds: 0
minutes: /1
then:
- lambda: id(disp1).set_component_text_printf("home.txtTime", "%02i:%02i", id(homeassistant_time).now().hour, id(homeassistant_time).now().minute);
- lambda: id(disp1).set_component_text_printf("home.txtDate", "%i-%02i-%02i", id(homeassistant_time).now().day_of_month, id(homeassistant_time).now().month, id(homeassistant_time).now().year);
on_time_sync:
then:
- wait_until:
switch.is_on: nextion_init
- lambda: id(disp1).set_component_text_printf("home.txtTime", "%02i:%02i", id(homeassistant_time).now().hour, id(homeassistant_time).now().minute);
- lambda: id(disp1).set_component_text_printf("home.txtDate", "%i-%02i-%02i", id(homeassistant_time).now().day_of_month, id(homeassistant_time).now().month, id(homeassistant_time).now().year);
# https://esphome.io/components/time.html
binary_sensor:
- platform: status
name: "${friendly_name} Status"
####################################################################
# Nextion buttons #
####################################################################
- platform: gpio
name: "${friendly_name} Left Button"
pin:
number: 14
inverted: true
icon: mdi:light-switch
# on_click:
# - switch.toggle: relay_1
- platform: gpio
name: "${friendly_name} Right Button"
pin:
number: 27
inverted: true
icon: mdi:light-switch
# on_click:
# - switch.toggle: relay_2
###############
## Cars #
###############
- platform: nextion
name: $friendly_name Car Down
page_id: 2
component_id: 15
on_release:
then:
- homeassistant.service:
service: input_number.decrement
data:
entity_id: $ha_carBoost
- platform: nextion
name: $friendly_name Car Up
page_id: 2
component_id: 17
on_release:
then:
- homeassistant.service:
service: input_number.increment
data:
entity_id: $ha_carBoost
- platform: nextion
name: $friendly_name Car Stop
page_id: 2
component_id: 18
###############
## Aircon #
###############
- platform: nextion
name: $friendly_name Aircon Power
page_id: 3
component_id: 16
on_release:
then:
- homeassistant.service:
service: climate.turn_off
data:
entity_id: $ha_aircon
- platform: nextion
name: $friendly_name Aircon Temp Down
page_id: 3
component_id: 15
on_release:
then:
- homeassistant.service:
service: climate.set_temperature
data_template:
entity_id: $ha_aircon
temperature: '{{ (state_attr("$ha_aircon", "temperature")|round(0)) - 1 }}'
- platform: nextion
name: $friendly_name Aircon Temp Up
page_id: 3
component_id: 14
on_release:
then:
- homeassistant.service:
service: climate.set_temperature
data_template:
entity_id: $ha_aircon
temperature: '{{ (state_attr("$ha_aircon", "temperature")|round(0)) + 1 }}'
- platform: nextion
name: $friendly_name Aircon Cool
page_id: 3
component_id: 10
on_release:
then:
- homeassistant.service:
service: climate.set_hvac_mode
data:
entity_id: $ha_aircon
hvac_mode: cool
- platform: nextion
name: $friendly_name Aircon Heat
page_id: 3
component_id: 11
on_release:
then:
- homeassistant.service:
service: climate.set_hvac_mode
data:
entity_id: $ha_aircon
hvac_mode: heat
- platform: nextion
name: $friendly_name Aircon Fan
page_id: 3
component_id: 12
on_release:
then:
- homeassistant.service:
service: climate.set_hvac_mode
data:
entity_id: $ha_aircon
hvac_mode: fan_only
- platform: nextion
name: $friendly_name Aircon Auto
page_id: 3
component_id: 13
on_release:
then:
- homeassistant.service:
service: climate.set_hvac_mode
data:
entity_id: $ha_aircon
hvac_mode: auto
###############
## Speakers #
###############
- platform: nextion
name: $friendly_name Speaker Power
page_id: 4
component_id: 11
- platform: nextion
name: $friendly_name Speaker Vol Down
page_id: 4
component_id: 14
on_release:
then:
- homeassistant.service:
service: media_player.volume_down
data_template:
entity_id: $ha_speaker
- platform: nextion
name: $friendly_name Speaker Vol Up
page_id: 4
component_id: 13
on_release:
then:
- homeassistant.service:
service: media_player.volume_up
data_template:
entity_id: $ha_speaker
- platform: nextion
name: $friendly_name Speaker Source Chomecast
page_id: 4
component_id: 6
on_release:
then:
- homeassistant.service:
service: media_player.select_source
data:
entity_id: $ha_speaker
source: Chromecast
- platform: nextion
name: $friendly_name Speaker Source Study PC
page_id: 4
component_id: 10
on_release:
then:
- homeassistant.service:
service: media_player.select_source
data:
entity_id: $ha_speaker
source: StudyPC
- platform: nextion
name: $friendly_name Speaker Source Media Center
page_id: 4
component_id: 7
on_release:
then:
- homeassistant.service:
service: media_player.select_source
data:
entity_id: $ha_speaker
source: MediaCenterAmp
number:
platform: template
name: $friendly_name Brightness
id: brightness
entity_category: config
unit_of_measurement: '%'
min_value: 0
max_value: 100
step: 1
initial_value: 30
set_action:
then:
- lambda: 'id(disp1).set_backlight_brightness(x/100);'
output:
- platform: ledc
id: buzzer_out
pin:
number: 21
rtttl:
id: buzzer
output: buzzer_out
button:
- platform: restart
name: "$friendly_name Restart"
device_class: restart
entity_category: config
- platform: template
name: $friendly_name TFT Upload
device_class: update
entity_category: config
on_press:
- lambda: 'id(disp1)->upload_tft();'
switch:
- platform: gpio
name: ${friendly_name} Relay 1
id: relay_1
pin:
number: 22
icon: mdi:ceiling-light
# on_turn_on:
# then:
# button_light_right
# on_turn_off:
# then:
# - lambda: |-
# button_light_right
- platform: gpio
name: ${friendly_name} Relay 2
id: relay_2
pin:
number: 19
icon: mdi:ceiling-light
# on_turn_on:
# then:
# button_light_right
# on_turn_off:
# then:
# - lambda: |-
# button_light_right
- platform: gpio
name: ${friendly_name} Screen Power
id: screen_power
entity_category: config
pin:
number: 4
inverted: true
restore_mode: ALWAYS_ON
icon: mdi:television
# # Basically a global variable to keep track on whether the Nextion display is ready or not. Delays initial info from HA to the display.
- platform: template
name: $friendly_name Nextion Inited
id: nextion_init
internal: true
entity_category: config
restore_state: false
assumed_state: off
optimistic: true
# # Basically a global variable to keep track on whether the Nextion display is ready or not. Delays initial info from HA to the display, but with some extra delay
# - platform: template
# name: $friendly_name Nextion Inited Slow
# id: nextion_init_slow
## internal: true
# entity_category: config
# restore_state: false
# assumed_state: off
# optimistic: true
# Show alarm screen on the display and disable the display usage (except for physical buttons).
- platform: template
name: $friendly_name Alarm screen
id: alarm_activated
entity_category: config
restore_state: false
assumed_state: off
optimistic: true
icon: mdi:alarm-light
on_turn_on:
- lambda: id(disp1).send_command_printf("page 6"); # this is the alarm page, must be updated when the page IDs change
on_turn_off:
- lambda: id(disp1).send_command_printf("page 1");
# # A template switch to keep track if Light details switch is on/off. This switch is controlled by an automation in Home Assistant
# - platform: template
# name: $friendly_name Light details toggle
# id: light_details_toggle
# entity_category: config
# restore_state: false
# assumed_state: off
# optimistic: true
# on_turn_on:
# - lambda: 'id(disp1).send_command_printf("lightdetails.light1.pic=%i", 23);'
# on_turn_off:
# - lambda: 'id(disp1).send_command_printf("lightdetails.light1.pic=%i", 22);'
- platform: template
name: $friendly_name Left Button Light
id: button_light_left
restore_state: false
assumed_state: off
optimistic: true
on_turn_on:
then:
- lambda: |-
id(disp1).set_component_pic("home.button_left", 0);
id(disp1).set_component_pic("cars.button_left", 0);
id(disp1).set_component_pic("aircon.button_left", 0);
id(disp1).set_component_pic("speakers.button_left", 0);
on_turn_off:
then:
- lambda: |-
id(disp1).set_component_pic("home.button_left", 1);
id(disp1).set_component_pic("cars.button_left", 1);
id(disp1).set_component_pic("aircon.button_left", 1);
id(disp1).set_component_pic("speakers.button_left", 1);
- platform: template
name: $friendly_name Right Button Light
id: button_light_right
restore_state: false
assumed_state: off
optimistic: true
on_turn_on:
then:
- lambda: |-
id(disp1).set_component_pic("home.button_right", 0);
id(disp1).set_component_pic("cars.button_right", 0);
id(disp1).set_component_pic("aircon.button_right", 0);
id(disp1).set_component_pic("speakers.button_right", 0);
on_turn_off:
then:
- lambda: |-
id(disp1).set_component_pic("home.button_right", 1);
id(disp1).set_component_pic("cars.button_right", 1);
id(disp1).set_component_pic("aircon.button_right", 1);
id(disp1).set_component_pic("speakers.button_right", 1);
sensor:
# - platform: nextion
# nextion_id: disp1
# name: $friendly_name n0
# component_name: n0
# - platform: nextion
# id: current_page
# name: $friendly_name Current Page
# variable_name: dp
# update_interval: 1s
- platform: uptime
name: $friendly_name uptime
id: uptime_sensor
update_interval: 60s
# 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 (
# (days ? String(days) + "d " : "") +
# (hours ? String(hours) + "h " : "") +
# (minutes ? String(minutes) + "m " : "") +
# (String(seconds) + "s")
# ).c_str();
- platform: wifi_signal
name: $friendly_name WiFi Signal
id: wifi_sig
update_interval: 60s
on_value:
then:
- wait_until:
switch.is_on: nextion_init
- lambda: |-
int symbol=24; // 24 is lowest wifi signal
if (id(wifi_sig).state < -70) {
symbol=24;
} else if (id(wifi_sig).state > -45) {
symbol=27;
} else if (id(wifi_sig).state > -50) {
symbol=26;
} else if (id(wifi_sig).state > -71) {
symbol=25;
}
id(disp1).send_command_printf("settings.wifi.pic=%i", symbol);
- platform: adc
id: ntc_source
pin: 38
update_interval: 10s
attenuation: 11db
- platform: resistance
id: resistance_sensor
sensor: ntc_source
configuration: DOWNSTREAM
resistor: 11.2kOhm
- platform: ntc
id: temperature
sensor: resistance_sensor
calibration:
b_constant: 3950
reference_temperature: 25°C
reference_resistance: 10kOhm
name: "${friendly_name} Temperature"
device_class: temperature
state_class: measurement
accuracy_decimals: 1
on_value:
then:
- wait_until:
switch.is_on: nextion_init
- lambda: 'id(disp1).set_component_text_printf("home.txtTempIn", "%.1f ""\xb0""F", x);'
- platform: homeassistant
id: outdoor_temperature
# entity_id: $ha_outdoorTemp
entity_id: weather.home
attribute: temperature
internal: true
on_value:
# Push it to the display
then:
- wait_until:
switch.is_on: nextion_init
- lambda: 'id(disp1).set_component_text_printf("home.txtTempOut", "%.1f ""\xb0""F", x);'
- platform: homeassistant
id: watts_house
entity_id: $ha_exportPower
on_value:
then:
- lambda: 'id(disp1).set_component_text_printf("home.txtWatts", "%iw", (int)x);'
- lambda: |-
int colval=65535; // white
if (id(watts_house).state < -4000) {
colval=1086;
} else if (id(watts_house).state < -2500) {
colval=26464;
} else if (id(watts_house).state < -1000) {
colval=49120;
} else if (id(watts_house).state > 2000) {
colval=61728;
} else if (id(watts_house).state > 250) {
colval=65529;
}
id(disp1).set_component_font_color("home.txtWatts",colval);
- platform: homeassistant
id: car_boost
entity_id: $ha_carBoost
internal: true
on_value:
then:
- wait_until:
switch.is_on: nextion_init
- lambda: 'id(disp1).set_component_text_printf("cars.btnCarAmps", "%iA", (int)x);'
# Grab current aircon info Home Assistant
- platform: homeassistant
id: aircon_setpoint
entity_id: $ha_aircon
attribute: temperature
internal: true
on_value:
then:
- wait_until:
switch.is_on: nextion_init
- lambda: 'id(disp1).set_component_text_printf("aircon.txtSetTemp", "%.1f°C", id(aircon_setpoint).state);'
- platform: homeassistant
id: aircon_temp
entity_id: $ha_aircon
attribute: current_temperature
internal: true
on_value:
then:
- wait_until:
switch.is_on: nextion_init
- lambda: 'id(disp1).set_component_text_printf("aircon.txtCurrTemp", "%.1f°C", id(aircon_temp).state);'
text_sensor:
- platform: version
name: $friendly_name ESPHome version
# # Expose WiFi information as sensors
# - platform: wifi_info
# ip_address:
# name: $friendly_name IP
# icon: mdi:ip-network
# id: ip_address
# on_value:
# then:
## - wait_until:
## switch.is_on: nextion_init
# - lambda: id(disp1).set_component_text_printf("connecting.ip_addr", "%s", id(ip_address).state.c_str());
# ssid:
# name: $friendly_name SSID
# bssid:
# name: $friendly_name BSSID
# Weather symbol, HA weather entity to pull data from
# States https://www.home-assistant.io/integrations/weather/
- platform: homeassistant
id: weather_symbol
entity_id: weather.home
on_value:
then:
- wait_until:
switch.is_on: nextion_init
- lambda: |-
if (id(weather_symbol).state == "clear-night") {
id(disp1).set_component_text("home.txtWeatherIcon","");
} else if (id(weather_symbol).state == "cloudy") {
id(disp1).set_component_text("home.txtWeatherIcon","");
} else if (id(weather_symbol).state == "fog") {
id(disp1).set_component_text("home.txtWeatherIcon","");
} else if (id(weather_symbol).state == "hail") {
id(disp1).set_component_text("home.txtWeatherIcon","");
} else if (id(weather_symbol).state == "lightning") {
id(disp1).set_component_text("home.txtWeatherIcon","");
} else if (id(weather_symbol).state == "lightning-rainy") {
id(disp1).set_component_text("home.txtWeatherIcon","");
} else if (id(weather_symbol).state == "partlycloudy") {
id(disp1).set_component_text("home.txtWeatherIcon","");
} else if (id(weather_symbol).state == "pouring") {
id(disp1).set_component_text("home.txtWeatherIcon","");
} else if (id(weather_symbol).state == "rainy") {
id(disp1).set_component_text("home.txtWeatherIcon","");
} else if (id(weather_symbol).state == "snowy") {
id(disp1).set_component_text("home.txtWeatherIcon","");
} else if (id(weather_symbol).state == "snowy-rainy") {
id(disp1).set_component_text("home.txtWeatherIcon","");
} else if (id(weather_symbol).state == "sunny") {
id(disp1).set_component_text("home.txtWeatherIcon","");
} else if (id(weather_symbol).state == "windy" || id(weather_symbol).state == "windy-variant") {
id(disp1).set_component_text("home.txtWeatherIcon","");
} else if (id(weather_symbol).state == "exceptional") {
id(disp1).set_component_text("home.txtWeatherIcon","");
} else {
id(disp1).set_component_text("home.txtWeatherIcon","");
}
# id(disp1).set_component_text("home.txtWeatherIcon",""); #moon
# id(disp1).set_component_text("home.txtWeatherIcon",""); #cloud
# id(disp1).set_component_text("home.txtWeatherIcon",""); #water
# id(disp1).set_component_text("home.txtWeatherIcon",""); #meteor
# id(disp1).set_component_text("home.txtWeatherIcon",""); #bolt
# id(disp1).set_component_text("home.txtWeatherIcon",""); #bolt
# id(disp1).set_component_text("home.txtWeatherIcon",""); #cloud
# id(disp1).set_component_text("home.txtWeatherIcon",""); #cloud-showers-heavy
# id(disp1).set_component_text("home.txtWeatherIcon",""); #cloud-rain
# id(disp1).set_component_text("home.txtWeatherIcon",""); #snowflake
# id(disp1).set_component_text("home.txtWeatherIcon",""); #snowflake
# id(disp1).set_component_text("home.txtWeatherIcon",""); #sun
# id(disp1).set_component_text("home.txtWeatherIcon",""); #wind
# id(disp1).set_component_text("home.txtWeatherIcon",""); #poo-storm
- platform: homeassistant
id: aircon_mode
entity_id: $ha_aircon
on_value:
then:
- wait_until:
switch.is_on: nextion_init
- lambda: |-
id(disp1).set_component_font_color("aircon.btnAirCool","65535");
id(disp1).set_component_font_color("aircon.btnAirHeat","65535");
id(disp1).set_component_font_color("aircon.btnAirFan","65535");
id(disp1).set_component_font_color("aircon.btnAirAuto","65535");
if (id(aircon_mode).state == "off") {
id(disp1).set_component_picc("aircon.txtCurrTemp", 6);
id(disp1).set_component_picc("aircon.btnAirPower", 6);
id(disp1).set_component_pic("aircon.picState", 6);
} else if (id(aircon_mode).state == "auto") {
id(disp1).set_component_font_color("aircon.btnAirAuto","51833");
id(disp1).set_component_picc("aircon.txtCurrTemp", 7);
id(disp1).set_component_picc("aircon.btnAirPower", 7);
id(disp1).set_component_pic("aircon.picState", 7);
} else if (id(aircon_mode).state == "cool") {
id(disp1).set_component_font_color("aircon.btnAirCool","5631");
id(disp1).set_component_picc("aircon.txtCurrTemp", 8);
id(disp1).set_component_picc("aircon.btnAirPower", 8);
id(disp1).set_component_pic("aircon.picState", 8);
} else if (id(aircon_mode).state == "fan_only") {
id(disp1).set_component_font_color("aircon.btnAirFan","22177");
id(disp1).set_component_picc("aircon.txtCurrTemp", 9);
id(disp1).set_component_picc("aircon.btnAirPower", 9);
id(disp1).set_component_pic("aircon.picState", 9);
} else if (id(aircon_mode).state == "heat") {
id(disp1).set_component_font_color("aircon.btnAirHeat","64032");
id(disp1).set_component_picc("aircon.txtCurrTemp", 10);
id(disp1).set_component_picc("aircon.btnAirPower", 10);
id(disp1).set_component_pic("aircon.picState", 10);
}
- platform: homeassistant
id: speaker_mode
entity_id: $ha_speaker
attribute: source
on_value:
then:
- wait_until:
switch.is_on: nextion_init
- lambda: |-
id(disp1).set_component_font_color("speakers.btnSpkWireless","65535");
id(disp1).set_component_font_color("speakers.btnSpkComputer","65535");
id(disp1).set_component_font_color("speakers.btnSpkPlay","65535");
if (id(speaker_mode).state == "Chromecast") {
id(disp1).set_component_font_color("speakers.btnSpkWireless","65504");
} else if (id(speaker_mode).state == "StudyPC") {
id(disp1).set_component_font_color("speakers.btnSpkComputer","65504");
} else if (id(speaker_mode).state == "MediaCenterAmp") {
id(disp1).set_component_font_color("speakers.btnSpkPlay","65504");
}
uart:
id: tf_uart
tx_pin: 16
rx_pin: 17
baud_rate: 115200
display:
- platform: nextion
id: disp1
uart_id: tf_uart
tft_url: !secret nspanel_tft_url
brightness: 30%
touch_sleep_timeout: 300
wake_up_page: 1
auto_wake_on_touch: true
on_setup:
then:
- wait_until:
api.connected
- switch.template.publish:
id: nextion_init
state: on
- lambda: id(disp1).send_command_printf("page 1");
# - delay: 10s
# - switch.template.publish:
# id: nextion_init_slow
# state: on
- number.set:
id: brightness
value: 30
# - lambda: 'id(disp1).set_component_text_printf("home.txtTempOut", "%.1f", id(outdoor_temperature).state);'
# - rtttl.play: "twobits:d=4,o=5,b=220:c6,8g,8g,a,g,p,b,c6"
- rtttl.play: "onebit:d=4,o=5,b=220:c6"