Letzter täglicher Build · 8 YAML-Konfigurationen
Build erfolgreich mit Deprecated-Meldungen
Zuletzt gebaut: 04.10.2026, 15:08

tx-ultimate-cover-light.png
1860.8 KB

tx-ultimate-ha.png
239.0 KB
LICENSE
1.0 KB
1substitutions:
2 name: "shys-tx-ultimate"
3 friendly_name: "TX Ultimate"
4
5 relay_count: "2"
6
7 toggle_relay_1_on_touch: "true"
8 toggle_relay_2_on_touch: "true"
9 toggle_relay_3_on_touch: "true"
10
11 vibra_time: 150ms
12 button_on_time: 500ms
13
14 button_brightness: "0.7"
15 button_color: "{0,0,100}"
16
17 nightlight: "on"
18 nightlight_brightness: "0.2"
19 nightlight_color: "{80,70,0}"
20
21 latitude: "50.123456°"
22 longitude: "5.654321°"
23
24 touch_brightness: "1"
25 touch_color: "{0,100,100}"
26 touch_effect: "Scan"
27
28 long_press_brightness: "1"
29 long_press_color: "{100,0,0}"
30 long_press_effect: "none"
31
32 multi_touch_brightness: "1"
33 multi_touch_color: "{0,0,0}"
34 multi_touch_effect: "Rainbow"
35
36 swipe_left_brightness: "1"
37 swipe_left_color: "{0,100,0}"
38 swipe_left_effect: "none"
39
40 swipe_right_brightness: "1"
41 swipe_right_color: "{100,0,70}"
42 swipe_right_effect: "none"
43
44 relay_1_pin: GPIO18
45 relay_2_pin: GPIO17
46 relay_3_pin: GPIO27
47 relay_4_pin: GPIO23
48
49 vibra_motor_pin: GPIO21
50 pa_power_pin: GPIO26
51
52 led_pin: GPIO13
53 status_led_pin: GPIO33
54
55 uart_tx_pin: GPIO19
56 uart_rx_pin: GPIO22
57
58 audio_lrclk_pin: GPIO4
59 audio_bclk_pin: GPIO2
60 audio_sdata_pin: GPIO15
61
62 touchpanel_power_pin: GPIO5
63
64
65esphome:
66 name: ${name}
67 friendly_name: ${friendly_name}
68 project:
69 name: smarthomeyourself.tx_ultimate
70 version: "1.0"
71
72 on_boot:
73 priority: -100
74 then:
75 - binary_sensor.template.publish:
76 id: touchfield_1
77 state: OFF
78 - binary_sensor.template.publish:
79 id: touchfield_2
80 state: OFF
81 - binary_sensor.template.publish:
82 id: touchfield_3
83 state: OFF
84 - binary_sensor.template.publish:
85 id: multi_touch
86 state: OFF
87 - binary_sensor.template.publish:
88 id: swipe_left
89 state: OFF
90 - binary_sensor.template.publish:
91 id: swipe_right
92 state: OFF
93 - binary_sensor.template.publish:
94 id: long_press
95 state: OFF
96 - script.execute: refresh_led_default
97 - script.execute: refresh_nightlight
98
99esp32:
100 board: esp32dev
101 framework:
102 type: esp-idf
103
104logger:
105# hardware_uart: UART2
106 level: DEBUG
107 logs:
108 binary_sensor: INFO
109 light: INFO
110 script: INFO
111 switch: INFO
112 tx_ultimate_touch: INFO
113 uart_debug: INFO
114
115dashboard_import:
116 package_import_url: github://SmartHome-yourself/shys-collection/templates/esphome/setups/sonoff-tx-ultimate/tx_ultimate.yaml@main
117 import_full_config: false
118
119api:
120
121ota:
122 - platform: esphome
123
124wifi:
125 ap:
126 password: "12345678"
127
128improv_serial:
129
130captive_portal:
131
132external_components:
133# - source: /config/esphome/my_components
134 - source:
135 type: git
136 url: https://github.com/SmartHome-yourself/sonoff-tx-ultimate-for-esphome
137 ref: main
138 components: [tx_ultimate_touch]
139
140
141
142globals:
143 - id: nightlight_color
144 type: int [3]
145 restore_value: no
146 initial_value: ${nightlight_color}
147 - id: button_color
148 type: int [3]
149 restore_value: no
150 initial_value: ${button_color}
151 - id: long_press_color
152 type: int [3]
153 restore_value: no
154 initial_value: ${long_press_color}
155 - id: multi_touch_color
156 type: int [3]
157 restore_value: no
158 initial_value: ${multi_touch_color}
159 - id: swipe_left_color
160 type: int [3]
161 restore_value: no
162 initial_value: ${swipe_left_color}
163 - id: swipe_right_color
164 type: int [3]
165 restore_value: no
166 initial_value: ${swipe_right_color}
167 - id: touch_color
168 type: int [3]
169 restore_value: no
170 initial_value: ${touch_color}
171
172
173
174binary_sensor:
175 - platform: template
176 name: "Touchfield 1"
177 id: touchfield_1
178 on_press:
179 - if:
180 condition:
181 lambda: "return ${toggle_relay_1_on_touch};"
182 then:
183 - switch.toggle: relay_1
184 - delay: ${button_on_time}
185 - binary_sensor.template.publish:
186 id: touchfield_1
187 state: OFF
188 - script.execute: refresh_led_default
189
190 - platform: template
191 name: "Touchfield 2"
192 id: touchfield_2
193 on_press:
194 - if:
195 condition:
196 lambda: "return ${toggle_relay_2_on_touch};"
197 then:
198 - switch.toggle: relay_2
199 - delay: ${button_on_time}
200 - binary_sensor.template.publish:
201 id: touchfield_2
202 state: OFF
203 - script.execute: refresh_led_default
204
205 - platform: template
206 name: "Touchfield 3"
207 id: touchfield_3
208 on_press:
209 - if:
210 condition:
211 lambda: "return ${toggle_relay_3_on_touch};"
212 then:
213 - switch.toggle: relay_3
214 - delay: ${button_on_time}
215 - binary_sensor.template.publish:
216 id: touchfield_3
217 state: OFF
218 - script.execute: refresh_led_default
219
220 - platform: template
221 name: "Swipe left"
222 id: swipe_left
223 on_press:
224 - delay: ${button_on_time}
225 - binary_sensor.template.publish:
226 id: swipe_left
227 state: OFF
228 - script.execute: refresh_led_default
229
230 - platform: template
231 name: "Swipe_right"
232 id: swipe_right
233 on_press:
234 - delay: ${button_on_time}
235 - binary_sensor.template.publish:
236 id: swipe_right
237 state: OFF
238 - script.execute: refresh_led_default
239
240 - platform: template
241 name: "Multi Touch"
242 id: multi_touch
243 on_press:
244 - delay: ${button_on_time}
245 - binary_sensor.template.publish:
246 id: multi_touch
247 state: OFF
248 - script.execute: refresh_led_default
249
250 - platform: template
251 name: "Long Press"
252 id: long_press
253 on_press:
254 - delay: ${button_on_time}
255 - binary_sensor.template.publish:
256 id: long_press
257 state: OFF
258 - script.execute: refresh_led_default
259
260switch:
261 - platform: gpio
262 id: relay_1
263 name: "${friendly_name} L1"
264 pin: ${relay_1_pin}
265 restore_mode: RESTORE_DEFAULT_OFF
266 on_turn_on:
267 then:
268 - script.execute: refresh_led_default
269 on_turn_off:
270 then:
271 - script.execute: refresh_led_default
272
273 - platform: gpio
274 id: relay_2
275 name: "${friendly_name} L2"
276 pin: ${relay_2_pin}
277 restore_mode: RESTORE_DEFAULT_OFF
278 on_turn_on:
279 then:
280 - script.execute: refresh_led_default
281 on_turn_off:
282 then:
283 - script.execute: refresh_led_default
284
285 - platform: gpio
286 id: relay_3
287 name: "${friendly_name} L3"
288 pin: ${relay_3_pin}
289 restore_mode: RESTORE_DEFAULT_OFF
290 on_turn_on:
291 then:
292 - script.execute: refresh_led_default
293 on_turn_off:
294 then:
295 - script.execute: refresh_led_default
296
297 - platform: gpio
298 id: vibra
299 pin: ${vibra_motor_pin}
300 name: "${friendly_name} Vibration"
301 restore_mode: ALWAYS_OFF
302 on_turn_on:
303 - delay: ${vibra_time}
304 - switch.turn_off: vibra
305
306 - platform: gpio
307 id: pa_power
308 pin: ${pa_power_pin}
309 name: "PA Power"
310 internal: true
311 restore_mode: ALWAYS_ON
312
313 - platform: gpio
314 name: "touch panel power"
315 pin:
316 number: ${touchpanel_power_pin}
317 inverted: true
318 id: touch_power
319 internal: true
320 restore_mode: RESTORE_DEFAULT_ON
321
322 - platform: template
323 name: "Nightlight"
324 id: nightlight
325 internal: true
326 optimistic: true
327 restore_mode: RESTORE_DEFAULT_OFF
328 on_turn_on:
329 then:
330 - script.execute: refresh_led_default
331 on_turn_off:
332 then:
333 - script.execute: refresh_led_default
334
335 - platform: template
336 name: "Nightlight"
337 id: nightlight_active
338 optimistic: true
339 restore_mode: RESTORE_DEFAULT_OFF
340 on_turn_on:
341 then:
342 - script.execute: refresh_led_default
343 on_turn_off:
344 then:
345 - script.execute: refresh_led_default
346
347 - platform: restart
348 name: "${friendly_name} Restart"
349
350light:
351 - platform: esp32_rmt_led_strip
352 chipset: WS2811
353 rgb_order: GRB
354 pin: ${led_pin}
355 num_leds: 28
356 name: "NeoPixel Light"
357 id: leds
358 default_transition_length: 0s
359 effects:
360 - addressable_rainbow:
361 name: "Rainbow"
362 speed: 30
363 width: 8
364 - pulse:
365 name: "Pulse"
366 transition_length: 1.4s
367 update_interval: 1s
368
369 on_turn_off:
370 then:
371 - script.execute: refresh_led_default
372
373 - platform: partition
374 name: "LEDs Button right"
375 id: leds_button_right
376 internal: true
377 segments:
378 - id: leds
379 from: 7
380 to: 7
381 - platform: partition
382 name: "LEDs Button middle"
383 id: leds_button_middle
384 internal: true
385 segments:
386 - id: leds
387 from: 9
388 to: 9
389 - platform: partition
390 name: "LEDs Button left"
391 id: leds_button_left
392 internal: true
393 segments:
394 - id: leds
395 from: 11
396 to: 11
397
398 - platform: partition
399 name: "LEDs Nightlight"
400 id: leds_nightlight
401 internal: true
402 segments:
403 - id: leds
404 from: 0
405 to: 6
406 - id: leds
407 from: 8
408 to: 8
409 - id: leds
410 from: 10
411 to: 10
412 - id: leds
413 from: 12
414 to: 19
415 - id: leds
416 from: 27
417 to: 27
418 - id: leds_top
419 from: 0
420 to: 6
421
422 - platform: partition
423 name: "LEDs Top"
424 id: leds_top
425 internal: true
426 segments:
427 - id: leds
428 from: 20
429 to: 26
430 effects:
431 - addressable_scan:
432 name: "Scan"
433 - addressable_rainbow:
434 name: "Rainbow"
435 speed: 10
436 width: 20
437
438i2s_audio:
439 id: audio_i2s
440 i2s_lrclk_pin: ${audio_lrclk_pin}
441 i2s_bclk_pin: ${audio_bclk_pin}
442
443speaker:
444 - platform: i2s_audio
445 id: media_out
446 dac_type: external
447 i2s_dout_pin: ${audio_sdata_pin}
448 i2s_audio_id: audio_i2s
449 i2s_comm_fmt: i2s_lsb
450 channel: mono
451
452uart:
453 tx_pin: ${uart_tx_pin}
454 rx_pin: ${uart_rx_pin}
455 id: my_uart
456 baud_rate: 115200
457 data_bits: 8
458 stop_bits: 1
459 parity: NONE
460 debug:
461 direction: RX
462 dummy_receiver: false
463 after:
464 timeout: 2s
465 bytes: 2048
466 sequence:
467 - lambda: UARTDebug::log_hex(direction, bytes, ' ');
468
469tx_ultimate_touch:
470 id: tx_touch
471 uart: my_uart
472
473 on_press:
474 - script.execute: led_on_touch
475 - lambda: >
476 ESP_LOGD("tx_ultimate_touch.on_press", "Touch Position: %d / State: %d", touch.x, touch.state);
477
478 on_release:
479 - script.execute:
480 id: handle_release
481 pos: !lambda "return touch.x;"
482
483 - switch.turn_on: vibra
484
485 - lambda: >
486 ESP_LOGD("tx_ultimate_touch.on_release", "Release Position: %d / State: %d", touch.x, touch.state);
487
488 on_swipe_left:
489 - script.execute: led_on_swipe_left
490
491 - switch.turn_on: vibra
492
493 - binary_sensor.template.publish:
494 id: swipe_left
495 state: ON
496
497 - lambda: >
498 ESP_LOGD("tx_ultimate_touch.on_swipe_left", "Swipe Left Position: %d / State: %d", touch.x, touch.state);
499
500 on_swipe_right:
501 - script.execute: led_on_swipe_right
502
503 - switch.turn_on: vibra
504
505 - binary_sensor.template.publish:
506 id: swipe_right
507 state: ON
508
509 - lambda: >
510 ESP_LOGD("tx_ultimate_touch.on_swipe_right", "Swipe Right Position: %d / State: %d", touch.x, touch.state);
511
512 on_full_touch_release:
513 - script.execute: led_on_full_touch
514
515 - switch.turn_on: vibra
516
517 - binary_sensor.template.publish:
518 id: multi_touch
519 state: ON
520
521 - lambda: >
522 ESP_LOGD("tx_ultimate_touch.on_full_touch_release", "Full Touch Release Position: %d / State: %d", touch.x, touch.state);
523
524 on_long_touch_release:
525 - script.execute: led_on_long_touch
526
527 - switch.turn_on: vibra
528
529 - binary_sensor.template.publish:
530 id: long_press
531 state: ON
532
533 - lambda: >
534 ESP_LOGD("tx_ultimate_touch.on_long_touch_release", "Long Touch Release Position: %d / State: %d", touch.x, touch.state);
535
536time:
537 - platform: homeassistant
538 id: homeassistant_time
539 - platform: sntp
540 id: sntp_time
541 on_time:
542 # Every 5 minutes
543 - seconds: 0
544 minutes: /5
545 then:
546 - script.execute: refresh_nightlight
547
548sun:
549 latitude: ${latitude}
550 longitude: ${longitude}
551
552
553script:
554 - id: refresh_nightlight
555 mode: restart
556 then:
557 - if:
558 condition:
559 lambda: 'return "${nightlight}" == "on";'
560 then:
561 - if:
562 condition:
563 - sun.is_below_horizon:
564 then:
565 - switch.turn_on:
566 id: nightlight
567 else:
568 - switch.turn_off:
569 id: nightlight
570
571 - id: refresh_led_default
572 mode: restart
573 then:
574 - if:
575 condition:
576 lambda: "return (${relay_count}>1 && id(relay_1).state) ;"
577 then:
578 - script.execute: led_on_button_left
579 else:
580 - script.execute: led_off_button_left
581
582 - if:
583 condition:
584 lambda: "return (${relay_count}==3 && id(relay_2).state) || (${relay_count}==1 && id(relay_1).state);"
585 then:
586 - script.execute: led_on_button_middle
587 else:
588 - script.execute: led_off_button_middle
589
590 - if:
591 condition:
592 lambda: "return (${relay_count}==2 && id(relay_2).state) || (${relay_count}==3 && id(relay_3).state);"
593 then:
594 - script.execute: led_on_button_right
595 else:
596 - script.execute: led_off_button_right
597
598 - if:
599 condition:
600 lambda: "return id(nightlight).state || id(nightlight_active).state;"
601 then:
602 - light.turn_on:
603 id: leds_top
604 brightness: ${nightlight_brightness}
605 red: !lambda "return id(nightlight_color)[0]/100.0;"
606 green: !lambda "return id(nightlight_color)[1]/100.0;"
607 blue: !lambda "return id(nightlight_color)[2]/100.0;"
608 effect: "None"
609 - script.execute: led_on_nightlight
610 else:
611 - light.turn_off:
612 id: leds_top
613 - light.turn_off: leds_nightlight
614
615 - id: led_on_button_left
616 mode: restart
617 then:
618 - light.turn_on:
619 id: leds_button_left
620 brightness: ${button_brightness}
621 red: !lambda "return id(button_color)[0]/100.0;"
622 green: !lambda "return id(button_color)[1]/100.0;"
623 blue: !lambda "return id(button_color)[2]/100.0;"
624
625 - id: led_on_button_middle
626 mode: restart
627 then:
628 - light.turn_on:
629 id: leds_button_middle
630 brightness: ${button_brightness}
631 red: !lambda "return id(button_color)[0]/100.0;"
632 green: !lambda "return id(button_color)[1]/100.0;"
633 blue: !lambda "return id(button_color)[2]/100.0;"
634
635 - id: led_on_button_right
636 mode: restart
637 then:
638 - light.turn_on:
639 id: leds_button_right
640 brightness: ${button_brightness}
641 red: !lambda "return id(button_color)[0]/100.0;"
642 green: !lambda "return id(button_color)[1]/100.0;"
643 blue: !lambda "return id(button_color)[2]/100.0;"
644
645
646 - id: led_off_button_left
647 mode: restart
648 then:
649 - if:
650 condition:
651 lambda: "return id(nightlight).state || id(nightlight_active).state;"
652 then:
653 - light.turn_on:
654 id: leds_button_left
655 brightness: ${nightlight_brightness}
656 red: !lambda "return id(nightlight_color)[0]/100.0;"
657 green: !lambda "return id(nightlight_color)[1]/100.0;"
658 blue: !lambda "return id(nightlight_color)[2]/100.0;"
659 else:
660 - light.turn_off:
661 id: leds_button_left
662
663 - id: led_off_button_middle
664 mode: restart
665 then:
666 - if:
667 condition:
668 lambda: "return id(nightlight).state || id(nightlight_active).state;"
669 then:
670 - light.turn_on:
671 id: leds_button_middle
672 brightness: ${nightlight_brightness}
673 red: !lambda "return id(nightlight_color)[0]/100.0;"
674 green: !lambda "return id(nightlight_color)[1]/100.0;"
675 blue: !lambda "return id(nightlight_color)[2]/100.0;"
676 else:
677 - light.turn_off:
678 id: leds_button_middle
679
680
681 - id: led_off_button_right
682 mode: restart
683 then:
684 - if:
685 condition:
686 lambda: "return id(nightlight).state || id(nightlight_active).state;"
687 then:
688 - light.turn_on:
689 id: leds_button_right
690 brightness: ${nightlight_brightness}
691 red: !lambda "return id(nightlight_color)[0]/100.0;"
692 green: !lambda "return id(nightlight_color)[1]/100.0;"
693 blue: !lambda "return id(nightlight_color)[2]/100.0;"
694 else:
695 - light.turn_off:
696 id: leds_button_right
697
698
699 - id: led_on_nightlight
700 mode: restart
701 then:
702 - light.turn_on:
703 id: leds_nightlight
704 brightness: ${nightlight_brightness}
705 red: !lambda "return id(nightlight_color)[0]/100.0;"
706 green: !lambda "return id(nightlight_color)[1]/100.0;"
707 blue: !lambda "return id(nightlight_color)[2]/100.0;"
708
709 - id: led_on_release
710 mode: restart
711 then:
712 - light.turn_off:
713 id: leds
714 - script.execute: refresh_led_default
715
716 - id: led_on_touch
717 mode: restart
718 then:
719 - light.turn_on:
720 id: leds_top
721 brightness: ${touch_brightness}
722 red: !lambda "return id(touch_color)[0]/100.0;"
723 green: !lambda "return id(touch_color)[1]/100.0;"
724 blue: !lambda "return id(touch_color)[2]/100.0;"
725 effect: ${touch_effect}
726 - delay: 6s
727 - script.execute: refresh_led_default
728
729 - id: led_on_swipe_left
730 mode: restart
731 then:
732 - light.turn_on:
733 id: leds_top
734 brightness: ${swipe_left_brightness}
735 red: !lambda "return id(swipe_left_color)[0]/100.0;"
736 green: !lambda "return id(swipe_left_color)[1]/100.0;"
737 blue: !lambda "return id(swipe_left_color)[2]/100.0;"
738 effect: ${swipe_left_effect}
739
740 - id: led_on_swipe_right
741 mode: restart
742 then:
743 - light.turn_on:
744 id: leds_top
745 brightness: ${swipe_right_brightness}
746 red: !lambda "return id(swipe_right_color)[0]/100.0;"
747 green: !lambda "return id(swipe_right_color)[1]/100.0;"
748 blue: !lambda "return id(swipe_right_color)[2]/100.0;"
749 effect: ${swipe_right_effect}
750
751 - id: led_on_full_touch
752 mode: restart
753 then:
754 - light.turn_on:
755 id: leds_top
756 brightness: ${multi_touch_brightness}
757 red: !lambda "return id(multi_touch_color)[0]/100.0;"
758 green: !lambda "return id(multi_touch_color)[1]/100.0;"
759 blue: !lambda "return id(multi_touch_color)[2]/100.0;"
760 effect: ${multi_touch_effect}
761
762
763 - id: led_on_long_touch
764 mode: restart
765 then:
766 - light.turn_on:
767 id: leds_top
768 brightness: ${long_press_brightness}
769 red: !lambda "return id(long_press_color)[0]/100.0;"
770 green: !lambda "return id(long_press_color)[1]/100.0;"
771 blue: !lambda "return id(long_press_color)[2]/100.0;"
772 effect: ${long_press_effect}
773
774
775 - id: handle_release
776 mode: restart
777 parameters:
778 pos: int
779 then:
780 - if:
781 condition:
782 lambda: "return ${relay_count}==1;"
783 then:
784 - binary_sensor.template.publish:
785 id: touchfield_1
786 state: ON
787
788 - if:
789 condition:
790 lambda: "return ${relay_count}==2;"
791 then:
792 - if:
793 condition:
794 lambda: "return pos <= 5;"
795 then:
796 - binary_sensor.template.publish:
797 id: touchfield_1
798 state: ON
799
800 else:
801 - binary_sensor.template.publish:
802 id: touchfield_2
803 state: ON
804
805 - if:
806 condition:
807 lambda: "return ${relay_count}==3;"
808 then:
809 - if:
810 condition:
811 lambda: "return pos <= 3;"
812 then:
813 - binary_sensor.template.publish:
814 id: touchfield_1
815 state: ON
816
817 else:
818 - if:
819 condition:
820 lambda: "return pos <= 7;"
821 then:
822 - binary_sensor.template.publish:
823 id: touchfield_2
824 state: ON
825
826 else:
827 - binary_sensor.template.publish:
828 id: touchfield_3
829 state: ON
830
831 - id: touch_led_marker
832 mode: restart
833 parameters:
834 state: int
835 pos: int
836 then:
837 - if:
838 condition:
839 lambda: "return state==1;"
840 then:
841 # RELEASE
842 - light.turn_off: leds
843
844 else:
845 - if:
846 condition:
847 lambda: "return state==2;"
848 then:
849 # TOUCH
850 - light.turn_on:
851 id: leds
852 red: 1
853 green: 0
854 blue: 0
855 - delay: 6s
856 - light.turn_off: leds
857
858 else:
859 - if:
860 condition:
861 lambda: "return state==11;"
862 then:
863 # FULL-TOUCH RELEASE
864 - light.turn_on:
865 id: leds
866 effect: "Rainbow"
867 - delay: 1s
868 - light.turn_off: leds
869
870 else:
871 # SWIPE
872 - if:
873 condition:
874 lambda: "return state==13;"
875 then:
876 # SWIPE LEFT
877 - light.turn_on:
878 id: leds
879 red: 0
880 green: 1
881 blue: 0
882
883 - if:
884 condition:
885 lambda: "return state==12;"
886 then:
887 # SWIPE RIGHT
888 - light.turn_on:
889 id: leds
890 red: 0
891 green: 0
892 blue: 1
893 - delay: 1s
894 - light.turn_off: leds