From 25bcc2fd53d529557cb85d465d4826782c36b5c7 Mon Sep 17 00:00:00 2001 From: Sebastian Sellmeier Date: Fri, 16 Aug 2024 09:10:26 +0200 Subject: [PATCH] yamlfmt: Fix all files --- tx_ultimate.yaml | 143 +++----------------- tx_ultimate_2x_cover_us.yaml | 152 ++-------------------- tx_ultimate_cover.yaml | 132 ++----------------- tx_ultimate_cover_and_2x_switches_us.yaml | 137 ++----------------- tx_ultimate_cover_us.yaml | 132 ++----------------- tx_ultimate_local.yaml | 143 +++----------------- tx_ultimate_local_us.yaml | 151 +++------------------ tx_ultimate_us.yaml | 150 +++------------------ 8 files changed, 110 insertions(+), 1030 deletions(-) diff --git a/tx_ultimate.yaml b/tx_ultimate.yaml index a3e02eb..d5c6b20 100644 --- a/tx_ultimate.yaml +++ b/tx_ultimate.yaml @@ -1,74 +1,54 @@ substitutions: name: "shys-tx-ultimate" friendly_name: "TX Ultimate" - relay_count: "2" - toggle_relay_1_on_touch: "true" toggle_relay_2_on_touch: "true" toggle_relay_3_on_touch: "true" - vibra_time: 150ms button_on_time: 500ms - button_brightness: "0.7" button_color: "{0,0,100}" - nightlight: "on" nightlight_brightness: "0.2" nightlight_color: "{80,70,0}" - latitude: "50.123456°" longitude: "5.654321°" - touch_brightness: "1" touch_color: "{0,100,100}" touch_effect: "Scan" - long_press_brightness: "1" long_press_color: "{100,0,0}" long_press_effect: "" - multi_touch_brightness: "1" multi_touch_color: "{0,0,0}" multi_touch_effect: "Rainbow" - swipe_left_brightness: "1" swipe_left_color: "{0,100,0}" swipe_left_effect: "" - swipe_right_brightness: "1" swipe_right_color: "{100,0,70}" swipe_right_effect: "" - relay_1_pin: GPIO18 relay_2_pin: GPIO17 relay_3_pin: GPIO27 relay_4_pin: GPIO23 - vibra_motor_pin: GPIO21 pa_power_pin: GPIO26 - led_pin: GPIO13 status_led_pin: GPIO33 - uart_tx_pin: GPIO19 uart_rx_pin: GPIO22 - audio_lrclk_pin: GPIO4 audio_bclk_pin: GPIO2 audio_sdata_pin: GPIO15 - touchpanel_power_pin: GPIO5 - - esphome: name: ${name} friendly_name: ${friendly_name} project: name: smarthomeyourself.tx_ultimate version: "1.0" - on_boot: priority: -100 then: @@ -95,14 +75,12 @@ esphome: state: OFF - script.execute: refresh_led_default - script.execute: refresh_nightlight - esp32: board: esp32dev framework: type: arduino - logger: -# hardware_uart: UART2 + # hardware_uart: UART2 level: DEBUG logs: binary_sensor: INFO @@ -111,34 +89,24 @@ logger: switch: INFO tx_ultimate_touch: INFO uart_debug: INFO - dashboard_import: package_import_url: github://SmartHome-yourself/sonoff-tx-ultimate-for-esphome/tx_ultimate.yaml@main import_full_config: false - api: - ota: - - platform: esphome - + - platform: esphome wifi: ap: password: "12345678" - improv_serial: - captive_portal: - external_components: -# - source: /config/esphome/my_components + # - source: /config/esphome/my_components - source: type: git url: https://github.com/SmartHome-yourself/sonoff-tx-ultimate-for-esphome ref: main components: [tx_ultimate_touch] - - - globals: - id: nightlight_color type: int [3] @@ -167,10 +135,7 @@ globals: - id: touch_color type: int [3] restore_value: no - initial_value: ${touch_color} - - - + initial_value: ${touch_color} binary_sensor: - platform: template name: "Touchfield 1" @@ -186,7 +151,6 @@ binary_sensor: id: touchfield_1 state: OFF - script.execute: refresh_led_default - - platform: template name: "Touchfield 2" id: touchfield_2 @@ -201,7 +165,6 @@ binary_sensor: id: touchfield_2 state: OFF - script.execute: refresh_led_default - - platform: template name: "Touchfield 3" id: touchfield_3 @@ -216,7 +179,6 @@ binary_sensor: id: touchfield_3 state: OFF - script.execute: refresh_led_default - - platform: template name: "Swipe left" id: swipe_left @@ -226,7 +188,6 @@ binary_sensor: id: swipe_left state: OFF - script.execute: refresh_led_default - - platform: template name: "Swipe_right" id: swipe_right @@ -236,7 +197,6 @@ binary_sensor: id: swipe_right state: OFF - script.execute: refresh_led_default - - platform: template name: "Multi Touch" id: multi_touch @@ -246,7 +206,6 @@ binary_sensor: id: multi_touch state: OFF - script.execute: refresh_led_default - - platform: template name: "Long Press" id: long_press @@ -256,7 +215,6 @@ binary_sensor: id: long_press state: OFF - script.execute: refresh_led_default - switch: - platform: gpio id: relay_1 @@ -269,7 +227,6 @@ switch: on_turn_off: then: - script.execute: refresh_led_default - - platform: gpio id: relay_2 name: "${friendly_name} L2" @@ -281,7 +238,6 @@ switch: on_turn_off: then: - script.execute: refresh_led_default - - platform: gpio id: relay_3 name: "${friendly_name} L3" @@ -293,7 +249,6 @@ switch: on_turn_off: then: - script.execute: refresh_led_default - - platform: gpio id: vibra pin: ${vibra_motor_pin} @@ -302,14 +257,12 @@ switch: on_turn_on: - delay: ${vibra_time} - switch.turn_off: vibra - - platform: gpio id: pa_power pin: ${pa_power_pin} name: "PA Power" internal: true restore_mode: ALWAYS_ON - - platform: gpio name: "touch panel power" pin: @@ -318,7 +271,6 @@ switch: id: touch_power internal: true restore_mode: RESTORE_DEFAULT_ON - - platform: template name: "Nightlight" id: nightlight @@ -331,7 +283,6 @@ switch: on_turn_off: then: - script.execute: refresh_led_default - - platform: template name: "Nightlight" id: nightlight_active @@ -343,10 +294,8 @@ switch: on_turn_off: then: - script.execute: refresh_led_default - - platform: restart name: "${friendly_name} Restart" - light: - platform: neopixelbus type: GRB @@ -365,11 +314,9 @@ light: name: "Pulse" transition_length: 1.4s update_interval: 1s - on_turn_off: then: - script.execute: refresh_led_default - - platform: partition name: "LEDs Button right" id: leds_button_right @@ -394,7 +341,6 @@ light: - id: leds from: 11 to: 11 - - platform: partition name: "LEDs Nightlight" id: leds_nightlight @@ -418,7 +364,6 @@ light: - id: leds_top from: 0 to: 6 - - platform: partition name: "LEDs Top" id: leds_top @@ -434,7 +379,6 @@ light: name: "Rainbow" speed: 10 width: 20 - media_player: - platform: i2s_audio id: media_out @@ -444,12 +388,10 @@ media_player: i2s_audio_id: audio_i2s i2s_comm_fmt: lsb mode: mono - i2s_audio: id: audio_i2s i2s_lrclk_pin: ${audio_lrclk_pin} i2s_bclk_pin: ${audio_bclk_pin} - uart: tx_pin: ${uart_tx_pin} rx_pin: ${uart_rx_pin} @@ -466,11 +408,9 @@ uart: bytes: 2048 sequence: - lambda: UARTDebug::log_hex(direction, bytes, ' '); - tx_ultimate_touch: id: tx_touch uart: my_uart - on_press: - script.execute: led_on_touch - lambda: > @@ -480,57 +420,43 @@ tx_ultimate_touch: - script.execute: id: handle_release pos: !lambda "return touch.x;" - - switch.turn_on: vibra - - lambda: > ESP_LOGD("tx_ultimate_touch.on_release", "Release Position: %d / State: %d", touch.x, touch.state); on_swipe_left: - script.execute: led_on_swipe_left - - switch.turn_on: vibra - - binary_sensor.template.publish: id: swipe_left state: ON - - lambda: > ESP_LOGD("tx_ultimate_touch.on_swipe_left", "Swipe Left Position: %d / State: %d", touch.x, touch.state); on_swipe_right: - script.execute: led_on_swipe_right - - switch.turn_on: vibra - - binary_sensor.template.publish: id: swipe_right state: ON - - lambda: > ESP_LOGD("tx_ultimate_touch.on_swipe_right", "Swipe Right Position: %d / State: %d", touch.x, touch.state); on_full_touch_release: - script.execute: led_on_full_touch - - switch.turn_on: vibra - - binary_sensor.template.publish: id: multi_touch state: ON - - lambda: > ESP_LOGD("tx_ultimate_touch.on_full_touch_release", "Full Touch Release Position: %d / State: %d", touch.x, touch.state); on_long_touch_release: - script.execute: led_on_long_touch - - switch.turn_on: vibra - - binary_sensor.template.publish: id: long_press state: ON - - lambda: > ESP_LOGD("tx_ultimate_touch.on_long_touch_release", "Long Touch Release Position: %d / State: %d", touch.x, touch.state); @@ -545,12 +471,9 @@ time: minutes: /5 then: - script.execute: refresh_nightlight - sun: latitude: ${latitude} longitude: ${longitude} - - script: - id: refresh_nightlight mode: restart @@ -568,12 +491,10 @@ script: else: - switch.turn_off: id: nightlight - - id: refresh_led_default mode: restart then: - light.turn_off: leds_top - - if: condition: lambda: "return (${relay_count}>1 && id(relay_1).state) ;" @@ -581,7 +502,6 @@ script: - script.execute: led_on_button_left else: - script.execute: led_off_button_left - - if: condition: lambda: "return (${relay_count}==3 && id(relay_2).state) || (${relay_count}==1 && id(relay_1).state);" @@ -589,7 +509,6 @@ script: - script.execute: led_on_button_middle else: - script.execute: led_off_button_middle - - if: condition: lambda: "return (${relay_count}==2 && id(relay_2).state) || (${relay_count}==3 && id(relay_3).state);" @@ -597,7 +516,6 @@ script: - script.execute: led_on_button_right else: - script.execute: led_off_button_right - - if: condition: lambda: "return id(nightlight).state || id(nightlight_active).state;" @@ -605,7 +523,6 @@ script: - script.execute: led_on_nightlight else: - light.turn_off: leds_nightlight - - id: led_on_button_left mode: restart then: @@ -614,8 +531,7 @@ script: brightness: ${button_brightness} red: !lambda "return id(button_color)[0]/100.0;" green: !lambda "return id(button_color)[1]/100.0;" - blue: !lambda "return id(button_color)[2]/100.0;" - + blue: !lambda "return id(button_color)[2]/100.0;" - id: led_on_button_middle mode: restart then: @@ -624,8 +540,7 @@ script: brightness: ${button_brightness} red: !lambda "return id(button_color)[0]/100.0;" green: !lambda "return id(button_color)[1]/100.0;" - blue: !lambda "return id(button_color)[2]/100.0;" - + blue: !lambda "return id(button_color)[2]/100.0;" - id: led_on_button_right mode: restart then: @@ -634,9 +549,7 @@ script: brightness: ${button_brightness} red: !lambda "return id(button_color)[0]/100.0;" green: !lambda "return id(button_color)[1]/100.0;" - blue: !lambda "return id(button_color)[2]/100.0;" - - + blue: !lambda "return id(button_color)[2]/100.0;" - id: led_off_button_left mode: restart then: @@ -649,11 +562,10 @@ script: brightness: ${nightlight_brightness} red: !lambda "return id(nightlight_color)[0]/100.0;" green: !lambda "return id(nightlight_color)[1]/100.0;" - blue: !lambda "return id(nightlight_color)[2]/100.0;" + blue: !lambda "return id(nightlight_color)[2]/100.0;" else: - light.turn_off: id: leds_button_left - - id: led_off_button_middle mode: restart then: @@ -666,12 +578,10 @@ script: brightness: ${nightlight_brightness} red: !lambda "return id(nightlight_color)[0]/100.0;" green: !lambda "return id(nightlight_color)[1]/100.0;" - blue: !lambda "return id(nightlight_color)[2]/100.0;" + blue: !lambda "return id(nightlight_color)[2]/100.0;" else: - light.turn_off: id: leds_button_middle - - - id: led_off_button_right mode: restart then: @@ -684,12 +594,10 @@ script: brightness: ${nightlight_brightness} red: !lambda "return id(nightlight_color)[0]/100.0;" green: !lambda "return id(nightlight_color)[1]/100.0;" - blue: !lambda "return id(nightlight_color)[2]/100.0;" + blue: !lambda "return id(nightlight_color)[2]/100.0;" else: - light.turn_off: id: leds_button_right - - - id: led_on_nightlight mode: restart then: @@ -698,14 +606,12 @@ script: brightness: ${nightlight_brightness} red: !lambda "return id(nightlight_color)[0]/100.0;" green: !lambda "return id(nightlight_color)[1]/100.0;" - blue: !lambda "return id(nightlight_color)[2]/100.0;" - + blue: !lambda "return id(nightlight_color)[2]/100.0;" - id: led_on_release mode: restart then: - light.turn_off: id: leds_top - - id: led_on_touch mode: restart then: @@ -714,11 +620,10 @@ script: brightness: ${touch_brightness} red: !lambda "return id(touch_color)[0]/100.0;" green: !lambda "return id(touch_color)[1]/100.0;" - blue: !lambda "return id(touch_color)[2]/100.0;" + blue: !lambda "return id(touch_color)[2]/100.0;" effect: ${touch_effect} - delay: 6s - script.execute: refresh_led_default - - id: led_on_swipe_left mode: restart then: @@ -727,9 +632,8 @@ script: brightness: ${swipe_left_brightness} red: !lambda "return id(swipe_left_color)[0]/100.0;" green: !lambda "return id(swipe_left_color)[1]/100.0;" - blue: !lambda "return id(swipe_left_color)[2]/100.0;" + blue: !lambda "return id(swipe_left_color)[2]/100.0;" effect: ${swipe_left_effect} - - id: led_on_swipe_right mode: restart then: @@ -738,9 +642,8 @@ script: brightness: ${swipe_right_brightness} red: !lambda "return id(swipe_right_color)[0]/100.0;" green: !lambda "return id(swipe_right_color)[1]/100.0;" - blue: !lambda "return id(swipe_right_color)[2]/100.0;" + blue: !lambda "return id(swipe_right_color)[2]/100.0;" effect: ${swipe_right_effect} - - id: led_on_full_touch mode: restart then: @@ -749,10 +652,8 @@ script: brightness: ${multi_touch_brightness} red: !lambda "return id(multi_touch_color)[0]/100.0;" green: !lambda "return id(multi_touch_color)[1]/100.0;" - blue: !lambda "return id(multi_touch_color)[2]/100.0;" + blue: !lambda "return id(multi_touch_color)[2]/100.0;" effect: ${multi_touch_effect} - - - id: led_on_long_touch mode: restart then: @@ -761,10 +662,8 @@ script: brightness: ${long_press_brightness} red: !lambda "return id(long_press_color)[0]/100.0;" green: !lambda "return id(long_press_color)[1]/100.0;" - blue: !lambda "return id(long_press_color)[2]/100.0;" + blue: !lambda "return id(long_press_color)[2]/100.0;" effect: ${long_press_effect} - - - id: handle_release mode: restart parameters: @@ -777,7 +676,6 @@ script: - binary_sensor.template.publish: id: touchfield_1 state: ON - - if: condition: lambda: "return ${relay_count}==2;" @@ -789,12 +687,10 @@ script: - binary_sensor.template.publish: id: touchfield_1 state: ON - else: - binary_sensor.template.publish: id: touchfield_2 state: ON - - if: condition: lambda: "return ${relay_count}==3;" @@ -806,7 +702,6 @@ script: - binary_sensor.template.publish: id: touchfield_1 state: ON - else: - if: condition: @@ -815,12 +710,10 @@ script: - binary_sensor.template.publish: id: touchfield_2 state: ON - else: - binary_sensor.template.publish: id: touchfield_3 state: ON - - id: touch_led_marker mode: restart parameters: @@ -833,7 +726,6 @@ script: then: # RELEASE - light.turn_off: leds - else: - if: condition: @@ -847,7 +739,6 @@ script: blue: 0 - delay: 6s - light.turn_off: leds - else: - if: condition: @@ -859,7 +750,6 @@ script: effect: "Rainbow" - delay: 1s - light.turn_off: leds - else: # SWIPE - if: @@ -872,7 +762,6 @@ script: red: 0 green: 1 blue: 0 - - if: condition: lambda: "return state==12;" diff --git a/tx_ultimate_2x_cover_us.yaml b/tx_ultimate_2x_cover_us.yaml index 9c42217..ca330c8 100644 --- a/tx_ultimate_2x_cover_us.yaml +++ b/tx_ultimate_2x_cover_us.yaml @@ -1,90 +1,67 @@ substitutions: name: "shys-tx-ultimate-cover" friendly_name: "TX Ultimate Cover" - relay_count: "4" # Needs at least 4 relays - cover_1_name: "My Cover 1" cover_1_open_duration: 25s cover_1_close_duration: 25s - cover_1_brightness: "0.7" - cover_1_color1: "{0,255,0}" #open - cover_1_color2: "{255,0,0}" #close - + cover_1_color1: "{0,255,0}" #open + cover_1_color2: "{255,0,0}" #close cover_2_name: "My Cover 2" cover_2_open_duration: 25s cover_2_close_duration: 25s - cover_2_brightness: "0.7" - cover_2_color1: "{0,255,0}" #open - cover_2_color2: "{255,0,0}" #close - + cover_2_color1: "{0,255,0}" #open + cover_2_color2: "{255,0,0}" #close vibra_time: 150ms button_on_time: 500ms - button_brightness: "0.7" button_color: "{0,0,100}" - nightlight: "on" nightlight_brightness: "0.2" nightlight_color: "{80,70,0}" - latitude: "51.132241°" longitude: "7.178795°" - touch_brightness: "1" touch_color: "{0,100,100}" touch_effect: "Scan" - boot_brightness: "0.7" boot_color1: "{100,0,0}" boot_color2: "{100,100,0}" boot_effect: "Scan" - long_press_brightness: "1" long_press_color: "{100,0,0}" long_press_effect: "" - multi_touch_brightness: "1" multi_touch_color: "{0,0,0}" multi_touch_effect: "Rainbow" - swipe_left_brightness: "1" swipe_left_color: "{0,100,0}" swipe_left_effect: "Pulse" - swipe_right_brightness: "1" swipe_right_color: "{100,0,70}" swipe_right_effect: "Pulse" - relay_1_pin: GPIO18 relay_2_pin: GPIO17 relay_3_pin: GPIO27 relay_4_pin: GPIO23 - vibra_motor_pin: GPIO21 pa_power_pin: GPIO26 - led_pin: GPIO13 status_led_pin: GPIO33 - uart_tx_pin: GPIO19 uart_rx_pin: GPIO22 - audio_lrclk_pin: GPIO4 audio_bclk_pin: GPIO2 audio_sdata_pin: GPIO15 - touchpanel_power_pin: GPIO5 - esphome: name: ${name} friendly_name: ${friendly_name} project: name: smarthomeyourself.tx_ultimate_2x_cover version: "1.0" - on_boot: priority: 700 #-100 then: @@ -110,7 +87,6 @@ esphome: condition: api.connected: timeout: 10s - - binary_sensor.template.publish: id: touchfield_1 state: OFF @@ -145,12 +121,10 @@ esphome: id: leds_right brightness: !lambda "return id(nightlight).state?${nightlight_brightness}:${cover_2_brightness};" effect: "Cover Position" - esp32: board: esp32dev framework: type: arduino - logger: # hardware_uart: UART2 level: DEBUG @@ -161,33 +135,24 @@ logger: switch: INFO tx_ultimate_touch: INFO uart_debug: INFO - dashboard_import: package_import_url: github://SmartHome-yourself/sonoff-tx-ultimate-for-esphome/tx_ultimate_cover.yaml@main import_full_config: false - api: - ota: - - platform: esphome - + - platform: esphome wifi: ap: password: "12345678" - improv_serial: - captive_portal: - external_components: -# - source: /config/esphome/my_components + # - source: /config/esphome/my_components - source: type: git url: https://github.com/SmartHome-yourself/sonoff-tx-ultimate-for-esphome ref: main components: [tx_ultimate_touch] - - globals: - id: nightlight_color type: int [3] @@ -241,20 +206,17 @@ globals: type: int [3] restore_value: no initial_value: ${cover_2_color2} - binary_sensor: - platform: template name: "Touchfield 1" id: touchfield_1 on_press: - script.execute: cover_1_open_action - - delay: ${button_on_time} - binary_sensor.template.publish: id: touchfield_1 state: OFF - script.execute: refresh_led_default - - platform: template name: "Touchfield 2" id: touchfield_2 @@ -265,7 +227,6 @@ binary_sensor: id: touchfield_2 state: OFF - script.execute: refresh_led_default - - platform: template name: "Touchfield 3" id: touchfield_3 @@ -276,7 +237,6 @@ binary_sensor: id: touchfield_3 state: OFF - script.execute: refresh_led_default - - platform: template name: "Touchfield 4" id: touchfield_4 @@ -287,7 +247,6 @@ binary_sensor: id: touchfield_4 state: OFF - script.execute: refresh_led_default - - platform: template name: "Swipe left" id: swipe_left @@ -297,7 +256,6 @@ binary_sensor: id: swipe_left state: OFF - script.execute: refresh_led_default - - platform: template name: "Swipe_right" id: swipe_right @@ -307,7 +265,6 @@ binary_sensor: id: swipe_right state: OFF - script.execute: refresh_led_default - - platform: template name: "Multi Touch" id: multi_touch @@ -317,7 +274,6 @@ binary_sensor: id: multi_touch state: OFF - script.execute: refresh_led_default - - platform: template name: "Long Press" id: long_press @@ -327,7 +283,6 @@ binary_sensor: id: long_press state: OFF - script.execute: refresh_led_default - switch: - platform: gpio id: relay_1 @@ -342,7 +297,6 @@ switch: on_turn_off: then: - script.execute: refresh_led_default - - platform: gpio id: relay_2 name: "${friendly_name} L2" @@ -356,7 +310,6 @@ switch: on_turn_off: then: - script.execute: refresh_led_default - - platform: gpio id: relay_3 name: "${friendly_name} L3" @@ -370,7 +323,6 @@ switch: on_turn_off: then: - script.execute: refresh_led_default - - platform: gpio id: relay_4 name: "${friendly_name} L4" @@ -384,7 +336,6 @@ switch: on_turn_off: then: - script.execute: refresh_led_default - - platform: gpio id: vibra pin: ${vibra_motor_pin} @@ -393,14 +344,12 @@ switch: on_turn_on: - delay: ${vibra_time} - switch.turn_off: vibra - - platform: gpio id: pa_power pin: ${pa_power_pin} name: "PA Power" internal: true restore_mode: ALWAYS_ON - - platform: gpio name: "touch panel power" pin: @@ -409,7 +358,6 @@ switch: id: touch_power internal: true restore_mode: RESTORE_DEFAULT_ON - - platform: template name: "Nightlight" id: nightlight @@ -422,7 +370,6 @@ switch: on_turn_off: then: - script.execute: refresh_led_default - - platform: template name: "Nightlight" id: nightlight_active @@ -434,10 +381,8 @@ switch: on_turn_off: then: - script.execute: refresh_led_default - - platform: restart name: "${friendly_name} Restart" - light: - platform: neopixelbus type: GRB @@ -456,11 +401,9 @@ light: name: "Pulse" transition_length: 1.4s update_interval: 1s - on_turn_off: then: - script.execute: refresh_led_default - - platform: partition name: "LEDs Button right" id: leds_button_right @@ -488,7 +431,6 @@ light: - id: leds from: 25 to: 30 - - platform: partition name: "LEDs Nightlight" id: leds_nightlight @@ -497,7 +439,6 @@ light: - id: leds from: 0 to: 31 - - platform: partition name: "LEDs Top" id: leds_top @@ -516,7 +457,6 @@ light: name: "Rainbow" speed: 10 width: 20 - - platform: partition name: "LEDs Left" id: leds_left @@ -539,7 +479,6 @@ light: if (pos < 7){ it.range(0, 7-pos) = ESPColor(id(cover_1_color2)[0],id(cover_1_color2)[1],id(cover_1_color2)[2]); } - - platform: partition name: "LEDs Right" id: leds_right @@ -562,7 +501,6 @@ light: if (pos < 7){ it.range(0, 7-pos) = ESPColor(id(cover_2_color2)[0],id(cover_2_color2)[1],id(cover_2_color2)[2]); } - media_player: - platform: i2s_audio id: media_out @@ -572,12 +510,10 @@ media_player: i2s_audio_id: audio_i2s i2s_comm_fmt: lsb mode: mono - i2s_audio: id: audio_i2s i2s_lrclk_pin: ${audio_lrclk_pin} i2s_bclk_pin: ${audio_bclk_pin} - uart: tx_pin: ${uart_tx_pin} rx_pin: ${uart_rx_pin} @@ -594,13 +530,11 @@ uart: bytes: 2048 sequence: - lambda: UARTDebug::log_hex(direction, bytes, ' '); - tx_ultimate_touch: id: tx_touch uart: my_uart - on_press: -# - script.execute: led_on_touch + # - script.execute: led_on_touch - lambda: > ESP_LOGD("tx_ultimate_touch.on_press", "Touch Position: %d / State: %d", touch.x, touch.state); @@ -608,57 +542,43 @@ tx_ultimate_touch: - script.execute: id: handle_release pos: !lambda "return touch.x;" - - switch.turn_on: vibra - - lambda: > ESP_LOGD("tx_ultimate_touch.on_release", "Release Position: %d / State: %d", touch.x, touch.state); on_swipe_left: - script.execute: led_on_swipe_left - - switch.turn_on: vibra - - binary_sensor.template.publish: id: swipe_left state: ON - - lambda: > ESP_LOGD("tx_ultimate_touch.on_swipe_left", "Swipe Left Position: %d / State: %d", touch.x, touch.state); on_swipe_right: - script.execute: led_on_swipe_right - - switch.turn_on: vibra - - binary_sensor.template.publish: id: swipe_right state: ON - - lambda: > ESP_LOGD("tx_ultimate_touch.on_swipe_right", "Swipe Right Position: %d / State: %d", touch.x, touch.state); on_full_touch_release: - script.execute: led_on_full_touch - - switch.turn_on: vibra - - binary_sensor.template.publish: id: multi_touch state: ON - - lambda: > ESP_LOGD("tx_ultimate_touch.on_full_touch_release", "Full Touch Release Position: %d / State: %d", touch.x, touch.state); on_long_touch_release: - script.execute: led_on_long_touch - - switch.turn_on: vibra - - binary_sensor.template.publish: id: long_press state: ON - - lambda: > ESP_LOGD("tx_ultimate_touch.on_long_touch_release", "Long Touch Release Position: %d / State: %d", touch.x, touch.state); @@ -671,17 +591,14 @@ time: minutes: /5 then: - script.execute: refresh_nightlight - sun: latitude: ${latitude} longitude: ${longitude} - cover: - platform: time_based name: ${cover_1_name} id: my_cover_1 assumed_state: false - open_action: - light.turn_on: id: leds_left @@ -689,7 +606,6 @@ cover: effect: "Cover Position" - script.execute: open_cover_1 open_duration: ${cover_1_open_duration} - close_action: - light.turn_on: id: leds_left @@ -697,15 +613,12 @@ cover: effect: "Cover Position" - script.execute: close_cover_1 close_duration: ${cover_1_close_duration} - stop_action: - script.execute: stop_cover_1 - - platform: time_based name: ${cover_2_name} id: my_cover_2 assumed_state: false - open_action: - light.turn_on: id: leds_right @@ -713,7 +626,6 @@ cover: effect: "Cover Position" - script.execute: open_cover_2 open_duration: ${cover_2_open_duration} - close_action: - light.turn_on: id: leds_right @@ -721,43 +633,35 @@ cover: effect: "Cover Position" - script.execute: close_cover_2 close_duration: ${cover_2_close_duration} - stop_action: - script.execute: stop_cover_2 - script: - id: open_cover_1 mode: restart then: - switch.turn_on: relay_1 - - id: close_cover_1 mode: restart then: - switch.turn_on: relay_2 - - id: stop_cover_1 mode: restart then: - switch.turn_off: relay_1 - switch.turn_off: relay_2 - - id: open_cover_2 mode: restart then: - switch.turn_on: relay_4 - - id: close_cover_2 mode: restart then: - switch.turn_on: relay_3 - - id: stop_cover_2 mode: restart then: - switch.turn_off: relay_3 - switch.turn_off: relay_4 - - id: refresh_nightlight mode: restart then: @@ -774,7 +678,6 @@ script: else: - switch.turn_off: id: nightlight - - id: refresh_led_default mode: restart then: @@ -782,16 +685,15 @@ script: condition: lambda: "return id(nightlight).state || id(nightlight_active).state;" then: - - light.turn_on: + - light.turn_on: id: leds_top brightness: ${nightlight_brightness} effect: "None" - script.execute: led_on_nightlight else: - - light.turn_off: + - light.turn_off: id: leds_top - light.turn_off: leds_nightlight - - if: condition: lambda: "return (id(relay_1).state) ;" @@ -799,7 +701,6 @@ script: - script.execute: led_on_button_left else: - script.execute: led_off_button_left - - if: condition: lambda: "return (${relay_count}>=3 && id(relay_3).state);" @@ -807,7 +708,6 @@ script: - script.execute: led_on_button_middle else: - script.execute: led_off_button_middle - - if: condition: lambda: "return (${relay_count}==4 && id(relay_4).state);" @@ -815,7 +715,6 @@ script: - script.execute: led_on_button_middle else: - script.execute: led_off_button_middle - - if: condition: lambda: "return id(relay_2).state;" @@ -823,7 +722,6 @@ script: - script.execute: led_on_button_right else: - script.execute: led_off_button_right - - id: led_on_button_left mode: restart then: @@ -833,7 +731,6 @@ script: red: !lambda "return id(button_color)[0]/100.0;" green: !lambda "return id(button_color)[1]/100.0;" blue: !lambda "return id(button_color)[2]/100.0;" - - id: led_on_button_middle mode: restart then: @@ -843,7 +740,6 @@ script: red: !lambda "return id(button_color)[0]/100.0;" green: !lambda "return id(button_color)[1]/100.0;" blue: !lambda "return id(button_color)[2]/100.0;" - - id: led_on_button_right mode: restart then: @@ -853,7 +749,6 @@ script: red: !lambda "return id(button_color)[0]/100.0;" green: !lambda "return id(button_color)[1]/100.0;" blue: !lambda "return id(button_color)[2]/100.0;" - - id: led_off_button_left mode: restart then: @@ -870,7 +765,6 @@ script: else: - light.turn_off: id: leds_button_left - - id: led_off_button_middle mode: restart then: @@ -887,7 +781,6 @@ script: else: - light.turn_off: id: leds_button_middle - - id: led_off_button_right mode: restart then: @@ -904,7 +797,6 @@ script: else: - light.turn_off: id: leds_button_right - - id: led_on_nightlight mode: restart then: @@ -914,15 +806,13 @@ script: red: !lambda "return id(nightlight_color)[0]/100.0;" green: !lambda "return id(nightlight_color)[1]/100.0;" blue: !lambda "return id(nightlight_color)[2]/100.0;" - effect: "None" - + effect: "None" - id: led_on_release mode: restart then: -# - light.turn_off: -# id: leds_top + # - light.turn_off: + # id: leds_top - script.execute: refresh_led_default - - id: led_on_touch mode: restart then: @@ -935,7 +825,6 @@ script: effect: ${touch_effect} - delay: 6s - script.execute: refresh_led_default - - id: led_on_swipe_left mode: restart then: @@ -950,7 +839,6 @@ script: - light.turn_off: id: leds_left - script.execute: refresh_led_default - - id: led_on_swipe_right mode: restart then: @@ -968,7 +856,6 @@ script: - light.turn_on: id: leds_left effect: "Cover Position" - - id: led_on_full_touch mode: restart then: @@ -979,7 +866,6 @@ script: green: !lambda "return id(multi_touch_color)[1]/100.0;" blue: !lambda "return id(multi_touch_color)[2]/100.0;" effect: ${multi_touch_effect} - - id: led_on_long_touch mode: restart then: @@ -990,7 +876,6 @@ script: green: !lambda "return id(long_press_color)[1]/100.0;" blue: !lambda "return id(long_press_color)[2]/100.0;" effect: ${long_press_effect} - - id: handle_release mode: restart parameters: @@ -1003,7 +888,6 @@ script: - binary_sensor.template.publish: id: touchfield_1 state: ON - - if: condition: lambda: "return ${relay_count}==2;" @@ -1015,12 +899,10 @@ script: - binary_sensor.template.publish: id: touchfield_1 state: ON - else: - binary_sensor.template.publish: id: touchfield_2 state: ON - - if: condition: lambda: "return ${relay_count}==3;" @@ -1032,7 +914,6 @@ script: - binary_sensor.template.publish: id: touchfield_1 state: ON - else: - if: condition: @@ -1041,12 +922,10 @@ script: - binary_sensor.template.publish: id: touchfield_2 state: ON - else: - binary_sensor.template.publish: id: touchfield_3 state: ON - - if: condition: lambda: "return ${relay_count}==4;" @@ -1058,7 +937,6 @@ script: - binary_sensor.template.publish: id: touchfield_1 state: ON - else: - if: condition: @@ -1067,7 +945,6 @@ script: - binary_sensor.template.publish: id: touchfield_2 state: ON - else: - if: condition: @@ -1076,12 +953,10 @@ script: - binary_sensor.template.publish: id: touchfield_3 state: ON - else: - binary_sensor.template.publish: id: touchfield_4 state: ON - - id: cover_1_open_action mode: restart then: @@ -1091,7 +966,6 @@ script: } else { id(my_cover_1).make_call().set_command_stop().perform(); } - - id: cover_1_close_action mode: restart then: @@ -1101,7 +975,6 @@ script: } else { id(my_cover_1).make_call().set_command_stop().perform(); } - - id: cover_2_open_action mode: restart then: @@ -1111,7 +984,6 @@ script: } else { id(my_cover_2).make_call().set_command_stop().perform(); } - - id: cover_2_close_action mode: restart then: diff --git a/tx_ultimate_cover.yaml b/tx_ultimate_cover.yaml index ec8408b..5f205d0 100644 --- a/tx_ultimate_cover.yaml +++ b/tx_ultimate_cover.yaml @@ -1,85 +1,63 @@ substitutions: name: "shys-tx-ultimate-cover" friendly_name: "TX Ultimate Cover" - relay_count: "3" - # only used on 3-way switch (relay_count = 3) toggle_relay_3_on_touch: "true" - cover_name: "My Cover" cover_open_duration: 25s cover_close_duration: 25s - vibra_time: 150ms button_on_time: 500ms - button_brightness: "0.7" button_color: "{0,0,100}" - nightlight: "on" nightlight_brightness: "0.2" nightlight_color: "{80,70,0}" - cover_brightness: "0.7" - cover_color1: "{0,255,0}" #open - cover_color2: "{255,0,0}" #close - + cover_color1: "{0,255,0}" #open + cover_color2: "{255,0,0}" #close latitude: "51.132241°" longitude: "7.178795°" - touch_brightness: "1" touch_color: "{0,100,100}" touch_effect: "Scan" - boot_brightness: "0.7" boot_color1: "{100,0,0}" boot_color2: "{100,100,0}" boot_effect: "Scan" - long_press_brightness: "1" long_press_color: "{100,0,0}" long_press_effect: "" - multi_touch_brightness: "1" multi_touch_color: "{0,0,0}" multi_touch_effect: "Rainbow" - swipe_left_brightness: "1" swipe_left_color: "{0,100,0}" swipe_left_effect: "Pulse" - swipe_right_brightness: "1" swipe_right_color: "{100,0,70}" swipe_right_effect: "Pulse" - relay_1_pin: GPIO18 relay_2_pin: GPIO17 relay_3_pin: GPIO27 relay_4_pin: GPIO23 - vibra_motor_pin: GPIO21 pa_power_pin: GPIO26 - led_pin: GPIO13 status_led_pin: GPIO33 - uart_tx_pin: GPIO19 uart_rx_pin: GPIO22 - audio_lrclk_pin: GPIO4 audio_bclk_pin: GPIO2 audio_sdata_pin: GPIO15 - touchpanel_power_pin: GPIO5 - esphome: name: ${name} friendly_name: ${friendly_name} project: name: smarthomeyourself.tx_ultimate_cover version: "1.0" - on_boot: priority: 700 #-100 then: @@ -105,7 +83,6 @@ esphome: condition: api.connected: timeout: 10s - - binary_sensor.template.publish: id: touchfield_1 state: OFF @@ -133,12 +110,10 @@ esphome: id: leds_right brightness: !lambda "return id(nightlight).state?${nightlight_brightness}:${cover_brightness};" effect: "Cover Position" - esp32: board: esp32dev framework: type: arduino - logger: # hardware_uart: UART2 level: DEBUG @@ -149,33 +124,24 @@ logger: switch: INFO tx_ultimate_touch: INFO uart_debug: INFO - dashboard_import: package_import_url: github://SmartHome-yourself/sonoff-tx-ultimate-for-esphome/tx_ultimate_cover.yaml@main import_full_config: false - api: - ota: - - platform: esphome - + - platform: esphome wifi: ap: password: "12345678" - improv_serial: - captive_portal: - external_components: -# - source: /config/esphome/my_components + # - source: /config/esphome/my_components - source: type: git url: https://github.com/SmartHome-yourself/sonoff-tx-ultimate-for-esphome ref: main components: [tx_ultimate_touch] - - globals: - id: nightlight_color type: int [3] @@ -221,20 +187,17 @@ globals: type: int [3] restore_value: no initial_value: ${cover_color2} - binary_sensor: - platform: template name: "Touchfield 1" id: touchfield_1 on_press: - script.execute: cover_open_action - - delay: ${button_on_time} - binary_sensor.template.publish: id: touchfield_1 state: OFF - script.execute: refresh_led_default - - platform: template name: "Touchfield 2" id: touchfield_2 @@ -250,13 +213,11 @@ binary_sensor: - switch.toggle: relay_3 else: - script.execute: cover_close_action - - delay: ${button_on_time} - binary_sensor.template.publish: id: touchfield_2 state: OFF - script.execute: refresh_led_default - - platform: template name: "Touchfield 3" id: touchfield_3 @@ -267,7 +228,6 @@ binary_sensor: id: touchfield_3 state: OFF - script.execute: refresh_led_default - - platform: template name: "Swipe left" id: swipe_left @@ -277,7 +237,6 @@ binary_sensor: id: swipe_left state: OFF - script.execute: refresh_led_default - - platform: template name: "Swipe_right" id: swipe_right @@ -287,7 +246,6 @@ binary_sensor: id: swipe_right state: OFF - script.execute: refresh_led_default - - platform: template name: "Multi Touch" id: multi_touch @@ -297,7 +255,6 @@ binary_sensor: id: multi_touch state: OFF - script.execute: refresh_led_default - - platform: template name: "Long Press" id: long_press @@ -307,7 +264,6 @@ binary_sensor: id: long_press state: OFF - script.execute: refresh_led_default - switch: - platform: gpio id: relay_1 @@ -322,7 +278,6 @@ switch: on_turn_off: then: - script.execute: refresh_led_default - - platform: gpio id: relay_2 name: "${friendly_name} L2" @@ -336,7 +291,6 @@ switch: on_turn_off: then: - script.execute: refresh_led_default - - platform: gpio id: relay_3 name: "${friendly_name} L3" @@ -348,7 +302,6 @@ switch: on_turn_off: then: - script.execute: refresh_led_default - - platform: gpio id: vibra pin: ${vibra_motor_pin} @@ -357,14 +310,12 @@ switch: on_turn_on: - delay: ${vibra_time} - switch.turn_off: vibra - - platform: gpio id: pa_power pin: ${pa_power_pin} name: "PA Power" internal: true restore_mode: ALWAYS_ON - - platform: gpio name: "touch panel power" pin: @@ -373,7 +324,6 @@ switch: id: touch_power internal: true restore_mode: RESTORE_DEFAULT_ON - - platform: template name: "Nightlight" id: nightlight @@ -386,7 +336,6 @@ switch: on_turn_off: then: - script.execute: refresh_led_default - - platform: template name: "Nightlight" id: nightlight_active @@ -398,10 +347,8 @@ switch: on_turn_off: then: - script.execute: refresh_led_default - - platform: restart name: "${friendly_name} Restart" - light: - platform: neopixelbus type: GRB @@ -420,11 +367,9 @@ light: name: "Pulse" transition_length: 1.4s update_interval: 1s - on_turn_off: then: - script.execute: refresh_led_default - - platform: partition name: "LEDs Button right" id: leds_button_right @@ -449,7 +394,6 @@ light: - id: leds from: 11 to: 11 - - platform: partition name: "LEDs Nightlight" id: leds_nightlight @@ -467,7 +411,6 @@ light: - id: leds_top from: 0 to: 6 - - platform: partition name: "LEDs Top" id: leds_top @@ -483,7 +426,6 @@ light: name: "Rainbow" speed: 10 width: 20 - - platform: partition name: "LEDs Left" id: leds_left @@ -497,7 +439,6 @@ light: name: "Pulse" transition_length: 600ms update_interval: 300ms - - platform: partition name: "LEDs Right" id: leds_right @@ -523,7 +464,6 @@ light: if (pos < 7){ it.range(0, 7-pos) = ESPColor(id(cover_color2)[0],id(cover_color2)[1],id(cover_color2)[2]); } - media_player: - platform: i2s_audio id: media_out @@ -533,12 +473,10 @@ media_player: i2s_audio_id: audio_i2s i2s_comm_fmt: lsb mode: mono - i2s_audio: id: audio_i2s i2s_lrclk_pin: ${audio_lrclk_pin} i2s_bclk_pin: ${audio_bclk_pin} - uart: tx_pin: ${uart_tx_pin} rx_pin: ${uart_rx_pin} @@ -555,13 +493,11 @@ uart: bytes: 2048 sequence: - lambda: UARTDebug::log_hex(direction, bytes, ' '); - tx_ultimate_touch: id: tx_touch uart: my_uart - on_press: -# - script.execute: led_on_touch + # - script.execute: led_on_touch - lambda: > ESP_LOGD("tx_ultimate_touch.on_press", "Touch Position: %d / State: %d", touch.x, touch.state); @@ -569,57 +505,43 @@ tx_ultimate_touch: - script.execute: id: handle_release pos: !lambda "return touch.x;" - - switch.turn_on: vibra - - lambda: > ESP_LOGD("tx_ultimate_touch.on_release", "Release Position: %d / State: %d", touch.x, touch.state); on_swipe_left: - script.execute: led_on_swipe_left - - switch.turn_on: vibra - - binary_sensor.template.publish: id: swipe_left state: ON - - lambda: > ESP_LOGD("tx_ultimate_touch.on_swipe_left", "Swipe Left Position: %d / State: %d", touch.x, touch.state); on_swipe_right: - script.execute: led_on_swipe_right - - switch.turn_on: vibra - - binary_sensor.template.publish: id: swipe_right state: ON - - lambda: > ESP_LOGD("tx_ultimate_touch.on_swipe_right", "Swipe Right Position: %d / State: %d", touch.x, touch.state); on_full_touch_release: - script.execute: led_on_full_touch - - switch.turn_on: vibra - - binary_sensor.template.publish: id: multi_touch state: ON - - lambda: > ESP_LOGD("tx_ultimate_touch.on_full_touch_release", "Full Touch Release Position: %d / State: %d", touch.x, touch.state); on_long_touch_release: - script.execute: led_on_long_touch - - switch.turn_on: vibra - - binary_sensor.template.publish: id: long_press state: ON - - lambda: > ESP_LOGD("tx_ultimate_touch.on_long_touch_release", "Long Touch Release Position: %d / State: %d", touch.x, touch.state); @@ -632,17 +554,14 @@ time: minutes: /5 then: - script.execute: refresh_nightlight - sun: latitude: ${latitude} longitude: ${longitude} - cover: - platform: time_based name: ${cover_name} id: my_cover assumed_state: false - open_action: - light.turn_on: id: leds_right @@ -650,7 +569,6 @@ cover: effect: "Cover Position" - script.execute: open_cover open_duration: ${cover_open_duration} - close_action: - light.turn_on: id: leds_right @@ -658,27 +576,22 @@ cover: effect: "Cover Position" - script.execute: close_cover close_duration: ${cover_close_duration} - stop_action: - script.execute: stop_cover - script: - id: open_cover mode: restart then: - switch.turn_on: relay_1 - - id: close_cover mode: restart then: - switch.turn_on: relay_2 - - id: stop_cover mode: restart then: - switch.turn_off: relay_1 - switch.turn_off: relay_2 - - id: refresh_nightlight mode: restart then: @@ -695,7 +608,6 @@ script: else: - switch.turn_off: id: nightlight - - id: refresh_led_default mode: restart then: @@ -703,16 +615,15 @@ script: condition: lambda: "return id(nightlight).state || id(nightlight_active).state;" then: - - light.turn_on: + - light.turn_on: id: leds_top brightness: ${nightlight_brightness} effect: "None" - script.execute: led_on_nightlight else: - - light.turn_off: + - light.turn_off: id: leds_top - light.turn_off: leds_nightlight - - if: condition: lambda: "return (id(relay_1).state) ;" @@ -720,7 +631,6 @@ script: - script.execute: led_on_button_left else: - script.execute: led_off_button_left - - if: condition: lambda: "return (${relay_count}==3 && id(relay_3).state);" @@ -728,7 +638,6 @@ script: - script.execute: led_on_button_middle else: - script.execute: led_off_button_middle - - if: condition: lambda: "return id(relay_2).state;" @@ -736,7 +645,6 @@ script: - script.execute: led_on_button_right else: - script.execute: led_off_button_right - - id: led_on_button_left mode: restart then: @@ -746,7 +654,6 @@ script: red: !lambda "return id(button_color)[0]/100.0;" green: !lambda "return id(button_color)[1]/100.0;" blue: !lambda "return id(button_color)[2]/100.0;" - - id: led_on_button_middle mode: restart then: @@ -756,7 +663,6 @@ script: red: !lambda "return id(button_color)[0]/100.0;" green: !lambda "return id(button_color)[1]/100.0;" blue: !lambda "return id(button_color)[2]/100.0;" - - id: led_on_button_right mode: restart then: @@ -766,7 +672,6 @@ script: red: !lambda "return id(button_color)[0]/100.0;" green: !lambda "return id(button_color)[1]/100.0;" blue: !lambda "return id(button_color)[2]/100.0;" - - id: led_off_button_left mode: restart then: @@ -783,7 +688,6 @@ script: else: - light.turn_off: id: leds_button_left - - id: led_off_button_middle mode: restart then: @@ -800,7 +704,6 @@ script: else: - light.turn_off: id: leds_button_middle - - id: led_off_button_right mode: restart then: @@ -817,7 +720,6 @@ script: else: - light.turn_off: id: leds_button_right - - id: led_on_nightlight mode: restart then: @@ -827,15 +729,13 @@ script: red: !lambda "return id(nightlight_color)[0]/100.0;" green: !lambda "return id(nightlight_color)[1]/100.0;" blue: !lambda "return id(nightlight_color)[2]/100.0;" - effect: "None" - + effect: "None" - id: led_on_release mode: restart then: -# - light.turn_off: -# id: leds_top + # - light.turn_off: + # id: leds_top - script.execute: refresh_led_default - - id: led_on_touch mode: restart then: @@ -848,7 +748,6 @@ script: effect: ${touch_effect} - delay: 6s - script.execute: refresh_led_default - - id: led_on_swipe_left mode: restart then: @@ -863,7 +762,6 @@ script: - light.turn_off: id: leds_left - script.execute: refresh_led_default - - id: led_on_swipe_right mode: restart then: @@ -878,7 +776,6 @@ script: - light.turn_on: id: leds_right effect: "Cover Position" - - id: led_on_full_touch mode: restart then: @@ -889,7 +786,6 @@ script: green: !lambda "return id(multi_touch_color)[1]/100.0;" blue: !lambda "return id(multi_touch_color)[2]/100.0;" effect: ${multi_touch_effect} - - id: led_on_long_touch mode: restart then: @@ -900,7 +796,6 @@ script: green: !lambda "return id(long_press_color)[1]/100.0;" blue: !lambda "return id(long_press_color)[2]/100.0;" effect: ${long_press_effect} - - id: handle_release mode: restart parameters: @@ -913,7 +808,6 @@ script: - binary_sensor.template.publish: id: touchfield_1 state: ON - - if: condition: lambda: "return ${relay_count}==2;" @@ -925,12 +819,10 @@ script: - binary_sensor.template.publish: id: touchfield_1 state: ON - else: - binary_sensor.template.publish: id: touchfield_2 state: ON - - if: condition: lambda: "return ${relay_count}==3;" @@ -942,7 +834,6 @@ script: - binary_sensor.template.publish: id: touchfield_1 state: ON - else: - if: condition: @@ -951,12 +842,10 @@ script: - binary_sensor.template.publish: id: touchfield_2 state: ON - else: - binary_sensor.template.publish: id: touchfield_3 state: ON - - id: cover_open_action mode: restart then: @@ -966,7 +855,6 @@ script: } else { id(my_cover).make_call().set_command_stop().perform(); } - - id: cover_close_action mode: restart then: diff --git a/tx_ultimate_cover_and_2x_switches_us.yaml b/tx_ultimate_cover_and_2x_switches_us.yaml index edea021..d72bb40 100644 --- a/tx_ultimate_cover_and_2x_switches_us.yaml +++ b/tx_ultimate_cover_and_2x_switches_us.yaml @@ -1,82 +1,61 @@ substitutions: name: "shys-tx-ultimate-cover-and-2x-switches" friendly_name: "TX Ultimate Cover and 2x Switches" - relay_count: "4" # Needs at least 4 relays - cover_name: "My Cover" cover_open_duration: 25s cover_close_duration: 25s - cover_brightness: "0.7" - cover_color1: "{0,255,0}" #open - cover_color2: "{255,0,0}" #close - + cover_color1: "{0,255,0}" #open + cover_color2: "{255,0,0}" #close vibra_time: 150ms button_on_time: 500ms - button_brightness: "0.7" button_color: "{0,0,100}" - nightlight: "on" nightlight_brightness: "0.2" nightlight_color: "{80,70,0}" - latitude: "51.132241°" longitude: "7.178795°" - touch_brightness: "1" touch_color: "{0,100,100}" touch_effect: "Scan" - boot_brightness: "0.7" boot_color1: "{100,0,0}" boot_color2: "{100,100,0}" boot_effect: "Scan" - long_press_brightness: "1" long_press_color: "{100,0,0}" long_press_effect: "" - multi_touch_brightness: "1" multi_touch_color: "{0,0,0}" multi_touch_effect: "Rainbow" - swipe_left_brightness: "1" swipe_left_color: "{0,100,0}" swipe_left_effect: "Pulse" - swipe_right_brightness: "1" swipe_right_color: "{100,0,70}" swipe_right_effect: "Pulse" - relay_1_pin: GPIO18 relay_2_pin: GPIO17 relay_3_pin: GPIO27 relay_4_pin: GPIO23 - vibra_motor_pin: GPIO21 pa_power_pin: GPIO26 - led_pin: GPIO13 status_led_pin: GPIO33 - uart_tx_pin: GPIO19 uart_rx_pin: GPIO22 - audio_lrclk_pin: GPIO4 audio_bclk_pin: GPIO2 audio_sdata_pin: GPIO15 - touchpanel_power_pin: GPIO5 - esphome: name: ${name} friendly_name: ${friendly_name} project: name: smarthomeyourself.tx_ultimate_cover_and_2x_switches version: "1.0" - on_boot: priority: 700 #-100 then: @@ -102,7 +81,6 @@ esphome: condition: api.connected: timeout: 10s - - binary_sensor.template.publish: id: touchfield_1 state: OFF @@ -133,12 +111,10 @@ esphome: id: leds_left brightness: !lambda "return id(nightlight).state?${nightlight_brightness}:${cover_brightness};" effect: "Cover Position" - esp32: board: esp32dev framework: type: arduino - logger: # hardware_uart: UART2 level: DEBUG @@ -149,33 +125,24 @@ logger: switch: INFO tx_ultimate_touch: INFO uart_debug: INFO - dashboard_import: package_import_url: github://SmartHome-yourself/sonoff-tx-ultimate-for-esphome/tx_ultimate_cover.yaml@main import_full_config: false - api: - ota: - - platform: esphome - + - platform: esphome wifi: ap: password: "12345678" - improv_serial: - captive_portal: - external_components: -# - source: /config/esphome/my_components + # - source: /config/esphome/my_components - source: type: git url: https://github.com/SmartHome-yourself/sonoff-tx-ultimate-for-esphome ref: main components: [tx_ultimate_touch] - - globals: - id: nightlight_color type: int [3] @@ -221,20 +188,17 @@ globals: type: int [3] restore_value: no initial_value: ${cover_color2} - binary_sensor: - platform: template name: "Touchfield 1" id: touchfield_1 on_press: - script.execute: cover_open_action - - delay: ${button_on_time} - binary_sensor.template.publish: id: touchfield_1 state: OFF - script.execute: refresh_led_default - - platform: template name: "Touchfield 2" id: touchfield_2 @@ -245,7 +209,6 @@ binary_sensor: id: touchfield_2 state: OFF - script.execute: refresh_led_default - - platform: template name: "Touchfield 3" id: touchfield_3 @@ -256,7 +219,6 @@ binary_sensor: id: touchfield_3 state: OFF - script.execute: refresh_led_default - - platform: template name: "Touchfield 4" id: touchfield_4 @@ -267,7 +229,6 @@ binary_sensor: id: touchfield_4 state: OFF - script.execute: refresh_led_default - - platform: template name: "Swipe left" id: swipe_left @@ -277,7 +238,6 @@ binary_sensor: id: swipe_left state: OFF - script.execute: refresh_led_default - - platform: template name: "Swipe_right" id: swipe_right @@ -287,7 +247,6 @@ binary_sensor: id: swipe_right state: OFF - script.execute: refresh_led_default - - platform: template name: "Multi Touch" id: multi_touch @@ -297,7 +256,6 @@ binary_sensor: id: multi_touch state: OFF - script.execute: refresh_led_default - - platform: template name: "Long Press" id: long_press @@ -307,7 +265,6 @@ binary_sensor: id: long_press state: OFF - script.execute: refresh_led_default - switch: - platform: gpio id: relay_1 @@ -322,7 +279,6 @@ switch: on_turn_off: then: - script.execute: refresh_led_default - - platform: gpio id: relay_2 name: "${friendly_name} L2" @@ -336,7 +292,6 @@ switch: on_turn_off: then: - script.execute: refresh_led_default - - platform: gpio id: relay_3 name: "${friendly_name} L3" @@ -348,7 +303,6 @@ switch: on_turn_off: then: - script.execute: refresh_led_default - - platform: gpio id: relay_4 name: "${friendly_name} L4" @@ -360,7 +314,6 @@ switch: on_turn_off: then: - script.execute: refresh_led_default - - platform: gpio id: vibra pin: ${vibra_motor_pin} @@ -369,14 +322,12 @@ switch: on_turn_on: - delay: ${vibra_time} - switch.turn_off: vibra - - platform: gpio id: pa_power pin: ${pa_power_pin} name: "PA Power" internal: true restore_mode: ALWAYS_ON - - platform: gpio name: "touch panel power" pin: @@ -385,7 +336,6 @@ switch: id: touch_power internal: true restore_mode: RESTORE_DEFAULT_ON - - platform: template name: "Nightlight" id: nightlight @@ -398,7 +348,6 @@ switch: on_turn_off: then: - script.execute: refresh_led_default - - platform: template name: "Nightlight" id: nightlight_active @@ -410,10 +359,8 @@ switch: on_turn_off: then: - script.execute: refresh_led_default - - platform: restart name: "${friendly_name} Restart" - light: - platform: neopixelbus type: GRB @@ -432,11 +379,9 @@ light: name: "Pulse" transition_length: 1.4s update_interval: 1s - on_turn_off: then: - script.execute: refresh_led_default - - platform: partition name: "LEDs Button right" id: leds_button_right @@ -464,7 +409,6 @@ light: - id: leds from: 25 to: 30 - - platform: partition name: "LEDs Nightlight" id: leds_nightlight @@ -473,7 +417,6 @@ light: - id: leds from: 0 to: 31 - - platform: partition name: "LEDs Top" id: leds_top @@ -492,7 +435,6 @@ light: name: "Rainbow" speed: 10 width: 20 - - platform: partition name: "LEDs Left" id: leds_left @@ -515,7 +457,6 @@ light: if (pos < 7){ it.range(0, 7-pos) = ESPColor(id(cover_color2)[0],id(cover_color2)[1],id(cover_color2)[2]); } - - platform: partition name: "LEDs Right" id: leds_right @@ -529,7 +470,6 @@ light: name: "Pulse" transition_length: 600ms update_interval: 300ms - media_player: - platform: i2s_audio id: media_out @@ -539,12 +479,10 @@ media_player: i2s_audio_id: audio_i2s i2s_comm_fmt: lsb mode: mono - i2s_audio: id: audio_i2s i2s_lrclk_pin: ${audio_lrclk_pin} i2s_bclk_pin: ${audio_bclk_pin} - uart: tx_pin: ${uart_tx_pin} rx_pin: ${uart_rx_pin} @@ -561,13 +499,11 @@ uart: bytes: 2048 sequence: - lambda: UARTDebug::log_hex(direction, bytes, ' '); - tx_ultimate_touch: id: tx_touch uart: my_uart - on_press: -# - script.execute: led_on_touch + # - script.execute: led_on_touch - lambda: > ESP_LOGD("tx_ultimate_touch.on_press", "Touch Position: %d / State: %d", touch.x, touch.state); @@ -575,57 +511,43 @@ tx_ultimate_touch: - script.execute: id: handle_release pos: !lambda "return touch.x;" - - switch.turn_on: vibra - - lambda: > ESP_LOGD("tx_ultimate_touch.on_release", "Release Position: %d / State: %d", touch.x, touch.state); on_swipe_left: - script.execute: led_on_swipe_left - - switch.turn_on: vibra - - binary_sensor.template.publish: id: swipe_left state: ON - - lambda: > ESP_LOGD("tx_ultimate_touch.on_swipe_left", "Swipe Left Position: %d / State: %d", touch.x, touch.state); on_swipe_right: - script.execute: led_on_swipe_right - - switch.turn_on: vibra - - binary_sensor.template.publish: id: swipe_right state: ON - - lambda: > ESP_LOGD("tx_ultimate_touch.on_swipe_right", "Swipe Right Position: %d / State: %d", touch.x, touch.state); on_full_touch_release: - script.execute: led_on_full_touch - - switch.turn_on: vibra - - binary_sensor.template.publish: id: multi_touch state: ON - - lambda: > ESP_LOGD("tx_ultimate_touch.on_full_touch_release", "Full Touch Release Position: %d / State: %d", touch.x, touch.state); on_long_touch_release: - script.execute: led_on_long_touch - - switch.turn_on: vibra - - binary_sensor.template.publish: id: long_press state: ON - - lambda: > ESP_LOGD("tx_ultimate_touch.on_long_touch_release", "Long Touch Release Position: %d / State: %d", touch.x, touch.state); @@ -638,17 +560,14 @@ time: minutes: /5 then: - script.execute: refresh_nightlight - sun: latitude: ${latitude} longitude: ${longitude} - cover: - platform: time_based name: ${cover_name} id: my_cover assumed_state: false - open_action: - light.turn_on: id: leds_left @@ -656,7 +575,6 @@ cover: effect: "Cover Position" - script.execute: open_cover open_duration: ${cover_open_duration} - close_action: - light.turn_on: id: leds_left @@ -664,27 +582,22 @@ cover: effect: "Cover Position" - script.execute: close_cover close_duration: ${cover_close_duration} - stop_action: - script.execute: stop_cover - script: - id: open_cover mode: restart then: - switch.turn_on: relay_1 - - id: close_cover mode: restart then: - switch.turn_on: relay_2 - - id: stop_cover mode: restart then: - switch.turn_off: relay_1 - switch.turn_off: relay_2 - - id: refresh_nightlight mode: restart then: @@ -701,7 +614,6 @@ script: else: - switch.turn_off: id: nightlight - - id: refresh_led_default mode: restart then: @@ -709,16 +621,15 @@ script: condition: lambda: "return id(nightlight).state || id(nightlight_active).state;" then: - - light.turn_on: + - light.turn_on: id: leds_top brightness: ${nightlight_brightness} effect: "None" - script.execute: led_on_nightlight else: - - light.turn_off: + - light.turn_off: id: leds_top - light.turn_off: leds_nightlight - - if: condition: lambda: "return (id(relay_1).state) ;" @@ -726,7 +637,6 @@ script: - script.execute: led_on_button_left else: - script.execute: led_off_button_left - - if: condition: lambda: "return id(relay_2).state;" @@ -734,7 +644,6 @@ script: - script.execute: led_on_button_right else: - script.execute: led_off_button_right - - if: condition: lambda: "return (${relay_count}>=3 && id(relay_3).state);" @@ -742,7 +651,6 @@ script: - script.execute: led_on_button_middle else: - script.execute: led_off_button_middle - - if: condition: lambda: "return (${relay_count}==4 && id(relay_4).state);" @@ -750,7 +658,6 @@ script: - script.execute: led_on_button_middle else: - script.execute: led_off_button_middle - - id: led_on_button_left mode: restart then: @@ -760,7 +667,6 @@ script: red: !lambda "return id(button_color)[0]/100.0;" green: !lambda "return id(button_color)[1]/100.0;" blue: !lambda "return id(button_color)[2]/100.0;" - - id: led_on_button_middle mode: restart then: @@ -770,7 +676,6 @@ script: red: !lambda "return id(button_color)[0]/100.0;" green: !lambda "return id(button_color)[1]/100.0;" blue: !lambda "return id(button_color)[2]/100.0;" - - id: led_on_button_right mode: restart then: @@ -780,7 +685,6 @@ script: red: !lambda "return id(button_color)[0]/100.0;" green: !lambda "return id(button_color)[1]/100.0;" blue: !lambda "return id(button_color)[2]/100.0;" - - id: led_off_button_left mode: restart then: @@ -797,7 +701,6 @@ script: else: - light.turn_off: id: leds_button_left - - id: led_off_button_middle mode: restart then: @@ -814,7 +717,6 @@ script: else: - light.turn_off: id: leds_button_middle - - id: led_off_button_right mode: restart then: @@ -831,7 +733,6 @@ script: else: - light.turn_off: id: leds_button_right - - id: led_on_nightlight mode: restart then: @@ -841,15 +742,13 @@ script: red: !lambda "return id(nightlight_color)[0]/100.0;" green: !lambda "return id(nightlight_color)[1]/100.0;" blue: !lambda "return id(nightlight_color)[2]/100.0;" - effect: "None" - + effect: "None" - id: led_on_release mode: restart then: -# - light.turn_off: -# id: leds_top + # - light.turn_off: + # id: leds_top - script.execute: refresh_led_default - - id: led_on_touch mode: restart then: @@ -862,7 +761,6 @@ script: effect: ${touch_effect} - delay: 6s - script.execute: refresh_led_default - - id: led_on_swipe_left mode: restart then: @@ -877,7 +775,6 @@ script: - light.turn_off: id: leds_left - script.execute: refresh_led_default - - id: led_on_swipe_right mode: restart then: @@ -895,7 +792,6 @@ script: - light.turn_on: id: leds_left effect: "Cover Position" - - id: led_on_full_touch mode: restart then: @@ -906,7 +802,6 @@ script: green: !lambda "return id(multi_touch_color)[1]/100.0;" blue: !lambda "return id(multi_touch_color)[2]/100.0;" effect: ${multi_touch_effect} - - id: led_on_long_touch mode: restart then: @@ -917,7 +812,6 @@ script: green: !lambda "return id(long_press_color)[1]/100.0;" blue: !lambda "return id(long_press_color)[2]/100.0;" effect: ${long_press_effect} - - id: handle_release mode: restart parameters: @@ -930,7 +824,6 @@ script: - binary_sensor.template.publish: id: touchfield_1 state: ON - - if: condition: lambda: "return ${relay_count}==2;" @@ -942,12 +835,10 @@ script: - binary_sensor.template.publish: id: touchfield_1 state: ON - else: - binary_sensor.template.publish: id: touchfield_2 state: ON - - if: condition: lambda: "return ${relay_count}==3;" @@ -959,7 +850,6 @@ script: - binary_sensor.template.publish: id: touchfield_1 state: ON - else: - if: condition: @@ -968,12 +858,10 @@ script: - binary_sensor.template.publish: id: touchfield_2 state: ON - else: - binary_sensor.template.publish: id: touchfield_3 state: ON - - if: condition: lambda: "return ${relay_count}==4;" @@ -985,7 +873,6 @@ script: - binary_sensor.template.publish: id: touchfield_1 state: ON - else: - if: condition: @@ -994,7 +881,6 @@ script: - binary_sensor.template.publish: id: touchfield_2 state: ON - else: - if: condition: @@ -1003,12 +889,10 @@ script: - binary_sensor.template.publish: id: touchfield_3 state: ON - else: - binary_sensor.template.publish: id: touchfield_4 state: ON - - id: cover_open_action mode: restart then: @@ -1018,7 +902,6 @@ script: } else { id(my_cover).make_call().set_command_stop().perform(); } - - id: cover_close_action mode: restart then: diff --git a/tx_ultimate_cover_us.yaml b/tx_ultimate_cover_us.yaml index 91cc68c..97b8e2d 100644 --- a/tx_ultimate_cover_us.yaml +++ b/tx_ultimate_cover_us.yaml @@ -1,85 +1,63 @@ substitutions: name: "shys-tx-ultimate-cover" friendly_name: "TX Ultimate Cover" - relay_count: "3" - # only used on 3-way switch (relay_count = 3) toggle_relay_3_on_touch: "true" - cover_name: "My Cover" cover_open_duration: 25s cover_close_duration: 25s - vibra_time: 150ms button_on_time: 500ms - button_brightness: "0.7" button_color: "{0,0,100}" - nightlight: "on" nightlight_brightness: "0.2" nightlight_color: "{80,70,0}" - cover_brightness: "0.7" - cover_color1: "{0,255,0}" #open - cover_color2: "{255,0,0}" #close - + cover_color1: "{0,255,0}" #open + cover_color2: "{255,0,0}" #close latitude: "51.132241°" longitude: "7.178795°" - touch_brightness: "1" touch_color: "{0,100,100}" touch_effect: "Scan" - boot_brightness: "0.7" boot_color1: "{100,0,0}" boot_color2: "{100,100,0}" boot_effect: "Scan" - long_press_brightness: "1" long_press_color: "{100,0,0}" long_press_effect: "" - multi_touch_brightness: "1" multi_touch_color: "{0,0,0}" multi_touch_effect: "Rainbow" - swipe_left_brightness: "1" swipe_left_color: "{0,100,0}" swipe_left_effect: "Pulse" - swipe_right_brightness: "1" swipe_right_color: "{100,0,70}" swipe_right_effect: "Pulse" - relay_1_pin: GPIO18 relay_2_pin: GPIO17 relay_3_pin: GPIO27 relay_4_pin: GPIO23 - vibra_motor_pin: GPIO21 pa_power_pin: GPIO26 - led_pin: GPIO13 status_led_pin: GPIO33 - uart_tx_pin: GPIO19 uart_rx_pin: GPIO22 - audio_lrclk_pin: GPIO4 audio_bclk_pin: GPIO2 audio_sdata_pin: GPIO15 - touchpanel_power_pin: GPIO5 - esphome: name: ${name} friendly_name: ${friendly_name} project: name: smarthomeyourself.tx_ultimate_cover version: "1.0" - on_boot: priority: 700 #-100 then: @@ -105,7 +83,6 @@ esphome: condition: api.connected: timeout: 10s - - binary_sensor.template.publish: id: touchfield_1 state: OFF @@ -133,12 +110,10 @@ esphome: id: leds_right brightness: !lambda "return id(nightlight).state?${nightlight_brightness}:${cover_brightness};" effect: "Cover Position" - esp32: board: esp32dev framework: type: arduino - logger: # hardware_uart: UART2 level: DEBUG @@ -149,33 +124,24 @@ logger: switch: INFO tx_ultimate_touch: INFO uart_debug: INFO - dashboard_import: package_import_url: github://SmartHome-yourself/sonoff-tx-ultimate-for-esphome/tx_ultimate_cover.yaml@main import_full_config: false - api: - ota: - - platform: esphome - + - platform: esphome wifi: ap: password: "12345678" - improv_serial: - captive_portal: - external_components: -# - source: /config/esphome/my_components + # - source: /config/esphome/my_components - source: type: git url: https://github.com/SmartHome-yourself/sonoff-tx-ultimate-for-esphome ref: main components: [tx_ultimate_touch] - - globals: - id: nightlight_color type: int [3] @@ -221,20 +187,17 @@ globals: type: int [3] restore_value: no initial_value: ${cover_color2} - binary_sensor: - platform: template name: "Touchfield 1" id: touchfield_1 on_press: - script.execute: cover_open_action - - delay: ${button_on_time} - binary_sensor.template.publish: id: touchfield_1 state: OFF - script.execute: refresh_led_default - - platform: template name: "Touchfield 2" id: touchfield_2 @@ -250,13 +213,11 @@ binary_sensor: - switch.toggle: relay_3 else: - script.execute: cover_close_action - - delay: ${button_on_time} - binary_sensor.template.publish: id: touchfield_2 state: OFF - script.execute: refresh_led_default - - platform: template name: "Touchfield 3" id: touchfield_3 @@ -267,7 +228,6 @@ binary_sensor: id: touchfield_3 state: OFF - script.execute: refresh_led_default - - platform: template name: "Swipe left" id: swipe_left @@ -277,7 +237,6 @@ binary_sensor: id: swipe_left state: OFF - script.execute: refresh_led_default - - platform: template name: "Swipe_right" id: swipe_right @@ -287,7 +246,6 @@ binary_sensor: id: swipe_right state: OFF - script.execute: refresh_led_default - - platform: template name: "Multi Touch" id: multi_touch @@ -297,7 +255,6 @@ binary_sensor: id: multi_touch state: OFF - script.execute: refresh_led_default - - platform: template name: "Long Press" id: long_press @@ -307,7 +264,6 @@ binary_sensor: id: long_press state: OFF - script.execute: refresh_led_default - switch: - platform: gpio id: relay_1 @@ -322,7 +278,6 @@ switch: on_turn_off: then: - script.execute: refresh_led_default - - platform: gpio id: relay_2 name: "${friendly_name} L2" @@ -336,7 +291,6 @@ switch: on_turn_off: then: - script.execute: refresh_led_default - - platform: gpio id: relay_3 name: "${friendly_name} L3" @@ -348,7 +302,6 @@ switch: on_turn_off: then: - script.execute: refresh_led_default - - platform: gpio id: vibra pin: ${vibra_motor_pin} @@ -357,14 +310,12 @@ switch: on_turn_on: - delay: ${vibra_time} - switch.turn_off: vibra - - platform: gpio id: pa_power pin: ${pa_power_pin} name: "PA Power" internal: true restore_mode: ALWAYS_ON - - platform: gpio name: "touch panel power" pin: @@ -373,7 +324,6 @@ switch: id: touch_power internal: true restore_mode: RESTORE_DEFAULT_ON - - platform: template name: "Nightlight" id: nightlight @@ -386,7 +336,6 @@ switch: on_turn_off: then: - script.execute: refresh_led_default - - platform: template name: "Nightlight" id: nightlight_active @@ -398,10 +347,8 @@ switch: on_turn_off: then: - script.execute: refresh_led_default - - platform: restart name: "${friendly_name} Restart" - light: - platform: neopixelbus type: GRB @@ -420,11 +367,9 @@ light: name: "Pulse" transition_length: 1.4s update_interval: 1s - on_turn_off: then: - script.execute: refresh_led_default - - platform: partition name: "LEDs Button right" id: leds_button_right @@ -452,7 +397,6 @@ light: - id: leds from: 25 to: 30 - - platform: partition name: "LEDs Nightlight" id: leds_nightlight @@ -461,7 +405,6 @@ light: - id: leds from: 0 to: 31 - - platform: partition name: "LEDs Top" id: leds_top @@ -480,7 +423,6 @@ light: name: "Rainbow" speed: 10 width: 20 - - platform: partition name: "LEDs Left" id: leds_left @@ -494,7 +436,6 @@ light: name: "Pulse" transition_length: 600ms update_interval: 300ms - - platform: partition name: "LEDs Right" id: leds_right @@ -517,7 +458,6 @@ light: if (pos < 7){ it.range(0, 7-pos) = ESPColor(id(cover_color2)[0],id(cover_color2)[1],id(cover_color2)[2]); } - media_player: - platform: i2s_audio id: media_out @@ -527,12 +467,10 @@ media_player: i2s_audio_id: audio_i2s i2s_comm_fmt: lsb mode: mono - i2s_audio: id: audio_i2s i2s_lrclk_pin: ${audio_lrclk_pin} i2s_bclk_pin: ${audio_bclk_pin} - uart: tx_pin: ${uart_tx_pin} rx_pin: ${uart_rx_pin} @@ -549,13 +487,11 @@ uart: bytes: 2048 sequence: - lambda: UARTDebug::log_hex(direction, bytes, ' '); - tx_ultimate_touch: id: tx_touch uart: my_uart - on_press: -# - script.execute: led_on_touch + # - script.execute: led_on_touch - lambda: > ESP_LOGD("tx_ultimate_touch.on_press", "Touch Position: %d / State: %d", touch.x, touch.state); @@ -563,57 +499,43 @@ tx_ultimate_touch: - script.execute: id: handle_release pos: !lambda "return touch.x;" - - switch.turn_on: vibra - - lambda: > ESP_LOGD("tx_ultimate_touch.on_release", "Release Position: %d / State: %d", touch.x, touch.state); on_swipe_left: - script.execute: led_on_swipe_left - - switch.turn_on: vibra - - binary_sensor.template.publish: id: swipe_left state: ON - - lambda: > ESP_LOGD("tx_ultimate_touch.on_swipe_left", "Swipe Left Position: %d / State: %d", touch.x, touch.state); on_swipe_right: - script.execute: led_on_swipe_right - - switch.turn_on: vibra - - binary_sensor.template.publish: id: swipe_right state: ON - - lambda: > ESP_LOGD("tx_ultimate_touch.on_swipe_right", "Swipe Right Position: %d / State: %d", touch.x, touch.state); on_full_touch_release: - script.execute: led_on_full_touch - - switch.turn_on: vibra - - binary_sensor.template.publish: id: multi_touch state: ON - - lambda: > ESP_LOGD("tx_ultimate_touch.on_full_touch_release", "Full Touch Release Position: %d / State: %d", touch.x, touch.state); on_long_touch_release: - script.execute: led_on_long_touch - - switch.turn_on: vibra - - binary_sensor.template.publish: id: long_press state: ON - - lambda: > ESP_LOGD("tx_ultimate_touch.on_long_touch_release", "Long Touch Release Position: %d / State: %d", touch.x, touch.state); @@ -626,17 +548,14 @@ time: minutes: /5 then: - script.execute: refresh_nightlight - sun: latitude: ${latitude} longitude: ${longitude} - cover: - platform: time_based name: ${cover_name} id: my_cover assumed_state: false - open_action: - light.turn_on: id: leds_right @@ -644,7 +563,6 @@ cover: effect: "Cover Position" - script.execute: open_cover open_duration: ${cover_open_duration} - close_action: - light.turn_on: id: leds_right @@ -652,27 +570,22 @@ cover: effect: "Cover Position" - script.execute: close_cover close_duration: ${cover_close_duration} - stop_action: - script.execute: stop_cover - script: - id: open_cover mode: restart then: - switch.turn_on: relay_1 - - id: close_cover mode: restart then: - switch.turn_on: relay_2 - - id: stop_cover mode: restart then: - switch.turn_off: relay_1 - switch.turn_off: relay_2 - - id: refresh_nightlight mode: restart then: @@ -689,7 +602,6 @@ script: else: - switch.turn_off: id: nightlight - - id: refresh_led_default mode: restart then: @@ -697,16 +609,15 @@ script: condition: lambda: "return id(nightlight).state || id(nightlight_active).state;" then: - - light.turn_on: + - light.turn_on: id: leds_top brightness: ${nightlight_brightness} effect: "None" - script.execute: led_on_nightlight else: - - light.turn_off: + - light.turn_off: id: leds_top - light.turn_off: leds_nightlight - - if: condition: lambda: "return (id(relay_1).state) ;" @@ -714,7 +625,6 @@ script: - script.execute: led_on_button_left else: - script.execute: led_off_button_left - - if: condition: lambda: "return (${relay_count}==3 && id(relay_3).state);" @@ -722,7 +632,6 @@ script: - script.execute: led_on_button_middle else: - script.execute: led_off_button_middle - - if: condition: lambda: "return id(relay_2).state;" @@ -730,7 +639,6 @@ script: - script.execute: led_on_button_right else: - script.execute: led_off_button_right - - id: led_on_button_left mode: restart then: @@ -740,7 +648,6 @@ script: red: !lambda "return id(button_color)[0]/100.0;" green: !lambda "return id(button_color)[1]/100.0;" blue: !lambda "return id(button_color)[2]/100.0;" - - id: led_on_button_middle mode: restart then: @@ -750,7 +657,6 @@ script: red: !lambda "return id(button_color)[0]/100.0;" green: !lambda "return id(button_color)[1]/100.0;" blue: !lambda "return id(button_color)[2]/100.0;" - - id: led_on_button_right mode: restart then: @@ -760,7 +666,6 @@ script: red: !lambda "return id(button_color)[0]/100.0;" green: !lambda "return id(button_color)[1]/100.0;" blue: !lambda "return id(button_color)[2]/100.0;" - - id: led_off_button_left mode: restart then: @@ -777,7 +682,6 @@ script: else: - light.turn_off: id: leds_button_left - - id: led_off_button_middle mode: restart then: @@ -794,7 +698,6 @@ script: else: - light.turn_off: id: leds_button_middle - - id: led_off_button_right mode: restart then: @@ -811,7 +714,6 @@ script: else: - light.turn_off: id: leds_button_right - - id: led_on_nightlight mode: restart then: @@ -821,15 +723,13 @@ script: red: !lambda "return id(nightlight_color)[0]/100.0;" green: !lambda "return id(nightlight_color)[1]/100.0;" blue: !lambda "return id(nightlight_color)[2]/100.0;" - effect: "None" - + effect: "None" - id: led_on_release mode: restart then: -# - light.turn_off: -# id: leds_top + # - light.turn_off: + # id: leds_top - script.execute: refresh_led_default - - id: led_on_touch mode: restart then: @@ -842,7 +742,6 @@ script: effect: ${touch_effect} - delay: 6s - script.execute: refresh_led_default - - id: led_on_swipe_left mode: restart then: @@ -857,7 +756,6 @@ script: - light.turn_off: id: leds_left - script.execute: refresh_led_default - - id: led_on_swipe_right mode: restart then: @@ -872,7 +770,6 @@ script: - light.turn_on: id: leds_right effect: "Cover Position" - - id: led_on_full_touch mode: restart then: @@ -883,7 +780,6 @@ script: green: !lambda "return id(multi_touch_color)[1]/100.0;" blue: !lambda "return id(multi_touch_color)[2]/100.0;" effect: ${multi_touch_effect} - - id: led_on_long_touch mode: restart then: @@ -894,7 +790,6 @@ script: green: !lambda "return id(long_press_color)[1]/100.0;" blue: !lambda "return id(long_press_color)[2]/100.0;" effect: ${long_press_effect} - - id: handle_release mode: restart parameters: @@ -907,7 +802,6 @@ script: - binary_sensor.template.publish: id: touchfield_1 state: ON - - if: condition: lambda: "return ${relay_count}==2;" @@ -919,12 +813,10 @@ script: - binary_sensor.template.publish: id: touchfield_1 state: ON - else: - binary_sensor.template.publish: id: touchfield_2 state: ON - - if: condition: lambda: "return ${relay_count}==3;" @@ -936,7 +828,6 @@ script: - binary_sensor.template.publish: id: touchfield_1 state: ON - else: - if: condition: @@ -945,12 +836,10 @@ script: - binary_sensor.template.publish: id: touchfield_2 state: ON - else: - binary_sensor.template.publish: id: touchfield_3 state: ON - - id: cover_open_action mode: restart then: @@ -960,7 +849,6 @@ script: } else { id(my_cover).make_call().set_command_stop().perform(); } - - id: cover_close_action mode: restart then: diff --git a/tx_ultimate_local.yaml b/tx_ultimate_local.yaml index 6e58653..731afb5 100644 --- a/tx_ultimate_local.yaml +++ b/tx_ultimate_local.yaml @@ -1,74 +1,54 @@ substitutions: name: "shys-tx-ultimate" friendly_name: "TX Ultimate" - relay_count: "2" - toggle_relay_1_on_touch: "true" toggle_relay_2_on_touch: "true" toggle_relay_3_on_touch: "true" - vibra_time: 150ms button_on_time: 500ms - button_brightness: "0.7" button_color: "{0,0,100}" - nightlight: "on" nightlight_brightness: "0.2" nightlight_color: "{80,70,0}" - latitude: "50.123456°" longitude: "5.654321°" - touch_brightness: "1" touch_color: "{0,100,100}" touch_effect: "Scan" - long_press_brightness: "1" long_press_color: "{100,0,0}" long_press_effect: "" - multi_touch_brightness: "1" multi_touch_color: "{0,0,0}" multi_touch_effect: "Rainbow" - swipe_left_brightness: "1" swipe_left_color: "{0,100,0}" swipe_left_effect: "" - swipe_right_brightness: "1" swipe_right_color: "{100,0,70}" swipe_right_effect: "" - relay_1_pin: GPIO18 relay_2_pin: GPIO17 relay_3_pin: GPIO27 relay_4_pin: GPIO23 - vibra_motor_pin: GPIO21 pa_power_pin: GPIO26 - led_pin: GPIO13 status_led_pin: GPIO33 - uart_tx_pin: GPIO19 uart_rx_pin: GPIO22 - audio_lrclk_pin: GPIO4 audio_bclk_pin: GPIO2 audio_sdata_pin: GPIO15 - touchpanel_power_pin: GPIO5 - - esphome: name: ${name} friendly_name: ${friendly_name} project: name: smarthomeyourself.tx_ultimate version: "1.0" - on_boot: priority: -100 then: @@ -95,14 +75,12 @@ esphome: state: OFF - script.execute: refresh_led_default - script.execute: refresh_nightlight - esp32: board: esp32dev framework: type: arduino - logger: -# hardware_uart: UART2 + # hardware_uart: UART2 level: DEBUG logs: binary_sensor: INFO @@ -111,33 +89,23 @@ logger: switch: INFO tx_ultimate_touch: INFO uart_debug: INFO - api: - ota: - - platform: esphome - + - platform: esphome wifi: ssid: !secret wifi_ssid password: !secret wifi_password - ap: password: "12345678" - improv_serial: - captive_portal: - external_components: -# - source: /config/esphome/my_components + # - source: /config/esphome/my_components - source: type: git url: https://github.com/SmartHome-yourself/sonoff-tx-ultimate-for-esphome ref: main components: [tx_ultimate_touch] - - - globals: - id: nightlight_color type: int [3] @@ -166,10 +134,7 @@ globals: - id: touch_color type: int [3] restore_value: no - initial_value: ${touch_color} - - - + initial_value: ${touch_color} binary_sensor: - platform: template name: "Touchfield 1" @@ -185,7 +150,6 @@ binary_sensor: id: touchfield_1 state: OFF - script.execute: refresh_led_default - - platform: template name: "Touchfield 2" id: touchfield_2 @@ -200,7 +164,6 @@ binary_sensor: id: touchfield_2 state: OFF - script.execute: refresh_led_default - - platform: template name: "Touchfield 3" id: touchfield_3 @@ -215,7 +178,6 @@ binary_sensor: id: touchfield_3 state: OFF - script.execute: refresh_led_default - - platform: template name: "Swipe left" id: swipe_left @@ -225,7 +187,6 @@ binary_sensor: id: swipe_left state: OFF - script.execute: refresh_led_default - - platform: template name: "Swipe_right" id: swipe_right @@ -235,7 +196,6 @@ binary_sensor: id: swipe_right state: OFF - script.execute: refresh_led_default - - platform: template name: "Multi Touch" id: multi_touch @@ -245,7 +205,6 @@ binary_sensor: id: multi_touch state: OFF - script.execute: refresh_led_default - - platform: template name: "Long Press" id: long_press @@ -255,7 +214,6 @@ binary_sensor: id: long_press state: OFF - script.execute: refresh_led_default - switch: - platform: gpio id: relay_1 @@ -268,7 +226,6 @@ switch: on_turn_off: then: - script.execute: refresh_led_default - - platform: gpio id: relay_2 name: "${friendly_name} L2" @@ -280,7 +237,6 @@ switch: on_turn_off: then: - script.execute: refresh_led_default - - platform: gpio id: relay_3 name: "${friendly_name} L3" @@ -292,7 +248,6 @@ switch: on_turn_off: then: - script.execute: refresh_led_default - - platform: gpio id: vibra pin: ${vibra_motor_pin} @@ -301,14 +256,12 @@ switch: on_turn_on: - delay: ${vibra_time} - switch.turn_off: vibra - - platform: gpio id: pa_power pin: ${pa_power_pin} name: "PA Power" internal: true restore_mode: ALWAYS_ON - - platform: gpio name: "touch panel power" pin: @@ -317,7 +270,6 @@ switch: id: touch_power internal: true restore_mode: RESTORE_DEFAULT_ON - - platform: template name: "Nightlight" id: nightlight @@ -330,7 +282,6 @@ switch: on_turn_off: then: - script.execute: refresh_led_default - - platform: template name: "Nightlight" id: nightlight_active @@ -342,10 +293,8 @@ switch: on_turn_off: then: - script.execute: refresh_led_default - - platform: restart name: "${friendly_name} Restart" - light: - platform: neopixelbus type: GRB @@ -364,11 +313,9 @@ light: name: "Pulse" transition_length: 1.4s update_interval: 1s - on_turn_off: then: - script.execute: refresh_led_default - - platform: partition name: "LEDs Button right" id: leds_button_right @@ -393,7 +340,6 @@ light: - id: leds from: 11 to: 11 - - platform: partition name: "LEDs Nightlight" id: leds_nightlight @@ -417,7 +363,6 @@ light: - id: leds_top from: 0 to: 6 - - platform: partition name: "LEDs Top" id: leds_top @@ -433,7 +378,6 @@ light: name: "Rainbow" speed: 10 width: 20 - media_player: - platform: i2s_audio id: media_out @@ -443,12 +387,10 @@ media_player: i2s_audio_id: audio_i2s i2s_comm_fmt: lsb mode: mono - i2s_audio: id: audio_i2s i2s_lrclk_pin: ${audio_lrclk_pin} i2s_bclk_pin: ${audio_bclk_pin} - uart: tx_pin: ${uart_tx_pin} rx_pin: ${uart_rx_pin} @@ -465,11 +407,9 @@ uart: bytes: 2048 sequence: - lambda: UARTDebug::log_hex(direction, bytes, ' '); - tx_ultimate_touch: id: tx_touch uart: my_uart - on_press: - script.execute: led_on_touch - lambda: > @@ -479,57 +419,43 @@ tx_ultimate_touch: - script.execute: id: handle_release pos: !lambda "return touch.x;" - - switch.turn_on: vibra - - lambda: > ESP_LOGD("tx_ultimate_touch.on_release", "Release Position: %d / State: %d", touch.x, touch.state); on_swipe_left: - script.execute: led_on_swipe_left - - switch.turn_on: vibra - - binary_sensor.template.publish: id: swipe_left state: ON - - lambda: > ESP_LOGD("tx_ultimate_touch.on_swipe_left", "Swipe Left Position: %d / State: %d", touch.x, touch.state); on_swipe_right: - script.execute: led_on_swipe_right - - switch.turn_on: vibra - - binary_sensor.template.publish: id: swipe_right state: ON - - lambda: > ESP_LOGD("tx_ultimate_touch.on_swipe_right", "Swipe Right Position: %d / State: %d", touch.x, touch.state); on_full_touch_release: - script.execute: led_on_full_touch - - switch.turn_on: vibra - - binary_sensor.template.publish: id: multi_touch state: ON - - lambda: > ESP_LOGD("tx_ultimate_touch.on_full_touch_release", "Full Touch Release Position: %d / State: %d", touch.x, touch.state); on_long_touch_release: - script.execute: led_on_long_touch - - switch.turn_on: vibra - - binary_sensor.template.publish: id: long_press state: ON - - lambda: > ESP_LOGD("tx_ultimate_touch.on_long_touch_release", "Long Touch Release Position: %d / State: %d", touch.x, touch.state); @@ -544,12 +470,9 @@ time: minutes: /5 then: - script.execute: refresh_nightlight - sun: latitude: ${latitude} longitude: ${longitude} - - script: - id: refresh_nightlight mode: restart @@ -567,12 +490,10 @@ script: else: - switch.turn_off: id: nightlight - - id: refresh_led_default mode: restart then: - light.turn_off: leds_top - - if: condition: lambda: "return (${relay_count}>1 && id(relay_1).state) ;" @@ -580,7 +501,6 @@ script: - script.execute: led_on_button_left else: - script.execute: led_off_button_left - - if: condition: lambda: "return (${relay_count}==3 && id(relay_2).state) || (${relay_count}==1 && id(relay_1).state);" @@ -588,7 +508,6 @@ script: - script.execute: led_on_button_middle else: - script.execute: led_off_button_middle - - if: condition: lambda: "return (${relay_count}==2 && id(relay_2).state) || (${relay_count}==3 && id(relay_3).state);" @@ -596,7 +515,6 @@ script: - script.execute: led_on_button_right else: - script.execute: led_off_button_right - - if: condition: lambda: "return id(nightlight).state || id(nightlight_active).state;" @@ -604,7 +522,6 @@ script: - script.execute: led_on_nightlight else: - light.turn_off: leds_nightlight - - id: led_on_button_left mode: restart then: @@ -613,8 +530,7 @@ script: brightness: ${button_brightness} red: !lambda "return id(button_color)[0]/100.0;" green: !lambda "return id(button_color)[1]/100.0;" - blue: !lambda "return id(button_color)[2]/100.0;" - + blue: !lambda "return id(button_color)[2]/100.0;" - id: led_on_button_middle mode: restart then: @@ -623,8 +539,7 @@ script: brightness: ${button_brightness} red: !lambda "return id(button_color)[0]/100.0;" green: !lambda "return id(button_color)[1]/100.0;" - blue: !lambda "return id(button_color)[2]/100.0;" - + blue: !lambda "return id(button_color)[2]/100.0;" - id: led_on_button_right mode: restart then: @@ -633,9 +548,7 @@ script: brightness: ${button_brightness} red: !lambda "return id(button_color)[0]/100.0;" green: !lambda "return id(button_color)[1]/100.0;" - blue: !lambda "return id(button_color)[2]/100.0;" - - + blue: !lambda "return id(button_color)[2]/100.0;" - id: led_off_button_left mode: restart then: @@ -648,11 +561,10 @@ script: brightness: ${nightlight_brightness} red: !lambda "return id(nightlight_color)[0]/100.0;" green: !lambda "return id(nightlight_color)[1]/100.0;" - blue: !lambda "return id(nightlight_color)[2]/100.0;" + blue: !lambda "return id(nightlight_color)[2]/100.0;" else: - light.turn_off: id: leds_button_left - - id: led_off_button_middle mode: restart then: @@ -665,12 +577,10 @@ script: brightness: ${nightlight_brightness} red: !lambda "return id(nightlight_color)[0]/100.0;" green: !lambda "return id(nightlight_color)[1]/100.0;" - blue: !lambda "return id(nightlight_color)[2]/100.0;" + blue: !lambda "return id(nightlight_color)[2]/100.0;" else: - light.turn_off: id: leds_button_middle - - - id: led_off_button_right mode: restart then: @@ -683,12 +593,10 @@ script: brightness: ${nightlight_brightness} red: !lambda "return id(nightlight_color)[0]/100.0;" green: !lambda "return id(nightlight_color)[1]/100.0;" - blue: !lambda "return id(nightlight_color)[2]/100.0;" + blue: !lambda "return id(nightlight_color)[2]/100.0;" else: - light.turn_off: id: leds_button_right - - - id: led_on_nightlight mode: restart then: @@ -697,14 +605,12 @@ script: brightness: ${nightlight_brightness} red: !lambda "return id(nightlight_color)[0]/100.0;" green: !lambda "return id(nightlight_color)[1]/100.0;" - blue: !lambda "return id(nightlight_color)[2]/100.0;" - + blue: !lambda "return id(nightlight_color)[2]/100.0;" - id: led_on_release mode: restart then: - light.turn_off: id: leds_top - - id: led_on_touch mode: restart then: @@ -713,11 +619,10 @@ script: brightness: ${touch_brightness} red: !lambda "return id(touch_color)[0]/100.0;" green: !lambda "return id(touch_color)[1]/100.0;" - blue: !lambda "return id(touch_color)[2]/100.0;" + blue: !lambda "return id(touch_color)[2]/100.0;" effect: ${touch_effect} - delay: 6s - script.execute: refresh_led_default - - id: led_on_swipe_left mode: restart then: @@ -726,9 +631,8 @@ script: brightness: ${swipe_left_brightness} red: !lambda "return id(swipe_left_color)[0]/100.0;" green: !lambda "return id(swipe_left_color)[1]/100.0;" - blue: !lambda "return id(swipe_left_color)[2]/100.0;" + blue: !lambda "return id(swipe_left_color)[2]/100.0;" effect: ${swipe_left_effect} - - id: led_on_swipe_right mode: restart then: @@ -737,9 +641,8 @@ script: brightness: ${swipe_right_brightness} red: !lambda "return id(swipe_right_color)[0]/100.0;" green: !lambda "return id(swipe_right_color)[1]/100.0;" - blue: !lambda "return id(swipe_right_color)[2]/100.0;" + blue: !lambda "return id(swipe_right_color)[2]/100.0;" effect: ${swipe_right_effect} - - id: led_on_full_touch mode: restart then: @@ -748,10 +651,8 @@ script: brightness: ${multi_touch_brightness} red: !lambda "return id(multi_touch_color)[0]/100.0;" green: !lambda "return id(multi_touch_color)[1]/100.0;" - blue: !lambda "return id(multi_touch_color)[2]/100.0;" + blue: !lambda "return id(multi_touch_color)[2]/100.0;" effect: ${multi_touch_effect} - - - id: led_on_long_touch mode: restart then: @@ -760,10 +661,8 @@ script: brightness: ${long_press_brightness} red: !lambda "return id(long_press_color)[0]/100.0;" green: !lambda "return id(long_press_color)[1]/100.0;" - blue: !lambda "return id(long_press_color)[2]/100.0;" + blue: !lambda "return id(long_press_color)[2]/100.0;" effect: ${long_press_effect} - - - id: handle_release mode: restart parameters: @@ -776,7 +675,6 @@ script: - binary_sensor.template.publish: id: touchfield_1 state: ON - - if: condition: lambda: "return ${relay_count}==2;" @@ -788,12 +686,10 @@ script: - binary_sensor.template.publish: id: touchfield_1 state: ON - else: - binary_sensor.template.publish: id: touchfield_2 state: ON - - if: condition: lambda: "return ${relay_count}==3;" @@ -805,7 +701,6 @@ script: - binary_sensor.template.publish: id: touchfield_1 state: ON - else: - if: condition: @@ -814,12 +709,10 @@ script: - binary_sensor.template.publish: id: touchfield_2 state: ON - else: - binary_sensor.template.publish: id: touchfield_3 state: ON - - id: touch_led_marker mode: restart parameters: @@ -832,7 +725,6 @@ script: then: # RELEASE - light.turn_off: leds - else: - if: condition: @@ -846,7 +738,6 @@ script: blue: 0 - delay: 6s - light.turn_off: leds - else: - if: condition: @@ -858,7 +749,6 @@ script: effect: "Rainbow" - delay: 1s - light.turn_off: leds - else: # SWIPE - if: @@ -871,7 +761,6 @@ script: red: 0 green: 1 blue: 0 - - if: condition: lambda: "return state==12;" diff --git a/tx_ultimate_local_us.yaml b/tx_ultimate_local_us.yaml index afcb1a7..964ff83 100644 --- a/tx_ultimate_local_us.yaml +++ b/tx_ultimate_local_us.yaml @@ -1,70 +1,51 @@ substitutions: name: "shys-tx-ultimate" friendly_name: "TX Ultimate" - relay_count: "2" - vibra_time: 150ms button_on_time: 500ms - button_brightness: "0.7" button_color: "{0,0,100}" - nightlight: "on" nightlight_brightness: "0.2" nightlight_color: "{80,70,0}" - latitude: "50.123456°" longitude: "5.654321°" - touch_brightness: "1" touch_color: "{0,100,100}" touch_effect: "Scan" - long_press_brightness: "1" long_press_color: "{100,0,0}" long_press_effect: "" - multi_touch_brightness: "1" multi_touch_color: "{0,0,0}" multi_touch_effect: "Rainbow" - swipe_left_brightness: "1" swipe_left_color: "{0,100,0}" swipe_left_effect: "" - swipe_right_brightness: "1" swipe_right_color: "{100,0,70}" swipe_right_effect: "" - relay_1_pin: GPIO18 relay_2_pin: GPIO17 relay_3_pin: GPIO27 relay_4_pin: GPIO23 - vibra_motor_pin: GPIO21 pa_power_pin: GPIO26 - led_pin: GPIO13 status_led_pin: GPIO33 - uart_tx_pin: GPIO19 uart_rx_pin: GPIO22 - audio_lrclk_pin: GPIO4 audio_bclk_pin: GPIO2 audio_sdata_pin: GPIO15 - touchpanel_power_pin: GPIO5 - - esphome: name: ${name} friendly_name: ${friendly_name} project: name: smarthomeyourself.tx_ultimate version: "1.0" - on_boot: priority: -100 then: @@ -94,14 +75,12 @@ esphome: state: OFF - script.execute: refresh_led_default - script.execute: refresh_nightlight - esp32: board: esp32dev framework: type: arduino - logger: -# hardware_uart: UART2 + # hardware_uart: UART2 level: DEBUG logs: binary_sensor: INFO @@ -110,30 +89,21 @@ logger: switch: INFO tx_ultimate_touch: INFO uart_debug: INFO - api: - ota: - - platform: esphome - + - platform: esphome wifi: ap: password: "12345678" - improv_serial: - captive_portal: - external_components: -# - source: /config/esphome/my_components + # - source: /config/esphome/my_components - source: type: git url: https://github.com/SmartHome-yourself/sonoff-tx-ultimate-for-esphome ref: main components: [tx_ultimate_touch] - - - globals: - id: nightlight_color type: int [3] @@ -162,10 +132,7 @@ globals: - id: touch_color type: int [3] restore_value: no - initial_value: ${touch_color} - - - + initial_value: ${touch_color} binary_sensor: - platform: template name: "Touchfield 1" @@ -177,7 +144,6 @@ binary_sensor: id: touchfield_1 state: OFF - script.execute: refresh_led_default - - platform: template name: "Touchfield 2" id: touchfield_2 @@ -188,7 +154,6 @@ binary_sensor: id: touchfield_2 state: OFF - script.execute: refresh_led_default - - platform: template name: "Touchfield 3" id: touchfield_3 @@ -199,7 +164,6 @@ binary_sensor: id: touchfield_3 state: OFF - script.execute: refresh_led_default - - platform: template name: "Touchfield 4" id: touchfield_4 @@ -210,7 +174,6 @@ binary_sensor: id: touchfield_4 state: OFF - script.execute: refresh_led_default - - platform: template name: "Swipe left" id: swipe_left @@ -220,7 +183,6 @@ binary_sensor: id: swipe_left state: OFF - script.execute: refresh_led_default - - platform: template name: "Swipe_right" id: swipe_right @@ -230,7 +192,6 @@ binary_sensor: id: swipe_right state: OFF - script.execute: refresh_led_default - - platform: template name: "Multi Touch" id: multi_touch @@ -240,7 +201,6 @@ binary_sensor: id: multi_touch state: OFF - script.execute: refresh_led_default - - platform: template name: "Long Press" id: long_press @@ -250,7 +210,6 @@ binary_sensor: id: long_press state: OFF - script.execute: refresh_led_default - switch: - platform: gpio id: relay_1 @@ -263,7 +222,6 @@ switch: on_turn_off: then: - script.execute: refresh_led_default - - platform: gpio id: relay_2 name: "${friendly_name} L2" @@ -275,7 +233,6 @@ switch: on_turn_off: then: - script.execute: refresh_led_default - - platform: gpio id: relay_3 name: "${friendly_name} L3" @@ -287,7 +244,6 @@ switch: on_turn_off: then: - script.execute: refresh_led_default - - platform: gpio id: relay_4 name: "${friendly_name} L4" @@ -299,7 +255,6 @@ switch: on_turn_off: then: - script.execute: refresh_led_default - - platform: gpio id: vibra pin: ${vibra_motor_pin} @@ -308,14 +263,12 @@ switch: on_turn_on: - delay: ${vibra_time} - switch.turn_off: vibra - - platform: gpio id: pa_power pin: ${pa_power_pin} name: "PA Power" internal: true restore_mode: ALWAYS_ON - - platform: gpio name: "touch panel power" pin: @@ -324,7 +277,6 @@ switch: id: touch_power internal: true restore_mode: RESTORE_DEFAULT_ON - - platform: template name: "Nightlight" id: nightlight @@ -337,7 +289,6 @@ switch: on_turn_off: then: - script.execute: refresh_led_default - - platform: template name: "Nightlight" id: nightlight_active @@ -349,10 +300,8 @@ switch: on_turn_off: then: - script.execute: refresh_led_default - - platform: restart name: "${friendly_name} Restart" - light: - platform: neopixelbus type: GRB @@ -371,11 +320,9 @@ light: name: "Pulse" transition_length: 1.4s update_interval: 1s - on_turn_off: then: - script.execute: refresh_led_default - - platform: partition name: "LEDs Button right" id: leds_button_right @@ -403,7 +350,6 @@ light: - id: leds from: 25 to: 30 - - platform: partition name: "LEDs Nightlight" id: leds_nightlight @@ -412,7 +358,6 @@ light: - id: leds from: 0 to: 31 - - platform: partition name: "LEDs Top" id: leds_top @@ -431,7 +376,6 @@ light: name: "Rainbow" speed: 10 width: 20 - media_player: - platform: i2s_audio id: media_out @@ -441,12 +385,10 @@ media_player: i2s_audio_id: audio_i2s i2s_comm_fmt: lsb mode: mono - i2s_audio: id: audio_i2s i2s_lrclk_pin: ${audio_lrclk_pin} i2s_bclk_pin: ${audio_bclk_pin} - uart: tx_pin: ${uart_tx_pin} rx_pin: ${uart_rx_pin} @@ -463,11 +405,9 @@ uart: bytes: 2048 sequence: - lambda: UARTDebug::log_hex(direction, bytes, ' '); - tx_ultimate_touch: id: tx_touch uart: my_uart - on_press: - script.execute: led_on_touch - lambda: > @@ -477,57 +417,43 @@ tx_ultimate_touch: - script.execute: id: handle_release pos: !lambda "return touch.x;" - - switch.turn_on: vibra - - lambda: > ESP_LOGD("tx_ultimate_touch.on_release", "Release Position: %d / State: %d", touch.x, touch.state); on_swipe_left: - script.execute: led_on_swipe_left - - switch.turn_on: vibra - - binary_sensor.template.publish: id: swipe_left state: ON - - lambda: > ESP_LOGD("tx_ultimate_touch.on_swipe_left", "Swipe Left Position: %d / State: %d", touch.x, touch.state); on_swipe_right: - script.execute: led_on_swipe_right - - switch.turn_on: vibra - - binary_sensor.template.publish: id: swipe_right state: ON - - lambda: > ESP_LOGD("tx_ultimate_touch.on_swipe_right", "Swipe Right Position: %d / State: %d", touch.x, touch.state); on_full_touch_release: - script.execute: led_on_full_touch - - switch.turn_on: vibra - - binary_sensor.template.publish: id: multi_touch state: ON - - lambda: > ESP_LOGD("tx_ultimate_touch.on_full_touch_release", "Full Touch Release Position: %d / State: %d", touch.x, touch.state); on_long_touch_release: - script.execute: led_on_long_touch - - switch.turn_on: vibra - - binary_sensor.template.publish: id: long_press state: ON - - lambda: > ESP_LOGD("tx_ultimate_touch.on_long_touch_release", "Long Touch Release Position: %d / State: %d", touch.x, touch.state); @@ -540,12 +466,9 @@ time: minutes: /5 then: - script.execute: refresh_nightlight - sun: latitude: ${latitude} longitude: ${longitude} - - script: - id: refresh_nightlight mode: restart @@ -563,7 +486,6 @@ script: else: - switch.turn_off: id: nightlight - - id: refresh_led_default mode: restart then: @@ -571,16 +493,15 @@ script: condition: lambda: "return id(nightlight).state || id(nightlight_active).state;" then: - - light.turn_on: + - light.turn_on: id: leds_top brightness: ${nightlight_brightness} effect: "None" - script.execute: led_on_nightlight else: - - light.turn_off: + - light.turn_off: id: leds_top - light.turn_off: leds_nightlight - - if: condition: lambda: "return (id(relay_1).state) ;" @@ -588,7 +509,6 @@ script: - script.execute: led_on_button_left else: - script.execute: led_off_button_left - - if: condition: lambda: "return id(relay_2).state;" @@ -596,7 +516,6 @@ script: - script.execute: led_on_button_right else: - script.execute: led_off_button_right - - if: condition: lambda: "return (${relay_count}>=3 && id(relay_3).state);" @@ -604,7 +523,6 @@ script: - script.execute: led_on_button_middle else: - script.execute: led_off_button_middle - - if: condition: lambda: "return (${relay_count}==4 && id(relay_4).state);" @@ -612,7 +530,6 @@ script: - script.execute: led_on_button_middle else: - script.execute: led_off_button_middle - - id: led_on_button_left mode: restart then: @@ -621,8 +538,7 @@ script: brightness: ${button_brightness} red: !lambda "return id(button_color)[0]/100.0;" green: !lambda "return id(button_color)[1]/100.0;" - blue: !lambda "return id(button_color)[2]/100.0;" - + blue: !lambda "return id(button_color)[2]/100.0;" - id: led_on_button_middle mode: restart then: @@ -631,8 +547,7 @@ script: brightness: ${button_brightness} red: !lambda "return id(button_color)[0]/100.0;" green: !lambda "return id(button_color)[1]/100.0;" - blue: !lambda "return id(button_color)[2]/100.0;" - + blue: !lambda "return id(button_color)[2]/100.0;" - id: led_on_button_right mode: restart then: @@ -641,9 +556,7 @@ script: brightness: ${button_brightness} red: !lambda "return id(button_color)[0]/100.0;" green: !lambda "return id(button_color)[1]/100.0;" - blue: !lambda "return id(button_color)[2]/100.0;" - - + blue: !lambda "return id(button_color)[2]/100.0;" - id: led_off_button_left mode: restart then: @@ -656,11 +569,10 @@ script: brightness: ${nightlight_brightness} red: !lambda "return id(nightlight_color)[0]/100.0;" green: !lambda "return id(nightlight_color)[1]/100.0;" - blue: !lambda "return id(nightlight_color)[2]/100.0;" + blue: !lambda "return id(nightlight_color)[2]/100.0;" else: - light.turn_off: id: leds_button_left - - id: led_off_button_middle mode: restart then: @@ -673,12 +585,10 @@ script: brightness: ${nightlight_brightness} red: !lambda "return id(nightlight_color)[0]/100.0;" green: !lambda "return id(nightlight_color)[1]/100.0;" - blue: !lambda "return id(nightlight_color)[2]/100.0;" + blue: !lambda "return id(nightlight_color)[2]/100.0;" else: - light.turn_off: id: leds_button_middle - - - id: led_off_button_right mode: restart then: @@ -691,12 +601,10 @@ script: brightness: ${nightlight_brightness} red: !lambda "return id(nightlight_color)[0]/100.0;" green: !lambda "return id(nightlight_color)[1]/100.0;" - blue: !lambda "return id(nightlight_color)[2]/100.0;" + blue: !lambda "return id(nightlight_color)[2]/100.0;" else: - light.turn_off: id: leds_button_right - - - id: led_on_nightlight mode: restart then: @@ -705,14 +613,12 @@ script: brightness: ${nightlight_brightness} red: !lambda "return id(nightlight_color)[0]/100.0;" green: !lambda "return id(nightlight_color)[1]/100.0;" - blue: !lambda "return id(nightlight_color)[2]/100.0;" - + blue: !lambda "return id(nightlight_color)[2]/100.0;" - id: led_on_release mode: restart then: - light.turn_off: id: leds_top - - id: led_on_touch mode: restart then: @@ -721,11 +627,10 @@ script: brightness: ${touch_brightness} red: !lambda "return id(touch_color)[0]/100.0;" green: !lambda "return id(touch_color)[1]/100.0;" - blue: !lambda "return id(touch_color)[2]/100.0;" + blue: !lambda "return id(touch_color)[2]/100.0;" effect: ${touch_effect} - delay: 6s - script.execute: refresh_led_default - - id: led_on_swipe_left mode: restart then: @@ -734,9 +639,8 @@ script: brightness: ${swipe_left_brightness} red: !lambda "return id(swipe_left_color)[0]/100.0;" green: !lambda "return id(swipe_left_color)[1]/100.0;" - blue: !lambda "return id(swipe_left_color)[2]/100.0;" + blue: !lambda "return id(swipe_left_color)[2]/100.0;" effect: ${swipe_left_effect} - - id: led_on_swipe_right mode: restart then: @@ -745,9 +649,8 @@ script: brightness: ${swipe_right_brightness} red: !lambda "return id(swipe_right_color)[0]/100.0;" green: !lambda "return id(swipe_right_color)[1]/100.0;" - blue: !lambda "return id(swipe_right_color)[2]/100.0;" + blue: !lambda "return id(swipe_right_color)[2]/100.0;" effect: ${swipe_right_effect} - - id: led_on_full_touch mode: restart then: @@ -756,10 +659,8 @@ script: brightness: ${multi_touch_brightness} red: !lambda "return id(multi_touch_color)[0]/100.0;" green: !lambda "return id(multi_touch_color)[1]/100.0;" - blue: !lambda "return id(multi_touch_color)[2]/100.0;" + blue: !lambda "return id(multi_touch_color)[2]/100.0;" effect: ${multi_touch_effect} - - - id: led_on_long_touch mode: restart then: @@ -768,10 +669,8 @@ script: brightness: ${long_press_brightness} red: !lambda "return id(long_press_color)[0]/100.0;" green: !lambda "return id(long_press_color)[1]/100.0;" - blue: !lambda "return id(long_press_color)[2]/100.0;" + blue: !lambda "return id(long_press_color)[2]/100.0;" effect: ${long_press_effect} - - - id: handle_release mode: restart parameters: @@ -784,7 +683,6 @@ script: - binary_sensor.template.publish: id: touchfield_1 state: ON - - if: condition: lambda: "return ${relay_count}==2;" @@ -796,12 +694,10 @@ script: - binary_sensor.template.publish: id: touchfield_1 state: ON - else: - binary_sensor.template.publish: id: touchfield_2 state: ON - - if: condition: lambda: "return ${relay_count}==3;" @@ -813,7 +709,6 @@ script: - binary_sensor.template.publish: id: touchfield_1 state: ON - else: - if: condition: @@ -822,12 +717,10 @@ script: - binary_sensor.template.publish: id: touchfield_2 state: ON - else: - binary_sensor.template.publish: id: touchfield_3 state: ON - - if: condition: lambda: "return ${relay_count}==4;" @@ -839,7 +732,6 @@ script: - binary_sensor.template.publish: id: touchfield_1 state: ON - else: - if: condition: @@ -848,7 +740,6 @@ script: - binary_sensor.template.publish: id: touchfield_2 state: ON - else: - if: condition: @@ -857,12 +748,10 @@ script: - binary_sensor.template.publish: id: touchfield_3 state: ON - else: - binary_sensor.template.publish: id: touchfield_4 state: ON - - id: touch_led_marker mode: restart parameters: @@ -875,7 +764,6 @@ script: then: # RELEASE - light.turn_off: leds - else: - if: condition: @@ -889,7 +777,6 @@ script: blue: 0 - delay: 6s - light.turn_off: leds - else: - if: condition: @@ -901,7 +788,6 @@ script: effect: "Rainbow" - delay: 1s - light.turn_off: leds - else: # SWIPE - if: @@ -914,7 +800,6 @@ script: red: 0 green: 1 blue: 0 - - if: condition: lambda: "return state==12;" diff --git a/tx_ultimate_us.yaml b/tx_ultimate_us.yaml index e19298a..0ac7135 100644 --- a/tx_ultimate_us.yaml +++ b/tx_ultimate_us.yaml @@ -1,70 +1,51 @@ substitutions: name: "shys-tx-ultimate" friendly_name: "TX Ultimate" - relay_count: "2" - vibra_time: 150ms button_on_time: 500ms - button_brightness: "0.7" button_color: "{0,0,100}" - nightlight: "on" nightlight_brightness: "0.2" nightlight_color: "{80,70,0}" - latitude: "50.123456°" longitude: "5.654321°" - touch_brightness: "1" touch_color: "{0,100,100}" touch_effect: "Scan" - long_press_brightness: "1" long_press_color: "{100,0,0}" long_press_effect: "" - multi_touch_brightness: "1" multi_touch_color: "{0,0,0}" multi_touch_effect: "Rainbow" - swipe_left_brightness: "1" swipe_left_color: "{0,100,0}" swipe_left_effect: "" - swipe_right_brightness: "1" swipe_right_color: "{100,0,70}" swipe_right_effect: "" - relay_1_pin: GPIO18 relay_2_pin: GPIO17 relay_3_pin: GPIO27 relay_4_pin: GPIO23 - vibra_motor_pin: GPIO21 pa_power_pin: GPIO26 - led_pin: GPIO13 status_led_pin: GPIO33 - uart_tx_pin: GPIO19 uart_rx_pin: GPIO22 - audio_lrclk_pin: GPIO4 audio_bclk_pin: GPIO2 audio_sdata_pin: GPIO15 - touchpanel_power_pin: GPIO5 - - esphome: name: ${name} friendly_name: ${friendly_name} project: name: smarthomeyourself.tx_ultimate version: "1.0" - on_boot: priority: -100 then: @@ -94,14 +75,12 @@ esphome: state: OFF - script.execute: refresh_led_default - script.execute: refresh_nightlight - esp32: board: esp32dev framework: type: arduino - logger: -# hardware_uart: UART2 + # hardware_uart: UART2 level: DEBUG logs: binary_sensor: INFO @@ -110,32 +89,24 @@ logger: switch: INFO tx_ultimate_touch: INFO uart_debug: INFO - dashboard_import: package_import_url: github://SmartHome-yourself/sonoff-tx-ultimate-for-esphome/tx_ultimate.yaml@main import_full_config: false - api: - ota: - - platform: esphome - + - platform: esphome wifi: ap: password: "12345678" - improv_serial: - captive_portal: - external_components: -# - source: /config/esphome/my_components + # - source: /config/esphome/my_components - source: type: git url: https://github.com/SmartHome-yourself/sonoff-tx-ultimate-for-esphome ref: main components: [tx_ultimate_touch] - globals: - id: nightlight_color type: int [3] @@ -164,10 +135,7 @@ globals: - id: touch_color type: int [3] restore_value: no - initial_value: ${touch_color} - - - + initial_value: ${touch_color} binary_sensor: - platform: template name: "Touchfield 1" @@ -179,7 +147,6 @@ binary_sensor: id: touchfield_1 state: OFF - script.execute: refresh_led_default - - platform: template name: "Touchfield 2" id: touchfield_2 @@ -190,7 +157,6 @@ binary_sensor: id: touchfield_2 state: OFF - script.execute: refresh_led_default - - platform: template name: "Touchfield 3" id: touchfield_3 @@ -201,7 +167,6 @@ binary_sensor: id: touchfield_3 state: OFF - script.execute: refresh_led_default - - platform: template name: "Touchfield 4" id: touchfield_4 @@ -212,7 +177,6 @@ binary_sensor: id: touchfield_4 state: OFF - script.execute: refresh_led_default - - platform: template name: "Swipe left" id: swipe_left @@ -222,7 +186,6 @@ binary_sensor: id: swipe_left state: OFF - script.execute: refresh_led_default - - platform: template name: "Swipe_right" id: swipe_right @@ -232,7 +195,6 @@ binary_sensor: id: swipe_right state: OFF - script.execute: refresh_led_default - - platform: template name: "Multi Touch" id: multi_touch @@ -242,7 +204,6 @@ binary_sensor: id: multi_touch state: OFF - script.execute: refresh_led_default - - platform: template name: "Long Press" id: long_press @@ -252,7 +213,6 @@ binary_sensor: id: long_press state: OFF - script.execute: refresh_led_default - switch: - platform: gpio id: relay_1 @@ -265,7 +225,6 @@ switch: on_turn_off: then: - script.execute: refresh_led_default - - platform: gpio id: relay_2 name: "${friendly_name} L2" @@ -277,7 +236,6 @@ switch: on_turn_off: then: - script.execute: refresh_led_default - - platform: gpio id: relay_3 name: "${friendly_name} L3" @@ -289,7 +247,6 @@ switch: on_turn_off: then: - script.execute: refresh_led_default - - platform: gpio id: relay_4 name: "${friendly_name} L4" @@ -301,7 +258,6 @@ switch: on_turn_off: then: - script.execute: refresh_led_default - - platform: gpio id: vibra pin: ${vibra_motor_pin} @@ -310,14 +266,12 @@ switch: on_turn_on: - delay: ${vibra_time} - switch.turn_off: vibra - - platform: gpio id: pa_power pin: ${pa_power_pin} name: "PA Power" internal: true restore_mode: ALWAYS_ON - - platform: gpio name: "touch panel power" pin: @@ -326,7 +280,6 @@ switch: id: touch_power internal: true restore_mode: RESTORE_DEFAULT_ON - - platform: template name: "Nightlight" id: nightlight @@ -339,7 +292,6 @@ switch: on_turn_off: then: - script.execute: refresh_led_default - - platform: template name: "Nightlight" id: nightlight_active @@ -351,10 +303,8 @@ switch: on_turn_off: then: - script.execute: refresh_led_default - - platform: restart name: "${friendly_name} Restart" - light: - platform: neopixelbus type: GRB @@ -373,11 +323,9 @@ light: name: "Pulse" transition_length: 1.4s update_interval: 1s - on_turn_off: then: - script.execute: refresh_led_default - - platform: partition name: "LEDs Button right" id: leds_button_right @@ -405,7 +353,6 @@ light: - id: leds from: 25 to: 30 - - platform: partition name: "LEDs Nightlight" id: leds_nightlight @@ -414,7 +361,6 @@ light: - id: leds from: 0 to: 31 - - platform: partition name: "LEDs Top" id: leds_top @@ -433,7 +379,6 @@ light: name: "Rainbow" speed: 10 width: 20 - media_player: - platform: i2s_audio id: media_out @@ -443,12 +388,10 @@ media_player: i2s_audio_id: audio_i2s i2s_comm_fmt: lsb mode: mono - i2s_audio: id: audio_i2s i2s_lrclk_pin: ${audio_lrclk_pin} i2s_bclk_pin: ${audio_bclk_pin} - uart: tx_pin: ${uart_tx_pin} rx_pin: ${uart_rx_pin} @@ -465,11 +408,9 @@ uart: bytes: 2048 sequence: - lambda: UARTDebug::log_hex(direction, bytes, ' '); - tx_ultimate_touch: id: tx_touch uart: my_uart - on_press: - script.execute: led_on_touch - lambda: > @@ -479,57 +420,43 @@ tx_ultimate_touch: - script.execute: id: handle_release pos: !lambda "return touch.x;" - - switch.turn_on: vibra - - lambda: > ESP_LOGD("tx_ultimate_touch.on_release", "Release Position: %d / State: %d", touch.x, touch.state); on_swipe_left: - script.execute: led_on_swipe_left - - switch.turn_on: vibra - - binary_sensor.template.publish: id: swipe_left state: ON - - lambda: > ESP_LOGD("tx_ultimate_touch.on_swipe_left", "Swipe Left Position: %d / State: %d", touch.x, touch.state); on_swipe_right: - script.execute: led_on_swipe_right - - switch.turn_on: vibra - - binary_sensor.template.publish: id: swipe_right state: ON - - lambda: > ESP_LOGD("tx_ultimate_touch.on_swipe_right", "Swipe Right Position: %d / State: %d", touch.x, touch.state); on_full_touch_release: - script.execute: led_on_full_touch - - switch.turn_on: vibra - - binary_sensor.template.publish: id: multi_touch state: ON - - lambda: > ESP_LOGD("tx_ultimate_touch.on_full_touch_release", "Full Touch Release Position: %d / State: %d", touch.x, touch.state); on_long_touch_release: - script.execute: led_on_long_touch - - switch.turn_on: vibra - - binary_sensor.template.publish: id: long_press state: ON - - lambda: > ESP_LOGD("tx_ultimate_touch.on_long_touch_release", "Long Touch Release Position: %d / State: %d", touch.x, touch.state); @@ -542,12 +469,9 @@ time: minutes: /5 then: - script.execute: refresh_nightlight - sun: latitude: ${latitude} longitude: ${longitude} - - script: - id: refresh_nightlight mode: restart @@ -565,7 +489,6 @@ script: else: - switch.turn_off: id: nightlight - - id: refresh_led_default mode: restart then: @@ -573,16 +496,15 @@ script: condition: lambda: "return id(nightlight).state || id(nightlight_active).state;" then: - - light.turn_on: + - light.turn_on: id: leds_top brightness: ${nightlight_brightness} effect: "None" - script.execute: led_on_nightlight else: - - light.turn_off: + - light.turn_off: id: leds_top - light.turn_off: leds_nightlight - - if: condition: lambda: "return (id(relay_1).state) ;" @@ -590,7 +512,6 @@ script: - script.execute: led_on_button_left else: - script.execute: led_off_button_left - - if: condition: lambda: "return id(relay_2).state;" @@ -598,7 +519,6 @@ script: - script.execute: led_on_button_right else: - script.execute: led_off_button_right - - if: condition: lambda: "return (${relay_count}>=3 && id(relay_3).state);" @@ -606,7 +526,6 @@ script: - script.execute: led_on_button_middle else: - script.execute: led_off_button_middle - - if: condition: lambda: "return (${relay_count}==4 && id(relay_4).state);" @@ -614,7 +533,6 @@ script: - script.execute: led_on_button_middle else: - script.execute: led_off_button_middle - - id: led_on_button_left mode: restart then: @@ -623,8 +541,7 @@ script: brightness: ${button_brightness} red: !lambda "return id(button_color)[0]/100.0;" green: !lambda "return id(button_color)[1]/100.0;" - blue: !lambda "return id(button_color)[2]/100.0;" - + blue: !lambda "return id(button_color)[2]/100.0;" - id: led_on_button_middle mode: restart then: @@ -633,8 +550,7 @@ script: brightness: ${button_brightness} red: !lambda "return id(button_color)[0]/100.0;" green: !lambda "return id(button_color)[1]/100.0;" - blue: !lambda "return id(button_color)[2]/100.0;" - + blue: !lambda "return id(button_color)[2]/100.0;" - id: led_on_button_right mode: restart then: @@ -643,9 +559,7 @@ script: brightness: ${button_brightness} red: !lambda "return id(button_color)[0]/100.0;" green: !lambda "return id(button_color)[1]/100.0;" - blue: !lambda "return id(button_color)[2]/100.0;" - - + blue: !lambda "return id(button_color)[2]/100.0;" - id: led_off_button_left mode: restart then: @@ -658,11 +572,10 @@ script: brightness: ${nightlight_brightness} red: !lambda "return id(nightlight_color)[0]/100.0;" green: !lambda "return id(nightlight_color)[1]/100.0;" - blue: !lambda "return id(nightlight_color)[2]/100.0;" + blue: !lambda "return id(nightlight_color)[2]/100.0;" else: - light.turn_off: id: leds_button_left - - id: led_off_button_middle mode: restart then: @@ -675,12 +588,10 @@ script: brightness: ${nightlight_brightness} red: !lambda "return id(nightlight_color)[0]/100.0;" green: !lambda "return id(nightlight_color)[1]/100.0;" - blue: !lambda "return id(nightlight_color)[2]/100.0;" + blue: !lambda "return id(nightlight_color)[2]/100.0;" else: - light.turn_off: id: leds_button_middle - - - id: led_off_button_right mode: restart then: @@ -693,12 +604,10 @@ script: brightness: ${nightlight_brightness} red: !lambda "return id(nightlight_color)[0]/100.0;" green: !lambda "return id(nightlight_color)[1]/100.0;" - blue: !lambda "return id(nightlight_color)[2]/100.0;" + blue: !lambda "return id(nightlight_color)[2]/100.0;" else: - light.turn_off: id: leds_button_right - - - id: led_on_nightlight mode: restart then: @@ -707,14 +616,12 @@ script: brightness: ${nightlight_brightness} red: !lambda "return id(nightlight_color)[0]/100.0;" green: !lambda "return id(nightlight_color)[1]/100.0;" - blue: !lambda "return id(nightlight_color)[2]/100.0;" - + blue: !lambda "return id(nightlight_color)[2]/100.0;" - id: led_on_release mode: restart then: - light.turn_off: id: leds_top - - id: led_on_touch mode: restart then: @@ -723,11 +630,10 @@ script: brightness: ${touch_brightness} red: !lambda "return id(touch_color)[0]/100.0;" green: !lambda "return id(touch_color)[1]/100.0;" - blue: !lambda "return id(touch_color)[2]/100.0;" + blue: !lambda "return id(touch_color)[2]/100.0;" effect: ${touch_effect} - delay: 6s - script.execute: refresh_led_default - - id: led_on_swipe_left mode: restart then: @@ -736,9 +642,8 @@ script: brightness: ${swipe_left_brightness} red: !lambda "return id(swipe_left_color)[0]/100.0;" green: !lambda "return id(swipe_left_color)[1]/100.0;" - blue: !lambda "return id(swipe_left_color)[2]/100.0;" + blue: !lambda "return id(swipe_left_color)[2]/100.0;" effect: ${swipe_left_effect} - - id: led_on_swipe_right mode: restart then: @@ -747,9 +652,8 @@ script: brightness: ${swipe_right_brightness} red: !lambda "return id(swipe_right_color)[0]/100.0;" green: !lambda "return id(swipe_right_color)[1]/100.0;" - blue: !lambda "return id(swipe_right_color)[2]/100.0;" + blue: !lambda "return id(swipe_right_color)[2]/100.0;" effect: ${swipe_right_effect} - - id: led_on_full_touch mode: restart then: @@ -758,10 +662,8 @@ script: brightness: ${multi_touch_brightness} red: !lambda "return id(multi_touch_color)[0]/100.0;" green: !lambda "return id(multi_touch_color)[1]/100.0;" - blue: !lambda "return id(multi_touch_color)[2]/100.0;" + blue: !lambda "return id(multi_touch_color)[2]/100.0;" effect: ${multi_touch_effect} - - - id: led_on_long_touch mode: restart then: @@ -770,10 +672,8 @@ script: brightness: ${long_press_brightness} red: !lambda "return id(long_press_color)[0]/100.0;" green: !lambda "return id(long_press_color)[1]/100.0;" - blue: !lambda "return id(long_press_color)[2]/100.0;" + blue: !lambda "return id(long_press_color)[2]/100.0;" effect: ${long_press_effect} - - - id: handle_release mode: restart parameters: @@ -786,7 +686,6 @@ script: - binary_sensor.template.publish: id: touchfield_1 state: ON - - if: condition: lambda: "return ${relay_count}==2;" @@ -798,12 +697,10 @@ script: - binary_sensor.template.publish: id: touchfield_1 state: ON - else: - binary_sensor.template.publish: id: touchfield_2 state: ON - - if: condition: lambda: "return ${relay_count}==3;" @@ -815,7 +712,6 @@ script: - binary_sensor.template.publish: id: touchfield_1 state: ON - else: - if: condition: @@ -824,12 +720,10 @@ script: - binary_sensor.template.publish: id: touchfield_2 state: ON - else: - binary_sensor.template.publish: id: touchfield_3 state: ON - - if: condition: lambda: "return ${relay_count}==4;" @@ -841,7 +735,6 @@ script: - binary_sensor.template.publish: id: touchfield_1 state: ON - else: - if: condition: @@ -850,7 +743,6 @@ script: - binary_sensor.template.publish: id: touchfield_2 state: ON - else: - if: condition: @@ -859,12 +751,10 @@ script: - binary_sensor.template.publish: id: touchfield_3 state: ON - else: - binary_sensor.template.publish: id: touchfield_4 state: ON - - id: touch_led_marker mode: restart parameters: @@ -877,7 +767,6 @@ script: then: # RELEASE - light.turn_off: leds - else: - if: condition: @@ -891,7 +780,6 @@ script: blue: 0 - delay: 6s - light.turn_off: leds - else: - if: condition: @@ -903,7 +791,6 @@ script: effect: "Rainbow" - delay: 1s - light.turn_off: leds - else: # SWIPE - if: @@ -916,7 +803,6 @@ script: red: 0 green: 1 blue: 0 - - if: condition: lambda: "return state==12;"