From 7e46ecb1b3847dd0ed97f2561a2e7e720bba6793 Mon Sep 17 00:00:00 2001 From: Edward Firmo <94725493+edwardtfn@users.noreply.github.com> Date: Thu, 29 Aug 2024 18:15:09 +0200 Subject: [PATCH 01/36] Fix led mapping on US model Tentatively solves #29 --- ESPHome/TX-Ultimate-Easy-ESPHome_core.yaml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/ESPHome/TX-Ultimate-Easy-ESPHome_core.yaml b/ESPHome/TX-Ultimate-Easy-ESPHome_core.yaml index 31595ed..9105750 100644 --- a/ESPHome/TX-Ultimate-Easy-ESPHome_core.yaml +++ b/ESPHome/TX-Ultimate-Easy-ESPHome_core.yaml @@ -204,6 +204,7 @@ esp32: esphome: name: ${name} friendly_name: ${friendly_name} + comment: TX Ultimate Easy platformio_options: build_flags: - -D TX_ULTIMATE_EASY_CORE @@ -394,7 +395,7 @@ light: segments: - id: light_full from: 0 - to: 28 + to: 27 effects: &light_effects_full - addressable_rainbow: - addressable_rainbow: @@ -507,8 +508,8 @@ light: default_transition_length: ${default_transition_length} segments: - id: light_full - from: 10 - to: 15 + from: 9 + to: 14 reversed: true effects: *light_effects_full - id: light_us_left From b6d9ae5a968fea4c092a699cb9d1903776dff969 Mon Sep 17 00:00:00 2001 From: Edward Firmo <94725493+edwardtfn@users.noreply.github.com> Date: Thu, 19 Dec 2024 19:35:46 +0100 Subject: [PATCH 02/36] Split files To improve readability and increase my chances to have more people collaborating with this project. Solves #27 --- ...Ultimate-Easy-ESPHome_addon_ble_proxy.yaml | 12 + ESPHome/TX-Ultimate-Easy-ESPHome_core.yaml | 1608 +---------------- .../TX-Ultimate-Easy-ESPHome_core_api.yaml | 52 + ...Ultimate-Easy-ESPHome_core_hw_buttons.yaml | 248 +++ .../TX-Ultimate-Easy-ESPHome_core_hw_led.yaml | 1012 +++++++++++ ...-Ultimate-Easy-ESPHome_core_hw_relays.yaml | 226 +++ ...Ultimate-Easy-ESPHome_core_hw_speaker.yaml | 29 + ...X-Ultimate-Easy-ESPHome_core_hw_touch.yaml | 212 +++ ...timate-Easy-ESPHome_core_hw_vibration.yaml | 120 ++ TX-Ultimate-Easy-ESPHome.yaml | 6 + 10 files changed, 1943 insertions(+), 1582 deletions(-) create mode 100644 ESPHome/TX-Ultimate-Easy-ESPHome_core_api.yaml create mode 100644 ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_buttons.yaml create mode 100644 ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_led.yaml create mode 100644 ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_relays.yaml create mode 100644 ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_speaker.yaml create mode 100644 ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_touch.yaml create mode 100644 ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_vibration.yaml diff --git a/ESPHome/TX-Ultimate-Easy-ESPHome_addon_ble_proxy.yaml b/ESPHome/TX-Ultimate-Easy-ESPHome_addon_ble_proxy.yaml index ad0ac37..331bda3 100644 --- a/ESPHome/TX-Ultimate-Easy-ESPHome_addon_ble_proxy.yaml +++ b/ESPHome/TX-Ultimate-Easy-ESPHome_addon_ble_proxy.yaml @@ -1,3 +1,15 @@ +#################################################################################################### +##### TX Ultimate Easy for ESPHome ##### +##### Repository: https://github.com/edwardtfn/TX-Ultimate-Easy ##### +#################################################################################################### +##### Purpose: ESPHome Core - Add-on - BLE Proxy ##### +#################################################################################################### +##### Author: edwardtfn - https://github.com/edwardtfn - https://buymeacoffee.com/edwardfirmo ##### +#################################################################################################### +##### NOTE: ##### +##### - Make changes ONLY if absolutely necessary and you have the required knowledge. ##### +##### - For normal system use, modifications to this file are NOT required. ##### +#################################################################################################### --- bluetooth_proxy: diff --git a/ESPHome/TX-Ultimate-Easy-ESPHome_core.yaml b/ESPHome/TX-Ultimate-Easy-ESPHome_core.yaml index 9105750..843dbe8 100644 --- a/ESPHome/TX-Ultimate-Easy-ESPHome_core.yaml +++ b/ESPHome/TX-Ultimate-Easy-ESPHome_core.yaml @@ -1,3 +1,15 @@ +#################################################################################################### +##### TX Ultimate Easy for ESPHome ##### +##### Repository: https://github.com/edwardtfn/TX-Ultimate-Easy ##### +#################################################################################################### +##### Purpose: ESPHome Core ##### +#################################################################################################### +##### Author: edwardtfn - https://github.com/edwardtfn - https://buymeacoffee.com/edwardfirmo ##### +#################################################################################################### +##### NOTE: ##### +##### - Make changes ONLY if absolutely necessary and you have the required knowledge. ##### +##### - For normal system use, modifications to this file are NOT required. ##### +#################################################################################################### --- substitutions: name: tx-ultimate-easy @@ -6,178 +18,19 @@ substitutions: latitude: '0' longitude: '0' zone_home: 'zone.home' - default_transition_length: 500ms - invalid_cooldown: 100ms version: '0.0.3' -api: - id: api_server - services: - - service: set_float - variables: - component: string - val: float - then: - - lambda: |- - if (!isnan(val)) { - if (component == "latitude") sun_entity->set_latitude(val); - else if (component == "longitude") sun_entity->set_longitude(val); - } - -binary_sensor: - - id: bs_vibrating - name: Vibrating - icon: mdi:vibrate - internal: false - platform: template - lambda: return sw_vibration_motor->state; - - - id: bs_button_1 - name: Button 1 - icon: mdi:gesture-tap-box - internal: false - platform: template - on_click: - then: - - lambda: |- - if (sl_button_1_action->active_index().has_value() and - sl_button_1_action->active_index().value() == 1 and - !bs_multi_touch->state and - !bs_swipe_left->state and - !bs_swipe_down->state and - !bs_swipe_right->state) - sw_relay_1->toggle(); - send_event_to_ha->execute("bs_button_1", "click"); - on_double_click: - then: - - lambda: send_event_to_ha->execute("bs_button_1", "double_click"); - on_multi_click: - - timing: &long_click-timing - - ON for at least 0.8s - invalid_cooldown: ${invalid_cooldown} - then: - - lambda: send_event_to_ha->execute("bs_button_1", "long_click"); - - - id: bs_button_2 - name: Button 2 - icon: mdi:gesture-tap-box - internal: true - platform: template - on_click: - then: - - lambda: |- - if (sl_button_2_action->active_index().has_value() and - sl_button_2_action->active_index().value() == 1 and - !bs_multi_touch->state and - !bs_swipe_left->state and - !bs_swipe_down->state and - !bs_swipe_right->state) - sw_relay_2->toggle(); - send_event_to_ha->execute("bs_button_2", "click"); - on_double_click: - then: - - lambda: send_event_to_ha->execute("bs_button_2", "double_click"); - on_multi_click: - - timing: *long_click-timing - invalid_cooldown: ${invalid_cooldown} - then: - - lambda: send_event_to_ha->execute("bs_button_2", "long_click"); - - - id: bs_button_3 - name: Button 3 - icon: mdi:gesture-tap-box - internal: true - platform: template - on_click: - then: - - lambda: |- - if (sl_button_3_action->active_index().has_value() and - sl_button_3_action->active_index().value() == 1 and - !bs_multi_touch->state and - !bs_swipe_left->state and - !bs_swipe_down->state and - !bs_swipe_right->state) - sw_relay_3->toggle(); - send_event_to_ha->execute("bs_button_3", "click"); - on_double_click: - then: - - lambda: send_event_to_ha->execute("bs_button_3", "double_click"); - on_multi_click: - - timing: *long_click-timing - invalid_cooldown: ${invalid_cooldown} - then: - - lambda: send_event_to_ha->execute("bs_button_3", "long_click"); - - - id: bs_button_4 - name: Button 4 - icon: mdi:gesture-tap-box - internal: true - platform: template - on_click: - then: - - lambda: |- - if (sl_button_4_action->active_index().has_value() and - sl_button_4_action->active_index().value() == 1 and - !bs_multi_touch->state and - !bs_swipe_left->state and - !bs_swipe_down->state and - !bs_swipe_right->state) - sw_relay_4->toggle(); - send_event_to_ha->execute("bs_button_4", "click"); - on_double_click: - then: - - lambda: send_event_to_ha->execute("bs_button_4", "double_click"); - on_multi_click: - - timing: *long_click-timing - invalid_cooldown: ${invalid_cooldown} - then: - - lambda: send_event_to_ha->execute("bs_button_4", "long_click"); - - - id: bs_multi_touch - name: Multi-touch - icon: mdi:gesture-two-tap - internal: false - platform: template - on_click: - then: - - lambda: send_event_to_ha->execute("multi_touch", "multi_touch"); - - - id: bs_swipe_left - name: Swipe left - icon: mdi:gesture-swipe-left - internal: true - platform: template - on_click: - then: - - lambda: send_event_to_ha->execute("swipe", "left"); - - - id: bs_swipe_right - name: Swipe right - icon: mdi:gesture-swipe-right - internal: true - platform: template - on_click: - then: - - lambda: send_event_to_ha->execute("swipe", "right"); - - - id: bs_swipe_up - name: Swipe up - icon: mdi:gesture-swipe-up - internal: true - platform: template - on_click: - then: - - lambda: send_event_to_ha->execute("swipe", "up"); - - - id: bs_swipe_down - name: Swipe down - icon: mdi:gesture-swipe-down - internal: true - platform: template - on_click: - then: - - lambda: send_event_to_ha->execute("swipe", "down"); +packages: + # yamllint disable rule:colons + core_api: !include TX-Ultimate-Easy-ESPHome_core_api.yaml + core_hw_buttons: !include TX-Ultimate-Easy-ESPHome_core_hw_buttons.yaml + core_hw_led: !include TX-Ultimate-Easy-ESPHome_core_hw_led.yaml + core_hw_relays: !include TX-Ultimate-Easy-ESPHome_core_hw_relays.yaml + core_hw_speaker: !include TX-Ultimate-Easy-ESPHome_core_hw_speaker.yaml + core_hw_touch: !include TX-Ultimate-Easy-ESPHome_core_hw_touch.yaml + core_hw_vibration: !include TX-Ultimate-Easy-ESPHome_core_hw_vibration.yaml + # yamllint enable rule:colons button: - id: bt_restart @@ -185,15 +38,6 @@ button: internal: false platform: restart - - id: bt_vibrate - name: Vibrate - icon: mdi:vibrate - internal: false - platform: template - on_press: - then: - - script.execute: vibrate - captive_portal: id: ap_captive_portal @@ -208,6 +52,7 @@ esphome: platformio_options: build_flags: - -D TX_ULTIMATE_EASY_CORE + on_boot: - priority: 700 then: @@ -335,1272 +180,22 @@ esphome: then: - lambda: send_event_to_ha->execute("boot", "done"); -external_components: - - source: github://edwardtfn/TX-Ultimate-Easy@dev # Change this before releasing - components: - - tx_ultimate_easy - -globals: - - id: gb_lights_1 - type: std::vector - restore_value: false - - id: gb_lights_2 - type: std::vector - restore_value: false - -i2s_audio: - id: if_i2s_audio - i2s_bclk_pin: GPIO2 - i2s_lrclk_pin: GPIO4 - improv_serial: id: serial_improv -light: - - id: ligth_output_1 - name: Light output 1 - internal: true - platform: binary - output: output_relay_1 - - id: ligth_output_2 - name: Light output 2 - internal: true - platform: binary - output: output_relay_2 - - id: ligth_output_3 - name: Light output 3 - internal: true - platform: binary - output: output_relay_3 - - id: ligth_output_4 - name: Light output 4 - internal: true - platform: binary - output: output_relay_4 - - - id: light_full - name: Light - All - internal: true - platform: neopixelbus - type: GRB - variant: WS2811 - num_leds: 32 - pin: GPIO13 - - - id: light_eu - name: Light - internal: true - platform: partition - default_transition_length: ${default_transition_length} - segments: - - id: light_full - from: 0 - to: 27 - effects: &light_effects_full - - addressable_rainbow: - - addressable_rainbow: - name: "Rainbow - Fast" - speed: 50 - - pulse: - - pulse: - name: "Pulse - Fast" - transition_length: 0.5s - update_interval: 0.5s - - pulse: - name: "Pulse - Slow" - update_interval: 2s - - addressable_scan: - - addressable_scan: - name: Scan Effect With Custom Values - move_interval: 100ms - scan_width: 3 - - addressable_twinkle: - - addressable_twinkle: - name: Twinkle Effect With Custom Values - twinkle_probability: 5% - progress_interval: 4ms - - addressable_random_twinkle: - - addressable_random_twinkle: - name: Random Twinkle Effect With Custom Values - twinkle_probability: 20% - progress_interval: 32ms - - addressable_fireworks: - - addressable_fireworks: - name: Fireworks Effect With Custom Values - update_interval: 32ms - spark_probability: 10% - use_random_color: false - fade_out_rate: 120 - - addressable_flicker: - - addressable_flicker: - name: Flicker Effect With Custom Values - update_interval: 16ms - intensity: 5% - - random: - - id: light_us - name: Light - internal: true - platform: partition - default_transition_length: ${default_transition_length} - segments: - - id: light_full - from: 0 - to: 31 - effects: *light_effects_full - - - id: light_eu_bottom - name: Light - Bottom - internal: true - disabled_by_default: true - platform: partition - default_transition_length: ${default_transition_length} - segments: - - id: light_full - from: 6 - to: 12 - reversed: true - effects: *light_effects_full - - id: light_eu_left - name: Light - Left - internal: true - disabled_by_default: true - platform: partition - default_transition_length: ${default_transition_length} - segments: - - id: light_full - from: 13 - to: 19 - reversed: true - effects: *light_effects_full - - id: light_eu_right - name: Light - Right - internal: true - disabled_by_default: true - platform: partition - default_transition_length: ${default_transition_length} - segments: - - id: light_full - from: 27 - to: 27 - reversed: false - - id: light_full - from: 0 - to: 5 - reversed: false - effects: *light_effects_full - - id: light_eu_top - name: Light - Top - internal: true - disabled_by_default: true - platform: partition - default_transition_length: ${default_transition_length} - segments: - - id: light_full - from: 20 - to: 26 - reversed: false - effects: *light_effects_full - - id: light_us_bottom - name: Light - Bottom - internal: true - disabled_by_default: true - platform: partition - default_transition_length: ${default_transition_length} - segments: - - id: light_full - from: 9 - to: 14 - reversed: true - effects: *light_effects_full - - id: light_us_left - name: Light - Left - internal: true - disabled_by_default: true - platform: partition - default_transition_length: ${default_transition_length} - segments: - - id: light_full - from: 15 - to: 24 - reversed: true - effects: *light_effects_full - - id: light_us_right - name: Light - Right - internal: true - disabled_by_default: true - platform: partition - default_transition_length: ${default_transition_length} - segments: - - id: light_full - from: 31 - to: 31 - reversed: false - - id: light_full - from: 0 - to: 8 - reversed: false - effects: *light_effects_full - - id: light_us_top - name: Light - Top - internal: true - disabled_by_default: true - platform: partition - default_transition_length: ${default_transition_length} - segments: - - id: light_full - from: 25 - to: 30 - reversed: false - effects: *light_effects_full - - - id: light_00 - name: Light - LED 00 - disabled_by_default: true - platform: partition - default_transition_length: ${default_transition_length} - segments: - - id: light_full - from: 0 - to: 0 - - id: light_01 - name: Light - LED 01 - disabled_by_default: true - platform: partition - default_transition_length: ${default_transition_length} - segments: - - id: light_full - from: 1 - to: 1 - - id: light_02 - name: Light - LED 02 - disabled_by_default: true - platform: partition - default_transition_length: ${default_transition_length} - segments: - - id: light_full - from: 2 - to: 2 - - id: light_03 - name: Light - LED 03 - disabled_by_default: true - platform: partition - default_transition_length: ${default_transition_length} - segments: - - id: light_full - from: 3 - to: 3 - - id: light_04 - name: Light - LED 04 - disabled_by_default: true - platform: partition - default_transition_length: ${default_transition_length} - segments: - - id: light_full - from: 4 - to: 4 - - id: light_05 - name: Light - LED 05 - disabled_by_default: true - platform: partition - default_transition_length: ${default_transition_length} - segments: - - id: light_full - from: 5 - to: 5 - - id: light_06 - name: Light - LED 06 - disabled_by_default: true - platform: partition - default_transition_length: ${default_transition_length} - segments: - - id: light_full - from: 6 - to: 6 - - id: light_07 - name: Light - LED 07 - disabled_by_default: true - platform: partition - default_transition_length: ${default_transition_length} - segments: - - id: light_full - from: 7 - to: 7 - - id: light_08 - name: Light - LED 08 - disabled_by_default: true - platform: partition - default_transition_length: ${default_transition_length} - segments: - - id: light_full - from: 8 - to: 8 - - id: light_09 - name: Light - LED 09 - disabled_by_default: true - platform: partition - default_transition_length: ${default_transition_length} - segments: - - id: light_full - from: 9 - to: 9 - - id: light_10 - name: Light - LED 10 - disabled_by_default: true - platform: partition - default_transition_length: ${default_transition_length} - segments: - - id: light_full - from: 10 - to: 10 - - id: light_11 - name: Light - LED 11 - disabled_by_default: true - platform: partition - default_transition_length: ${default_transition_length} - segments: - - id: light_full - from: 11 - to: 11 - - id: light_12 - name: Light - LED 12 - disabled_by_default: true - platform: partition - default_transition_length: ${default_transition_length} - segments: - - id: light_full - from: 12 - to: 12 - - id: light_13 - name: Light - LED 13 - disabled_by_default: true - platform: partition - default_transition_length: ${default_transition_length} - segments: - - id: light_full - from: 13 - to: 13 - - id: light_14 - name: Light - LED 14 - disabled_by_default: true - platform: partition - default_transition_length: ${default_transition_length} - segments: - - id: light_full - from: 14 - to: 14 - - id: light_15 - name: Light - LED 15 - disabled_by_default: true - platform: partition - default_transition_length: ${default_transition_length} - segments: - - id: light_full - from: 15 - to: 15 - - id: light_16 - name: Light - LED 16 - disabled_by_default: true - platform: partition - default_transition_length: ${default_transition_length} - segments: - - id: light_full - from: 16 - to: 16 - - id: light_17 - name: Light - LED 17 - disabled_by_default: true - platform: partition - default_transition_length: ${default_transition_length} - segments: - - id: light_full - from: 17 - to: 17 - - id: light_18 - name: Light - LED 18 - disabled_by_default: true - platform: partition - default_transition_length: ${default_transition_length} - segments: - - id: light_full - from: 18 - to: 18 - - id: light_19 - name: Light - LED 19 - disabled_by_default: true - platform: partition - default_transition_length: ${default_transition_length} - segments: - - id: light_full - from: 19 - to: 19 - - id: light_20 - name: Light - LED 20 - disabled_by_default: true - platform: partition - default_transition_length: ${default_transition_length} - segments: - - id: light_full - from: 20 - to: 20 - - id: light_21 - name: Light - LED 21 - disabled_by_default: true - platform: partition - default_transition_length: ${default_transition_length} - segments: - - id: light_full - from: 21 - to: 21 - - id: light_22 - name: Light - LED 22 - disabled_by_default: true - platform: partition - default_transition_length: ${default_transition_length} - segments: - - id: light_full - from: 22 - to: 22 - - id: light_23 - name: Light - LED 23 - disabled_by_default: true - platform: partition - default_transition_length: ${default_transition_length} - segments: - - id: light_full - from: 23 - to: 23 - - id: light_24 - name: Light - LED 24 - disabled_by_default: true - platform: partition - default_transition_length: ${default_transition_length} - segments: - - id: light_full - from: 24 - to: 24 - - id: light_25 - name: Light - LED 25 - disabled_by_default: true - platform: partition - default_transition_length: ${default_transition_length} - segments: - - id: light_full - from: 25 - to: 25 - - id: light_26 - name: Light - LED 26 - disabled_by_default: true - platform: partition - default_transition_length: ${default_transition_length} - segments: - - id: light_full - from: 26 - to: 26 - - id: light_27 - name: Light - LED 27 - disabled_by_default: true - platform: partition - default_transition_length: ${default_transition_length} - segments: - - id: light_full - from: 27 - to: 27 - - id: light_28 - name: Light - LED 28 - internal: true - disabled_by_default: true - platform: partition - default_transition_length: ${default_transition_length} - segments: - - id: light_full - from: 28 - to: 28 - - id: light_29 - name: Light - LED 29 - internal: true - disabled_by_default: true - platform: partition - default_transition_length: ${default_transition_length} - segments: - - id: light_full - from: 29 - to: 29 - - id: light_30 - name: Light - LED 30 - internal: true - disabled_by_default: true - platform: partition - default_transition_length: ${default_transition_length} - segments: - - id: light_full - from: 30 - to: 30 - - id: light_31 - name: Light - LED 31 - internal: true - disabled_by_default: true - platform: partition - default_transition_length: ${default_transition_length} - segments: - - id: light_full - from: 31 - to: 31 - - - id: light_eu_rl_1_1_bottom - name: Light - Relay 1 of 1 (bottom) - internal: true - platform: partition - default_transition_length: ${default_transition_length} - segments: - - id: light_full - from: 9 - to: 9 - - id: light_eu_rl_1_1_top - name: Light - Relay 1 of 1 (top) - internal: true - platform: partition - default_transition_length: ${default_transition_length} - segments: - - id: light_full - from: 23 - to: 23 - - id: light_eu_rl_1_2_bottom - name: Light - Relay 1 of 2 (bottom) - internal: true - platform: partition - default_transition_length: ${default_transition_length} - segments: - - id: light_full - from: 11 - to: 11 - - id: light_eu_rl_1_2_top - name: Light - Relay 1 of 2 (top) - internal: true - platform: partition - default_transition_length: ${default_transition_length} - segments: - - id: light_full - from: 21 - to: 21 - - id: light_eu_rl_2_2_bottom - name: Light - Relay 2 of 2 (bottom) - internal: true - platform: partition - default_transition_length: ${default_transition_length} - segments: - - id: light_full - from: 7 - to: 7 - - id: light_eu_rl_2_2_top - name: Light - Relay 2 of 2 (top) - internal: true - platform: partition - default_transition_length: ${default_transition_length} - segments: - - id: light_full - from: 25 - to: 25 - - id: light_eu_rl_1_3_bottom - name: Light - Relay 1 of 3 (bottom) - internal: true - platform: partition - default_transition_length: ${default_transition_length} - segments: - - id: light_full - from: 12 - to: 12 - - id: light_eu_rl_1_3_top - name: Light - Relay 1 of 3 (top) - internal: true - platform: partition - default_transition_length: ${default_transition_length} - segments: - - id: light_full - from: 20 - to: 20 - - id: light_eu_rl_2_3_bottom - name: Light - Relay 2 of 3 (bottom) - internal: true - platform: partition - default_transition_length: ${default_transition_length} - segments: - - id: light_full - from: 9 - to: 9 - - id: light_eu_rl_2_3_top - name: Light - Relay 2 of 3 (top) - internal: true - platform: partition - default_transition_length: ${default_transition_length} - segments: - - id: light_full - from: 23 - to: 23 - - id: light_eu_rl_3_3_bottom - name: Light - Relay 3 of 3 (bottom) - internal: true - platform: partition - default_transition_length: ${default_transition_length} - segments: - - id: light_full - from: 6 - to: 6 - - id: light_eu_rl_3_3_top - name: Light - Relay 3 of 3 (top) - internal: true - platform: partition - default_transition_length: ${default_transition_length} - segments: - - id: light_full - from: 26 - to: 26 - - id: light_eu_rl_1_4_bottom - name: Light - Relay 1 of 4 (bottom) - internal: true - platform: partition - default_transition_length: ${default_transition_length} - segments: - - id: light_full - from: 12 - to: 12 - - id: light_eu_rl_1_4_top - name: Light - Relay 1 of 4 (top) - internal: true - platform: partition - default_transition_length: ${default_transition_length} - segments: - - id: light_full - from: 20 - to: 20 - - id: light_eu_rl_2_4_bottom - name: Light - Relay 2 of 4 (bottom) - internal: true - platform: partition - default_transition_length: ${default_transition_length} - segments: - - id: light_full - from: 10 - to: 10 - - id: light_eu_rl_2_4_top - name: Light - Relay 2 of 4 (top) - internal: true - platform: partition - default_transition_length: ${default_transition_length} - segments: - - id: light_full - from: 22 - to: 22 - - id: light_eu_rl_3_4_bottom - name: Light - Relay 3 of 4 (bottom) - internal: true - platform: partition - default_transition_length: ${default_transition_length} - segments: - - id: light_full - from: 8 - to: 8 - - id: light_eu_rl_3_4_top - name: Light - Relay 3 of 4 (top) - internal: true - platform: partition - default_transition_length: ${default_transition_length} - segments: - - id: light_full - from: 24 - to: 24 - - id: light_eu_rl_4_4_bottom - name: Light - Relay 4 of 4 (bottom) - internal: true - platform: partition - default_transition_length: ${default_transition_length} - segments: - - id: light_full - from: 6 - to: 6 - - id: light_eu_rl_4_4_top - name: Light - Relay 4 of 4 (top) - internal: true - platform: partition - default_transition_length: ${default_transition_length} - segments: - - id: light_full - from: 26 - to: 26 - - id: light_us_rl_1_1_left - name: Light - Relay 1 of 1 (left) - internal: true - platform: partition - default_transition_length: ${default_transition_length} - segments: - - id: light_full - from: 15 - to: 24 - - id: light_us_rl_1_1_right - name: Light - Relay 1 of 1 (right) - internal: true - platform: partition - default_transition_length: ${default_transition_length} - segments: - - id: light_full - from: 31 - to: 31 - - id: light_full - from: 0 - to: 8 - - id: light_us_rl_1_2_left - name: Light - Relay 1 of 2 (left) - internal: true - platform: partition - default_transition_length: ${default_transition_length} - segments: - - id: light_full - from: 20 - to: 24 - - id: light_us_rl_1_2_right - name: Light - Relay 1 of 2 (right) - internal: true - platform: partition - default_transition_length: ${default_transition_length} - segments: - - id: light_full - from: 31 - to: 31 - - id: light_full - from: 0 - to: 3 - - id: light_us_rl_2_2_left - name: Light - Relay 2 of 2 (left) - internal: true - platform: partition - default_transition_length: ${default_transition_length} - segments: - - id: light_full - from: 15 - to: 19 - - id: light_us_rl_2_2_right - name: Light - Relay 2 of 2 (right) - internal: true - platform: partition - default_transition_length: ${default_transition_length} - segments: - - id: light_full - from: 4 - to: 8 - - id: light_us_rl_1_3_left - name: Light - Relay 1 of 3 (left) - internal: true - platform: partition - default_transition_length: ${default_transition_length} - segments: - - id: light_full - from: 22 - to: 23 - - id: light_us_rl_1_3_right - name: Light - Relay 1 of 3 (right) - internal: true - platform: partition - default_transition_length: ${default_transition_length} - segments: - - id: light_full - from: 0 - to: 1 - - id: light_us_rl_2_3_left - name: Light - Relay 2 of 3 (left) - internal: true - platform: partition - default_transition_length: ${default_transition_length} - segments: - - id: light_full - from: 19 - to: 20 - - id: light_us_rl_2_3_right - name: Light - Relay 2 of 3 (right) - internal: true - platform: partition - default_transition_length: ${default_transition_length} - segments: - - id: light_full - from: 3 - to: 4 - - id: light_us_rl_3_3_left - name: Light - Relay 3 of 3 (left) - internal: true - platform: partition - default_transition_length: ${default_transition_length} - segments: - - id: light_full - from: 17 - to: 18 - - id: light_us_rl_3_3_right - name: Light - Relay 3 of 3 (right) - internal: true - platform: partition - default_transition_length: ${default_transition_length} - segments: - - id: light_full - from: 6 - to: 7 - - id: light_us_rl_1_4_left - name: Light - Relay 1 of 4 (left) - internal: true - platform: partition - default_transition_length: ${default_transition_length} - segments: - - id: light_full - from: 12 - to: 12 - - id: light_us_rl_1_4_right - name: Light - Relay 1 of 4 (right) - internal: true - platform: partition - default_transition_length: ${default_transition_length} - segments: - - id: light_full - from: 31 - to: 31 - - id: light_us_rl_2_4_left - name: Light - Relay 2 of 4 (left) - internal: true - platform: partition - default_transition_length: ${default_transition_length} - segments: - - id: light_full - from: 24 - to: 24 - - id: light_us_rl_2_4_right - name: Light - Relay 2 of 4 (right) - internal: true - platform: partition - default_transition_length: ${default_transition_length} - segments: - - id: light_full - from: 2 - to: 2 - - id: light_us_rl_3_4_left - name: Light - Relay 3 of 4 (left) - internal: true - platform: partition - default_transition_length: ${default_transition_length} - segments: - - id: light_full - from: 21 - to: 21 - - id: light_us_rl_3_4_right - name: Light - Relay 3 of 4 (right) - internal: true - platform: partition - default_transition_length: ${default_transition_length} - segments: - - id: light_full - from: 4 - to: 4 - - id: light_us_rl_4_4_left - name: Light - Relay 4 of 4 (left) - internal: true - platform: partition - default_transition_length: ${default_transition_length} - segments: - - id: light_full - from: 19 - to: 19 - - id: light_us_rl_4_4_right - name: Light - Relay 4 of 4 (right) - internal: true - platform: partition - default_transition_length: ${default_transition_length} - segments: - - id: light_full - from: 7 - to: 7 - logger: -media_player: - - id: mp_speaker - name: Speaker - platform: i2s_audio - i2s_dout_pin: GPIO15 - i2s_audio_id: if_i2s_audio - i2s_comm_fmt: lsb - dac_type: external - mode: mono - internal: false - -number: - - id: nr_vibrating_duration - name: Vibrate duration - icon: mdi:vibrate - unit_of_measurement: ms - # mode: box - internal: false - entity_category: config - platform: template - min_value: 1 - max_value: 500 - step: 1 - initial_value: 15 - optimistic: true - restore_value: true - - - id: nr_touch_duration - name: Touch duration - icon: mdi:timer-cog-outline - unit_of_measurement: ms - # mode: box - internal: false - entity_category: config - platform: template - min_value: 10 - max_value: 1500 - step: 1 - initial_value: 250 - optimistic: true - restore_value: true - ota: platform: esphome -output: - - id: output_relay_1 - platform: gpio - pin: GPIO18 - - - id: output_relay_2 - platform: gpio - pin: GPIO17 - - - id: output_relay_3 - platform: gpio - pin: GPIO27 - - - id: output_relay_4 - platform: gpio - pin: GPIO23 - psram: script: - - id: release_buttons + - id: boot_initialize mode: restart - then: - - lambda: |- - if (bs_button_1->state) bs_button_1->publish_state(false); - if (bs_button_2->state) bs_button_2->publish_state(false); - if (bs_button_3->state) bs_button_3->publish_state(false); - if (bs_button_4->state) bs_button_4->publish_state(false); - - - id: send_event_to_ha - mode: queued - parameters: - component: string - event: string - then: - - lambda: |- - esphome::api::CustomAPIDevice ha_event; - ha_event.fire_homeassistant_event("esphome.tx_ultimate_easy", - { - {"device_name", tx_device_name->state.c_str()}, - {"firmware", "${version}"}, - {"component", component}, - {"event", event}, - }); - - - id: show_relay_status - mode: restart - then: - - lambda: |- - return; - show_relay_status->stop(); - auto model_format = sl_tx_model_format->active_index(); - std::vector relay_modes; - - if (model_format.has_value() and model_format.value() == 0) { - relay_modes = {sl_relay_1_light_mode_eu, sl_relay_2_light_mode_eu, sl_relay_3_light_mode_eu, sl_relay_4_light_mode_eu}; - } else { - relay_modes = {sl_relay_1_light_mode_us, sl_relay_2_light_mode_us, sl_relay_3_light_mode_us, sl_relay_4_light_mode_us}; - } - - std::vector switches = {sw_relay_1, sw_relay_2, sw_relay_3, sw_relay_4}; - for (int i = 0; i < relay_modes.size(); ++i) { - auto light_index = relay_modes[i]->active_index(); - if (light_index.has_value()) { - uint8_t light_idx = light_index.value(); - bool switch_state = switches[i]->state; - if (light_idx == 1 || light_idx == 3) { - if (switch_state) - id(gb_lights_1)[i]->turn_on().perform(); - else - id(gb_lights_1)[i]->turn_off().perform(); - } - if (light_idx == 2 || light_idx == 3) { - if (switch_state) - id(gb_lights_2)[i]->turn_on().perform(); - else - id(gb_lights_2)[i]->turn_off().perform(); - } - } - } - - - id: vibrate - mode: restart - then: - - switch.turn_on: sw_vibration_motor - - delay: !lambda return nr_vibrating_duration->state; - - switch.turn_off: sw_vibration_motor + then: # There's nothing here so far select: - - id: sl_button_1_action - name: Button 1 action - platform: template - options: - - "None" - - "Relay 1 (toggle)" - optimistic: true - restore_value: true - internal: true - entity_category: config - disabled_by_default: false - icon: mdi:dip-switch - - - id: sl_button_2_action - name: Button 2 action - platform: template - options: - - "None" - - "Relay 2 (toggle)" - optimistic: true - restore_value: true - internal: true - entity_category: config - disabled_by_default: false - icon: mdi:dip-switch - - - id: sl_button_3_action - name: Button 3 action - platform: template - options: - - "None" - - "Relay 3 (toggle)" - optimistic: true - restore_value: true - internal: true - entity_category: config - disabled_by_default: false - icon: mdi:dip-switch - - - id: sl_button_4_action - name: Button 4 action - platform: template - options: - - "None" - - "Relay 4 (toggle)" - optimistic: true - restore_value: true - internal: true - entity_category: config - disabled_by_default: false - icon: mdi:dip-switch - - - id: sl_relay_1_mode - name: Relay 1 mode - platform: template - options: - - "Relay" - - "Light" - - "Not in use" - optimistic: true - restore_value: true - internal: true - entity_category: config - disabled_by_default: false - icon: mdi:dip-switch - - - id: sl_relay_2_mode - name: Relay 2 mode - platform: template - options: - - "Relay" - - "Light" - - "Not in use" - optimistic: true - restore_value: true - internal: true - entity_category: config - disabled_by_default: false - icon: mdi:dip-switch - - - id: sl_relay_3_mode - name: Relay 3 mode - platform: template - options: - - "Relay" - - "Light" - - "Not in use" - optimistic: true - restore_value: true - internal: true - entity_category: config - disabled_by_default: false - icon: mdi:dip-switch - - - id: sl_relay_4_mode - name: Relay 4 mode - platform: template - options: - - "Relay" - - "Light" - - "Not in use" - optimistic: true - restore_value: true - internal: true - entity_category: config - disabled_by_default: false - icon: mdi:dip-switch - - - id: sl_relay_1_light_mode_eu - name: Relay 1 light mode - platform: template - options: - - "Disabled" - - "Bottom" - - "Top" - - "Both" - initial_option: "Bottom" - optimistic: true - restore_value: true - internal: true - entity_category: config - disabled_by_default: false - icon: mdi:dots-square - - - id: sl_relay_2_light_mode_eu - name: Relay 2 light mode - platform: template - options: - - "Disabled" - - "Bottom" - - "Top" - - "Both" - initial_option: "Bottom" - optimistic: true - restore_value: true - internal: true - entity_category: config - disabled_by_default: false - icon: mdi:dots-square - - - id: sl_relay_3_light_mode_eu - name: Relay 3 light mode - platform: template - options: - - "Disabled" - - "Bottom" - - "Top" - - "Both" - initial_option: "Bottom" - optimistic: true - restore_value: true - internal: true - entity_category: config - disabled_by_default: false - icon: mdi:dots-square - - - id: sl_relay_4_light_mode_eu - name: Relay 4 light mode - platform: template - options: - - "Disabled" - - "Bottom" - - "Top" - - "Both" - initial_option: "Bottom" - optimistic: true - restore_value: true - internal: true - entity_category: config - disabled_by_default: false - icon: mdi:dots-square - - - id: sl_relay_1_light_mode_us - name: Relay 1 light mode - platform: template - options: - - "Disabled" - - "Left" - - "Right" - - "Both" - initial_option: "Right" - optimistic: true - restore_value: true - internal: true - entity_category: config - disabled_by_default: false - icon: mdi:dots-square - - - id: sl_relay_2_light_mode_us - name: Relay 2 light mode - platform: template - options: - - "Disabled" - - "Left" - - "Right" - - "Both" - initial_option: "Right" - optimistic: true - restore_value: true - internal: true - entity_category: config - disabled_by_default: false - icon: mdi:dots-square - - - id: sl_relay_3_light_mode_us - name: Relay 3 light mode - platform: template - options: - - "Disabled" - - "Left" - - "Right" - - "Both" - initial_option: "Right" - optimistic: true - restore_value: true - internal: true - entity_category: config - disabled_by_default: false - icon: mdi:dots-square - - - id: sl_relay_4_light_mode_us - name: Relay 4 light mode - platform: template - options: - - "Disabled" - - "Left" - - "Right" - - "Both" - initial_option: "Right" - optimistic: true - restore_value: true - internal: true - entity_category: config - disabled_by_default: false - icon: mdi:dots-square - - - id: sl_touch_vibration_feedback - name: Touch - Vibration feedback - platform: template - options: - - "Disabled" - - "On press" - - "On release" - - "Always" - initial_option: "Disabled" - optimistic: true - restore_value: true - internal: false - entity_category: config - disabled_by_default: false - icon: mdi:vibrate - - id: sl_tx_model_format name: Model (Format) platform: template @@ -1631,6 +226,7 @@ select: disabled_by_default: false icon: mdi:dip-switch + sensor: - id: sun_elevation name: Sun Elevation @@ -1659,82 +255,6 @@ sun: latitude: ${latitude} longitude: ${longitude} -switch: - - id: sw_relay_1 - name: Relay 1 - platform: output - output: output_relay_1 - restore_mode: RESTORE_DEFAULT_OFF - internal: true - on_turn_on: - then: - - script.execute: show_relay_status - on_turn_off: - then: - - script.execute: show_relay_status - - - id: sw_relay_2 - name: Relay 2 - platform: output - output: output_relay_2 - restore_mode: RESTORE_DEFAULT_OFF - internal: true - on_turn_on: - then: - - script.execute: show_relay_status - on_turn_off: - then: - - script.execute: show_relay_status - - - id: sw_relay_3 - name: Relay 3 - platform: output - output: output_relay_3 - restore_mode: RESTORE_DEFAULT_OFF - internal: true - on_turn_on: - then: - - script.execute: show_relay_status - on_turn_off: - then: - - script.execute: show_relay_status - - - id: sw_relay_4 - name: Relay 4 - platform: output - output: output_relay_4 - restore_mode: RESTORE_DEFAULT_OFF - internal: true - on_turn_on: - then: - - script.execute: show_relay_status - on_turn_off: - then: - - script.execute: show_relay_status - - - id: sw_touch_panel_power - name: Touch panel - Power - platform: gpio - pin: - number: GPIO5 - inverted: true - restore_mode: ALWAYS_ON - internal: false - entity_category: config - - - id: sw_vibration_motor - name: Vibration motor - platform: gpio - pin: GPIO21 - restore_mode: ALWAYS_OFF - internal: true - on_turn_on: - then: - - lambda: bs_vibrating->publish_state(true); - on_turn_off: - then: - - lambda: bs_vibrating->publish_state(false); - text_sensor: - id: tx_fw_version name: Firmware version @@ -1775,82 +295,6 @@ time: - id: time_source platform: homeassistant -tx_ultimate_easy: - id: tx_ultimate - uart: uart_touch - - on_multi_touch_release: - - lambda: |- - if (sl_touch_vibration_feedback->state == "On press" or sl_touch_vibration_feedback->state == "Always") - vibrate->execute(); - bs_multi_touch->publish_state(true); - release_buttons->execute(); - - delay: !lambda return nr_touch_duration->state; - - lambda: bs_multi_touch->publish_state(false); - - on_press: - - lambda: |- - if (sl_touch_vibration_feedback->state == "On press" or sl_touch_vibration_feedback->state == "Always") - vibrate->execute(); - auto model_index = sl_tx_model_gang->active_index(); - if (model_index.has_value()) { - uint8_t model_idx = model_index.value() + 1; - switch (model_idx) { - case 1: // 1 Gang - bs_button_1->publish_state(true); - break; - case 2: // 2 Gang - if (touch.x <= 5) bs_button_1->publish_state(true); - else bs_button_2->publish_state(true); - break; - case 3: // 3 Gang - if (touch.x <= 3) bs_button_1->publish_state(true); - else if (touch.x <= 7) bs_button_2->publish_state(true); - else bs_button_3->publish_state(true); - break; - case 4: // 4 Gang - if (touch.x <= 2) bs_button_1->publish_state(true); - else if (touch.x <= 5) bs_button_2->publish_state(true); - else if (touch.x <= 8) bs_button_3->publish_state(true); - else bs_button_4->publish_state(true); - break; - } - } - - on_release: - - lambda: |- - if (sl_touch_vibration_feedback->state == "On release" or sl_touch_vibration_feedback->state == "Always") - vibrate->execute(); - release_buttons->execute(); - if (bs_swipe_left->state) bs_swipe_left->publish_state(false); - if (bs_swipe_right->state) bs_swipe_right->publish_state(false); - - on_swipe_left: - - lambda: |- - bs_swipe_left->publish_state(true); - release_buttons->execute(); - - delay: !lambda return nr_touch_duration->state; - - lambda: bs_swipe_left->publish_state(false); - - on_swipe_right: - - lambda: |- - bs_swipe_right->publish_state(true); - release_buttons->execute(); - - delay: !lambda return nr_touch_duration->state; - - lambda: bs_swipe_right->publish_state(false); - - on_touch_event: - - lambda: |- - ESP_LOGD("tx_ultimate_easy.on_touch_event", "Touch event:"); - ESP_LOGD("tx_ultimate_easy.on_touch_event", " State: %i (%s)", touch.state, touch.state_str.c_str()); - ESP_LOGD("tx_ultimate_easy.on_touch_event", " Position: %i", touch.x); - -uart: - id: uart_touch - tx_pin: GPIO19 - rx_pin: GPIO22 - baud_rate: 115200 - web_server: wifi: diff --git a/ESPHome/TX-Ultimate-Easy-ESPHome_core_api.yaml b/ESPHome/TX-Ultimate-Easy-ESPHome_core_api.yaml new file mode 100644 index 0000000..c326718 --- /dev/null +++ b/ESPHome/TX-Ultimate-Easy-ESPHome_core_api.yaml @@ -0,0 +1,52 @@ +#################################################################################################### +##### TX Ultimate Easy for ESPHome ##### +##### Repository: https://github.com/edwardtfn/TX-Ultimate-Easy ##### +#################################################################################################### +##### Purpose: ESPHome Core - API ##### +#################################################################################################### +##### Author: edwardtfn - https://github.com/edwardtfn - https://buymeacoffee.com/edwardfirmo ##### +#################################################################################################### +##### NOTE: ##### +##### - Make changes ONLY if absolutely necessary and you have the required knowledge. ##### +##### - For normal system use, modifications to this file are NOT required. ##### +#################################################################################################### +--- +api: + id: api_server + actions: + - action: set_float + variables: + component: string + val: float + then: + - lambda: |- + if (!isnan(val)) { + if (component == "latitude") sun_entity->set_latitude(val); + else if (component == "longitude") sun_entity->set_longitude(val); + } + +script: + - id: !extend button_action + then: + - script.execute: + id: send_event_to_ha + component: !lambda return component.c_str(); + event: !lambda return event.c_str(); + + - id: send_event_to_ha + mode: queued + parameters: + component: string + event: string + then: + - lambda: |- + esphome::api::CustomAPIDevice ha_event; + ha_event.fire_homeassistant_event("esphome.tx_ultimate_easy", + { + {"device_name", tx_device_name->state.c_str()}, + {"firmware", "${version}"}, + {"component", component}, + {"event", event}, + }); + +... diff --git a/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_buttons.yaml b/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_buttons.yaml new file mode 100644 index 0000000..ffd32d8 --- /dev/null +++ b/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_buttons.yaml @@ -0,0 +1,248 @@ +#################################################################################################### +##### TX Ultimate Easy for ESPHome ##### +##### Repository: https://github.com/edwardtfn/TX-Ultimate-Easy ##### +#################################################################################################### +##### Purpose: ESPHome Core - Hardware - Buttons ##### +#################################################################################################### +##### Author: edwardtfn - https://github.com/edwardtfn - https://buymeacoffee.com/edwardfirmo ##### +#################################################################################################### +##### NOTE: ##### +##### - Make changes ONLY if absolutely necessary and you have the required knowledge. ##### +##### - For normal system use, modifications to this file are NOT required. ##### +#################################################################################################### +--- +substitutions: + invalid_cooldown: 100ms + +binary_sensor: + - id: bs_button_1 + name: Button 1 + icon: mdi:gesture-tap-box + internal: false + platform: template + on_click: + then: + - script.execute: + id: button_action + component: bs_button_1 + event: click + on_double_click: + then: + - script.execute: + id: button_action + component: bs_button_1 + event: double_click + on_multi_click: + - timing: &long_click-timing + - ON for at least 0.8s + invalid_cooldown: ${invalid_cooldown} + then: + - script.execute: + id: button_action + component: bs_button_1 + event: long_click + + - id: bs_button_2 + name: Button 2 + icon: mdi:gesture-tap-box + internal: true + platform: template + on_click: + then: + - script.execute: + id: button_action + component: bs_button_2 + event: click + on_double_click: + then: + - script.execute: + id: button_action + component: bs_button_2 + event: double_click + on_multi_click: + - timing: *long_click-timing + invalid_cooldown: ${invalid_cooldown} + then: + - script.execute: + id: button_action + component: bs_button_2 + event: long_click + + - id: bs_button_3 + name: Button 3 + icon: mdi:gesture-tap-box + internal: true + platform: template + on_click: + then: + - script.execute: + id: button_action + component: bs_button_3 + event: click + on_double_click: + then: + - script.execute: + id: button_action + component: bs_button_3 + event: double_click + on_multi_click: + - timing: *long_click-timing + invalid_cooldown: ${invalid_cooldown} + then: + - script.execute: + id: button_action + component: bs_button_3 + event: long_click + + - id: bs_button_4 + name: Button 4 + icon: mdi:gesture-tap-box + internal: true + platform: template + on_click: + then: + - script.execute: + id: button_action + component: bs_button_4 + event: click + on_double_click: + then: + - script.execute: + id: button_action + component: bs_button_4 + event: double_click + on_multi_click: + - timing: *long_click-timing + invalid_cooldown: ${invalid_cooldown} + then: + - script.execute: + id: button_action + component: bs_button_4 + event: long_click + +script: + - id: button_action + mode: parallel + parameters: + component: string + event: string + then: # There's nothing here so far + # Extended by: + # - core_api + + - id: buttons_release + mode: restart + then: + - lambda: |- + if (bs_button_1->state) bs_button_1->publish_state(false); + if (bs_button_2->state) bs_button_2->publish_state(false); + if (bs_button_3->state) bs_button_3->publish_state(false); + if (bs_button_4->state) bs_button_4->publish_state(false); + + - id: !extend touch_on_multi_touch_release + then: + - script.execute: buttons_release + + - id: !extend touch_on_press + then: + - script.execute: + id: touch_on_press_buttons + touch_x: !lambda return touch_x; + + - id: touch_on_press_buttons + mode: restart + parameters: + touch_x: uint8_t + then: + - lambda: |- + auto model_index = sl_tx_model_gang->active_index(); + if (model_index.has_value()) { + uint8_t model_idx = model_index.value() + 1; + switch (model_idx) { + case 1: // 1 Gang + bs_button_1->publish_state(true); + break; + case 2: // 2 Gang + if (touch_x <= 5) bs_button_1->publish_state(true); + else bs_button_2->publish_state(true); + break; + case 3: // 3 Gang + if (touch_x <= 3) bs_button_1->publish_state(true); + else if (touch_x <= 7) bs_button_2->publish_state(true); + else bs_button_3->publish_state(true); + break; + case 4: // 4 Gang + if (touch_x <= 2) bs_button_1->publish_state(true); + else if (touch_x <= 5) bs_button_2->publish_state(true); + else if (touch_x <= 8) bs_button_3->publish_state(true); + else bs_button_4->publish_state(true); + break; + } + } + + - id: !extend touch_on_release + then: + - script.execute: buttons_release + + - id: !extend touch_swipe_left + then: + - script.execute: buttons_release + + - id: !extend touch_swipe_right + then: + - script.execute: buttons_release + +select: + - id: sl_button_1_action + name: Button 1 action + platform: template + options: + - "None" + - "Relay 1 (toggle)" + optimistic: true + restore_value: true + internal: true + entity_category: config + disabled_by_default: false + icon: mdi:dip-switch + + - id: sl_button_2_action + name: Button 2 action + platform: template + options: + - "None" + - "Relay 2 (toggle)" + optimistic: true + restore_value: true + internal: true + entity_category: config + disabled_by_default: false + icon: mdi:dip-switch + + - id: sl_button_3_action + name: Button 3 action + platform: template + options: + - "None" + - "Relay 3 (toggle)" + optimistic: true + restore_value: true + internal: true + entity_category: config + disabled_by_default: false + icon: mdi:dip-switch + + - id: sl_button_4_action + name: Button 4 action + platform: template + options: + - "None" + - "Relay 4 (toggle)" + optimistic: true + restore_value: true + internal: true + entity_category: config + disabled_by_default: false + icon: mdi:dip-switch + +... diff --git a/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_led.yaml b/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_led.yaml new file mode 100644 index 0000000..2f45d71 --- /dev/null +++ b/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_led.yaml @@ -0,0 +1,1012 @@ +#################################################################################################### +##### TX Ultimate Easy for ESPHome ##### +##### Repository: https://github.com/edwardtfn/TX-Ultimate-Easy ##### +#################################################################################################### +##### Purpose: ESPHome Core - Hardware - LED ##### +#################################################################################################### +##### Author: edwardtfn - https://github.com/edwardtfn - https://buymeacoffee.com/edwardfirmo ##### +#################################################################################################### +##### NOTE: ##### +##### - Make changes ONLY if absolutely necessary and you have the required knowledge. ##### +##### - For normal system use, modifications to this file are NOT required. ##### +#################################################################################################### +--- +substitutions: + default_transition_length: 500ms + +globals: + - id: gb_lights_1 + type: std::vector + restore_value: false + - id: gb_lights_2 + type: std::vector + restore_value: false + +light: + - id: ligth_output_1 + name: Light output 1 + internal: true + platform: binary + output: output_relay_1 + - id: ligth_output_2 + name: Light output 2 + internal: true + platform: binary + output: output_relay_2 + - id: ligth_output_3 + name: Light output 3 + internal: true + platform: binary + output: output_relay_3 + - id: ligth_output_4 + name: Light output 4 + internal: true + platform: binary + output: output_relay_4 + + - id: light_full + name: Light - All + internal: true + platform: neopixelbus + type: GRB + variant: WS2811 + # method: esp32_rmt + num_leds: 32 + pin: GPIO13 + + - id: light_eu + name: Light + internal: true + platform: partition + default_transition_length: ${default_transition_length} + segments: + - id: light_full + from: 0 + to: 27 + effects: &light_effects_full + - addressable_rainbow: + - addressable_rainbow: + name: "Rainbow - Fast" + speed: 50 + - pulse: + - pulse: + name: "Pulse - Fast" + transition_length: 0.5s + update_interval: 0.5s + - pulse: + name: "Pulse - Slow" + update_interval: 2s + - addressable_scan: + - addressable_scan: + name: Scan Effect With Custom Values + move_interval: 100ms + scan_width: 3 + - addressable_twinkle: + - addressable_twinkle: + name: Twinkle Effect With Custom Values + twinkle_probability: 5% + progress_interval: 4ms + - addressable_random_twinkle: + - addressable_random_twinkle: + name: Random Twinkle Effect With Custom Values + twinkle_probability: 20% + progress_interval: 32ms + - addressable_fireworks: + - addressable_fireworks: + name: Fireworks Effect With Custom Values + update_interval: 32ms + spark_probability: 10% + use_random_color: false + fade_out_rate: 120 + - addressable_flicker: + - addressable_flicker: + name: Flicker Effect With Custom Values + update_interval: 16ms + intensity: 5% + - random: + - id: light_us + name: Light + internal: true + platform: partition + default_transition_length: ${default_transition_length} + segments: + - id: light_full + from: 0 + to: 31 + effects: *light_effects_full + + - id: light_eu_bottom + name: Light - Bottom + internal: true + disabled_by_default: true + platform: partition + default_transition_length: ${default_transition_length} + segments: + - id: light_full + from: 6 + to: 12 + reversed: true + effects: *light_effects_full + - id: light_eu_left + name: Light - Left + internal: true + disabled_by_default: true + platform: partition + default_transition_length: ${default_transition_length} + segments: + - id: light_full + from: 13 + to: 19 + reversed: true + effects: *light_effects_full + - id: light_eu_right + name: Light - Right + internal: true + disabled_by_default: true + platform: partition + default_transition_length: ${default_transition_length} + segments: + - id: light_full + from: 27 + to: 27 + reversed: false + - id: light_full + from: 0 + to: 5 + reversed: false + effects: *light_effects_full + - id: light_eu_top + name: Light - Top + internal: true + disabled_by_default: true + platform: partition + default_transition_length: ${default_transition_length} + segments: + - id: light_full + from: 20 + to: 26 + reversed: false + effects: *light_effects_full + - id: light_us_bottom + name: Light - Bottom + internal: true + disabled_by_default: true + platform: partition + default_transition_length: ${default_transition_length} + segments: + - id: light_full + from: 9 + to: 14 + reversed: true + effects: *light_effects_full + - id: light_us_left + name: Light - Left + internal: true + disabled_by_default: true + platform: partition + default_transition_length: ${default_transition_length} + segments: + - id: light_full + from: 15 + to: 24 + reversed: true + effects: *light_effects_full + - id: light_us_right + name: Light - Right + internal: true + disabled_by_default: true + platform: partition + default_transition_length: ${default_transition_length} + segments: + - id: light_full + from: 31 + to: 31 + reversed: false + - id: light_full + from: 0 + to: 8 + reversed: false + effects: *light_effects_full + - id: light_us_top + name: Light - Top + internal: true + disabled_by_default: true + platform: partition + default_transition_length: ${default_transition_length} + segments: + - id: light_full + from: 25 + to: 30 + reversed: false + effects: *light_effects_full + + - id: light_00 + name: Light - LED 00 + disabled_by_default: true + platform: partition + default_transition_length: ${default_transition_length} + segments: + - id: light_full + from: 0 + to: 0 + - id: light_01 + name: Light - LED 01 + disabled_by_default: true + platform: partition + default_transition_length: ${default_transition_length} + segments: + - id: light_full + from: 1 + to: 1 + - id: light_02 + name: Light - LED 02 + disabled_by_default: true + platform: partition + default_transition_length: ${default_transition_length} + segments: + - id: light_full + from: 2 + to: 2 + - id: light_03 + name: Light - LED 03 + disabled_by_default: true + platform: partition + default_transition_length: ${default_transition_length} + segments: + - id: light_full + from: 3 + to: 3 + - id: light_04 + name: Light - LED 04 + disabled_by_default: true + platform: partition + default_transition_length: ${default_transition_length} + segments: + - id: light_full + from: 4 + to: 4 + - id: light_05 + name: Light - LED 05 + disabled_by_default: true + platform: partition + default_transition_length: ${default_transition_length} + segments: + - id: light_full + from: 5 + to: 5 + - id: light_06 + name: Light - LED 06 + disabled_by_default: true + platform: partition + default_transition_length: ${default_transition_length} + segments: + - id: light_full + from: 6 + to: 6 + - id: light_07 + name: Light - LED 07 + disabled_by_default: true + platform: partition + default_transition_length: ${default_transition_length} + segments: + - id: light_full + from: 7 + to: 7 + - id: light_08 + name: Light - LED 08 + disabled_by_default: true + platform: partition + default_transition_length: ${default_transition_length} + segments: + - id: light_full + from: 8 + to: 8 + - id: light_09 + name: Light - LED 09 + disabled_by_default: true + platform: partition + default_transition_length: ${default_transition_length} + segments: + - id: light_full + from: 9 + to: 9 + - id: light_10 + name: Light - LED 10 + disabled_by_default: true + platform: partition + default_transition_length: ${default_transition_length} + segments: + - id: light_full + from: 10 + to: 10 + - id: light_11 + name: Light - LED 11 + disabled_by_default: true + platform: partition + default_transition_length: ${default_transition_length} + segments: + - id: light_full + from: 11 + to: 11 + - id: light_12 + name: Light - LED 12 + disabled_by_default: true + platform: partition + default_transition_length: ${default_transition_length} + segments: + - id: light_full + from: 12 + to: 12 + - id: light_13 + name: Light - LED 13 + disabled_by_default: true + platform: partition + default_transition_length: ${default_transition_length} + segments: + - id: light_full + from: 13 + to: 13 + - id: light_14 + name: Light - LED 14 + disabled_by_default: true + platform: partition + default_transition_length: ${default_transition_length} + segments: + - id: light_full + from: 14 + to: 14 + - id: light_15 + name: Light - LED 15 + disabled_by_default: true + platform: partition + default_transition_length: ${default_transition_length} + segments: + - id: light_full + from: 15 + to: 15 + - id: light_16 + name: Light - LED 16 + disabled_by_default: true + platform: partition + default_transition_length: ${default_transition_length} + segments: + - id: light_full + from: 16 + to: 16 + - id: light_17 + name: Light - LED 17 + disabled_by_default: true + platform: partition + default_transition_length: ${default_transition_length} + segments: + - id: light_full + from: 17 + to: 17 + - id: light_18 + name: Light - LED 18 + disabled_by_default: true + platform: partition + default_transition_length: ${default_transition_length} + segments: + - id: light_full + from: 18 + to: 18 + - id: light_19 + name: Light - LED 19 + disabled_by_default: true + platform: partition + default_transition_length: ${default_transition_length} + segments: + - id: light_full + from: 19 + to: 19 + - id: light_20 + name: Light - LED 20 + disabled_by_default: true + platform: partition + default_transition_length: ${default_transition_length} + segments: + - id: light_full + from: 20 + to: 20 + - id: light_21 + name: Light - LED 21 + disabled_by_default: true + platform: partition + default_transition_length: ${default_transition_length} + segments: + - id: light_full + from: 21 + to: 21 + - id: light_22 + name: Light - LED 22 + disabled_by_default: true + platform: partition + default_transition_length: ${default_transition_length} + segments: + - id: light_full + from: 22 + to: 22 + - id: light_23 + name: Light - LED 23 + disabled_by_default: true + platform: partition + default_transition_length: ${default_transition_length} + segments: + - id: light_full + from: 23 + to: 23 + - id: light_24 + name: Light - LED 24 + disabled_by_default: true + platform: partition + default_transition_length: ${default_transition_length} + segments: + - id: light_full + from: 24 + to: 24 + - id: light_25 + name: Light - LED 25 + disabled_by_default: true + platform: partition + default_transition_length: ${default_transition_length} + segments: + - id: light_full + from: 25 + to: 25 + - id: light_26 + name: Light - LED 26 + disabled_by_default: true + platform: partition + default_transition_length: ${default_transition_length} + segments: + - id: light_full + from: 26 + to: 26 + - id: light_27 + name: Light - LED 27 + disabled_by_default: true + platform: partition + default_transition_length: ${default_transition_length} + segments: + - id: light_full + from: 27 + to: 27 + - id: light_28 + name: Light - LED 28 + internal: true + disabled_by_default: true + platform: partition + default_transition_length: ${default_transition_length} + segments: + - id: light_full + from: 28 + to: 28 + - id: light_29 + name: Light - LED 29 + internal: true + disabled_by_default: true + platform: partition + default_transition_length: ${default_transition_length} + segments: + - id: light_full + from: 29 + to: 29 + - id: light_30 + name: Light - LED 30 + internal: true + disabled_by_default: true + platform: partition + default_transition_length: ${default_transition_length} + segments: + - id: light_full + from: 30 + to: 30 + - id: light_31 + name: Light - LED 31 + internal: true + disabled_by_default: true + platform: partition + default_transition_length: ${default_transition_length} + segments: + - id: light_full + from: 31 + to: 31 + + - id: light_eu_rl_1_1_bottom + name: Light - Relay 1 of 1 (bottom) + internal: true + platform: partition + default_transition_length: ${default_transition_length} + segments: + - id: light_full + from: 9 + to: 9 + - id: light_eu_rl_1_1_top + name: Light - Relay 1 of 1 (top) + internal: true + platform: partition + default_transition_length: ${default_transition_length} + segments: + - id: light_full + from: 23 + to: 23 + - id: light_eu_rl_1_2_bottom + name: Light - Relay 1 of 2 (bottom) + internal: true + platform: partition + default_transition_length: ${default_transition_length} + segments: + - id: light_full + from: 11 + to: 11 + - id: light_eu_rl_1_2_top + name: Light - Relay 1 of 2 (top) + internal: true + platform: partition + default_transition_length: ${default_transition_length} + segments: + - id: light_full + from: 21 + to: 21 + - id: light_eu_rl_2_2_bottom + name: Light - Relay 2 of 2 (bottom) + internal: true + platform: partition + default_transition_length: ${default_transition_length} + segments: + - id: light_full + from: 7 + to: 7 + - id: light_eu_rl_2_2_top + name: Light - Relay 2 of 2 (top) + internal: true + platform: partition + default_transition_length: ${default_transition_length} + segments: + - id: light_full + from: 25 + to: 25 + - id: light_eu_rl_1_3_bottom + name: Light - Relay 1 of 3 (bottom) + internal: true + platform: partition + default_transition_length: ${default_transition_length} + segments: + - id: light_full + from: 12 + to: 12 + - id: light_eu_rl_1_3_top + name: Light - Relay 1 of 3 (top) + internal: true + platform: partition + default_transition_length: ${default_transition_length} + segments: + - id: light_full + from: 20 + to: 20 + - id: light_eu_rl_2_3_bottom + name: Light - Relay 2 of 3 (bottom) + internal: true + platform: partition + default_transition_length: ${default_transition_length} + segments: + - id: light_full + from: 9 + to: 9 + - id: light_eu_rl_2_3_top + name: Light - Relay 2 of 3 (top) + internal: true + platform: partition + default_transition_length: ${default_transition_length} + segments: + - id: light_full + from: 23 + to: 23 + - id: light_eu_rl_3_3_bottom + name: Light - Relay 3 of 3 (bottom) + internal: true + platform: partition + default_transition_length: ${default_transition_length} + segments: + - id: light_full + from: 6 + to: 6 + - id: light_eu_rl_3_3_top + name: Light - Relay 3 of 3 (top) + internal: true + platform: partition + default_transition_length: ${default_transition_length} + segments: + - id: light_full + from: 26 + to: 26 + - id: light_eu_rl_1_4_bottom + name: Light - Relay 1 of 4 (bottom) + internal: true + platform: partition + default_transition_length: ${default_transition_length} + segments: + - id: light_full + from: 12 + to: 12 + - id: light_eu_rl_1_4_top + name: Light - Relay 1 of 4 (top) + internal: true + platform: partition + default_transition_length: ${default_transition_length} + segments: + - id: light_full + from: 20 + to: 20 + - id: light_eu_rl_2_4_bottom + name: Light - Relay 2 of 4 (bottom) + internal: true + platform: partition + default_transition_length: ${default_transition_length} + segments: + - id: light_full + from: 10 + to: 10 + - id: light_eu_rl_2_4_top + name: Light - Relay 2 of 4 (top) + internal: true + platform: partition + default_transition_length: ${default_transition_length} + segments: + - id: light_full + from: 22 + to: 22 + - id: light_eu_rl_3_4_bottom + name: Light - Relay 3 of 4 (bottom) + internal: true + platform: partition + default_transition_length: ${default_transition_length} + segments: + - id: light_full + from: 8 + to: 8 + - id: light_eu_rl_3_4_top + name: Light - Relay 3 of 4 (top) + internal: true + platform: partition + default_transition_length: ${default_transition_length} + segments: + - id: light_full + from: 24 + to: 24 + - id: light_eu_rl_4_4_bottom + name: Light - Relay 4 of 4 (bottom) + internal: true + platform: partition + default_transition_length: ${default_transition_length} + segments: + - id: light_full + from: 6 + to: 6 + - id: light_eu_rl_4_4_top + name: Light - Relay 4 of 4 (top) + internal: true + platform: partition + default_transition_length: ${default_transition_length} + segments: + - id: light_full + from: 26 + to: 26 + - id: light_us_rl_1_1_left + name: Light - Relay 1 of 1 (left) + internal: true + platform: partition + default_transition_length: ${default_transition_length} + segments: + - id: light_full + from: 15 + to: 24 + - id: light_us_rl_1_1_right + name: Light - Relay 1 of 1 (right) + internal: true + platform: partition + default_transition_length: ${default_transition_length} + segments: + - id: light_full + from: 31 + to: 31 + - id: light_full + from: 0 + to: 8 + - id: light_us_rl_1_2_left + name: Light - Relay 1 of 2 (left) + internal: true + platform: partition + default_transition_length: ${default_transition_length} + segments: + - id: light_full + from: 20 + to: 24 + - id: light_us_rl_1_2_right + name: Light - Relay 1 of 2 (right) + internal: true + platform: partition + default_transition_length: ${default_transition_length} + segments: + - id: light_full + from: 31 + to: 31 + - id: light_full + from: 0 + to: 3 + - id: light_us_rl_2_2_left + name: Light - Relay 2 of 2 (left) + internal: true + platform: partition + default_transition_length: ${default_transition_length} + segments: + - id: light_full + from: 15 + to: 19 + - id: light_us_rl_2_2_right + name: Light - Relay 2 of 2 (right) + internal: true + platform: partition + default_transition_length: ${default_transition_length} + segments: + - id: light_full + from: 4 + to: 8 + - id: light_us_rl_1_3_left + name: Light - Relay 1 of 3 (left) + internal: true + platform: partition + default_transition_length: ${default_transition_length} + segments: + - id: light_full + from: 22 + to: 23 + - id: light_us_rl_1_3_right + name: Light - Relay 1 of 3 (right) + internal: true + platform: partition + default_transition_length: ${default_transition_length} + segments: + - id: light_full + from: 0 + to: 1 + - id: light_us_rl_2_3_left + name: Light - Relay 2 of 3 (left) + internal: true + platform: partition + default_transition_length: ${default_transition_length} + segments: + - id: light_full + from: 19 + to: 20 + - id: light_us_rl_2_3_right + name: Light - Relay 2 of 3 (right) + internal: true + platform: partition + default_transition_length: ${default_transition_length} + segments: + - id: light_full + from: 3 + to: 4 + - id: light_us_rl_3_3_left + name: Light - Relay 3 of 3 (left) + internal: true + platform: partition + default_transition_length: ${default_transition_length} + segments: + - id: light_full + from: 17 + to: 18 + - id: light_us_rl_3_3_right + name: Light - Relay 3 of 3 (right) + internal: true + platform: partition + default_transition_length: ${default_transition_length} + segments: + - id: light_full + from: 6 + to: 7 + - id: light_us_rl_1_4_left + name: Light - Relay 1 of 4 (left) + internal: true + platform: partition + default_transition_length: ${default_transition_length} + segments: + - id: light_full + from: 12 + to: 12 + - id: light_us_rl_1_4_right + name: Light - Relay 1 of 4 (right) + internal: true + platform: partition + default_transition_length: ${default_transition_length} + segments: + - id: light_full + from: 31 + to: 31 + - id: light_us_rl_2_4_left + name: Light - Relay 2 of 4 (left) + internal: true + platform: partition + default_transition_length: ${default_transition_length} + segments: + - id: light_full + from: 24 + to: 24 + - id: light_us_rl_2_4_right + name: Light - Relay 2 of 4 (right) + internal: true + platform: partition + default_transition_length: ${default_transition_length} + segments: + - id: light_full + from: 2 + to: 2 + - id: light_us_rl_3_4_left + name: Light - Relay 3 of 4 (left) + internal: true + platform: partition + default_transition_length: ${default_transition_length} + segments: + - id: light_full + from: 21 + to: 21 + - id: light_us_rl_3_4_right + name: Light - Relay 3 of 4 (right) + internal: true + platform: partition + default_transition_length: ${default_transition_length} + segments: + - id: light_full + from: 4 + to: 4 + - id: light_us_rl_4_4_left + name: Light - Relay 4 of 4 (left) + internal: true + platform: partition + default_transition_length: ${default_transition_length} + segments: + - id: light_full + from: 19 + to: 19 + - id: light_us_rl_4_4_right + name: Light - Relay 4 of 4 (right) + internal: true + platform: partition + default_transition_length: ${default_transition_length} + segments: + - id: light_full + from: 7 + to: 7 + +select: + - id: sl_relay_1_light_mode_eu + name: Relay 1 light mode + platform: template + options: + - "Disabled" + - "Bottom" + - "Top" + - "Both" + initial_option: "Bottom" + optimistic: true + restore_value: true + internal: true + entity_category: config + disabled_by_default: false + icon: mdi:dots-square + + - id: sl_relay_2_light_mode_eu + name: Relay 2 light mode + platform: template + options: + - "Disabled" + - "Bottom" + - "Top" + - "Both" + initial_option: "Bottom" + optimistic: true + restore_value: true + internal: true + entity_category: config + disabled_by_default: false + icon: mdi:dots-square + + - id: sl_relay_3_light_mode_eu + name: Relay 3 light mode + platform: template + options: + - "Disabled" + - "Bottom" + - "Top" + - "Both" + initial_option: "Bottom" + optimistic: true + restore_value: true + internal: true + entity_category: config + disabled_by_default: false + icon: mdi:dots-square + + - id: sl_relay_4_light_mode_eu + name: Relay 4 light mode + platform: template + options: + - "Disabled" + - "Bottom" + - "Top" + - "Both" + initial_option: "Bottom" + optimistic: true + restore_value: true + internal: true + entity_category: config + disabled_by_default: false + icon: mdi:dots-square + + - id: sl_relay_1_light_mode_us + name: Relay 1 light mode + platform: template + options: + - "Disabled" + - "Left" + - "Right" + - "Both" + initial_option: "Right" + optimistic: true + restore_value: true + internal: true + entity_category: config + disabled_by_default: false + icon: mdi:dots-square + + - id: sl_relay_2_light_mode_us + name: Relay 2 light mode + platform: template + options: + - "Disabled" + - "Left" + - "Right" + - "Both" + initial_option: "Right" + optimistic: true + restore_value: true + internal: true + entity_category: config + disabled_by_default: false + icon: mdi:dots-square + + - id: sl_relay_3_light_mode_us + name: Relay 3 light mode + platform: template + options: + - "Disabled" + - "Left" + - "Right" + - "Both" + initial_option: "Right" + optimistic: true + restore_value: true + internal: true + entity_category: config + disabled_by_default: false + icon: mdi:dots-square + + - id: sl_relay_4_light_mode_us + name: Relay 4 light mode + platform: template + options: + - "Disabled" + - "Left" + - "Right" + - "Both" + initial_option: "Right" + optimistic: true + restore_value: true + internal: true + entity_category: config + disabled_by_default: false + icon: mdi:dots-square + +... diff --git a/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_relays.yaml b/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_relays.yaml new file mode 100644 index 0000000..04008e9 --- /dev/null +++ b/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_relays.yaml @@ -0,0 +1,226 @@ +#################################################################################################### +##### TX Ultimate Easy for ESPHome ##### +##### Repository: https://github.com/edwardtfn/TX-Ultimate-Easy ##### +#################################################################################################### +##### Purpose: ESPHome Core - Hardware - Relays ##### +#################################################################################################### +##### Author: edwardtfn - https://github.com/edwardtfn - https://buymeacoffee.com/edwardfirmo ##### +#################################################################################################### +##### NOTE: ##### +##### - Make changes ONLY if absolutely necessary and you have the required knowledge. ##### +##### - For normal system use, modifications to this file are NOT required. ##### +#################################################################################################### +--- +binary_sensor: + - id: !extend bs_button_1 + on_click: + then: + - lambda: |- + if (sl_button_1_action->active_index().has_value() and + sl_button_1_action->active_index().value() == 1 and + !bs_multi_touch->state and + !bs_swipe_left->state and + !bs_swipe_down->state and + !bs_swipe_right->state) + sw_relay_1->toggle(); + + - id: !extend bs_button_2 + on_click: + then: + - lambda: |- + if (sl_button_2_action->active_index().has_value() and + sl_button_2_action->active_index().value() == 1 and + !bs_multi_touch->state and + !bs_swipe_left->state and + !bs_swipe_down->state and + !bs_swipe_right->state) + sw_relay_2->toggle(); + + - id: !extend bs_button_3 + on_click: + then: + - lambda: |- + if (sl_button_3_action->active_index().has_value() and + sl_button_3_action->active_index().value() == 1 and + !bs_multi_touch->state and + !bs_swipe_left->state and + !bs_swipe_down->state and + !bs_swipe_right->state) + sw_relay_3->toggle(); + + - id: !extend bs_button_4 + on_click: + then: + - lambda: |- + if (sl_button_4_action->active_index().has_value() and + sl_button_4_action->active_index().value() == 1 and + !bs_multi_touch->state and + !bs_swipe_left->state and + !bs_swipe_down->state and + !bs_swipe_right->state) + sw_relay_4->toggle(); + +output: + - id: output_relay_1 + platform: gpio + pin: GPIO18 + + - id: output_relay_2 + platform: gpio + pin: GPIO17 + + - id: output_relay_3 + platform: gpio + pin: GPIO27 + + - id: output_relay_4 + platform: gpio + pin: GPIO23 + +script: + - id: show_relay_status + mode: restart + then: + - lambda: |- + return; + show_relay_status->stop(); + auto model_format = sl_tx_model_format->active_index(); + std::vector relay_modes; + + if (model_format.has_value() and model_format.value() == 0) { + relay_modes = {sl_relay_1_light_mode_eu, sl_relay_2_light_mode_eu, sl_relay_3_light_mode_eu, sl_relay_4_light_mode_eu}; + } else { + relay_modes = {sl_relay_1_light_mode_us, sl_relay_2_light_mode_us, sl_relay_3_light_mode_us, sl_relay_4_light_mode_us}; + } + + std::vector switches = {sw_relay_1, sw_relay_2, sw_relay_3, sw_relay_4}; + for (int i = 0; i < relay_modes.size(); ++i) { + auto light_index = relay_modes[i]->active_index(); + if (light_index.has_value()) { + uint8_t light_idx = light_index.value(); + bool switch_state = switches[i]->state; + if (light_idx == 1 || light_idx == 3) { + if (switch_state) + id(gb_lights_1)[i]->turn_on().perform(); + else + id(gb_lights_1)[i]->turn_off().perform(); + } + if (light_idx == 2 || light_idx == 3) { + if (switch_state) + id(gb_lights_2)[i]->turn_on().perform(); + else + id(gb_lights_2)[i]->turn_off().perform(); + } + } + } + +select: + - id: sl_relay_1_mode + name: Relay 1 mode + platform: template + options: + - "Relay" + - "Light" + - "Not in use" + optimistic: true + restore_value: true + internal: true + entity_category: config + disabled_by_default: false + icon: mdi:dip-switch + + - id: sl_relay_2_mode + name: Relay 2 mode + platform: template + options: + - "Relay" + - "Light" + - "Not in use" + optimistic: true + restore_value: true + internal: true + entity_category: config + disabled_by_default: false + icon: mdi:dip-switch + + - id: sl_relay_3_mode + name: Relay 3 mode + platform: template + options: + - "Relay" + - "Light" + - "Not in use" + optimistic: true + restore_value: true + internal: true + entity_category: config + disabled_by_default: false + icon: mdi:dip-switch + + - id: sl_relay_4_mode + name: Relay 4 mode + platform: template + options: + - "Relay" + - "Light" + - "Not in use" + optimistic: true + restore_value: true + internal: true + entity_category: config + disabled_by_default: false + icon: mdi:dip-switch + +switch: + - id: sw_relay_1 + name: Relay 1 + platform: output + output: output_relay_1 + restore_mode: RESTORE_DEFAULT_OFF + internal: true + on_turn_on: + then: + - script.execute: show_relay_status + on_turn_off: + then: + - script.execute: show_relay_status + + - id: sw_relay_2 + name: Relay 2 + platform: output + output: output_relay_2 + restore_mode: RESTORE_DEFAULT_OFF + internal: true + on_turn_on: + then: + - script.execute: show_relay_status + on_turn_off: + then: + - script.execute: show_relay_status + + - id: sw_relay_3 + name: Relay 3 + platform: output + output: output_relay_3 + restore_mode: RESTORE_DEFAULT_OFF + internal: true + on_turn_on: + then: + - script.execute: show_relay_status + on_turn_off: + then: + - script.execute: show_relay_status + + - id: sw_relay_4 + name: Relay 4 + platform: output + output: output_relay_4 + restore_mode: RESTORE_DEFAULT_OFF + internal: true + on_turn_on: + then: + - script.execute: show_relay_status + on_turn_off: + then: + - script.execute: show_relay_status +... diff --git a/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_speaker.yaml b/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_speaker.yaml new file mode 100644 index 0000000..11178ec --- /dev/null +++ b/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_speaker.yaml @@ -0,0 +1,29 @@ +#################################################################################################### +##### TX Ultimate Easy for ESPHome ##### +##### Repository: https://github.com/edwardtfn/TX-Ultimate-Easy ##### +#################################################################################################### +##### Purpose: ESPHome Core - Hardware - Speaker ##### +#################################################################################################### +##### Author: edwardtfn - https://github.com/edwardtfn - https://buymeacoffee.com/edwardfirmo ##### +#################################################################################################### +##### NOTE: ##### +##### - Make changes ONLY if absolutely necessary and you have the required knowledge. ##### +##### - For normal system use, modifications to this file are NOT required. ##### +#################################################################################################### +--- +i2s_audio: + id: if_i2s_audio + i2s_bclk_pin: GPIO2 + i2s_lrclk_pin: GPIO4 + +media_player: + - id: mp_speaker + name: Speaker + platform: i2s_audio + i2s_dout_pin: GPIO15 + i2s_audio_id: if_i2s_audio + i2s_comm_fmt: lsb + dac_type: external + mode: mono + internal: false +... diff --git a/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_touch.yaml b/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_touch.yaml new file mode 100644 index 0000000..e9de90b --- /dev/null +++ b/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_touch.yaml @@ -0,0 +1,212 @@ +#################################################################################################### +##### TX Ultimate Easy for ESPHome ##### +##### Repository: https://github.com/edwardtfn/TX-Ultimate-Easy ##### +#################################################################################################### +##### Purpose: ESPHome Core - Hardware - Touch panel ##### +#################################################################################################### +##### Author: edwardtfn - https://github.com/edwardtfn - https://buymeacoffee.com/edwardfirmo ##### +#################################################################################################### +##### NOTE: ##### +##### - Make changes ONLY if absolutely necessary and you have the required knowledge. ##### +##### - For normal system use, modifications to this file are NOT required. ##### +#################################################################################################### +--- +binary_sensor: + - id: bs_multi_touch + name: Multi-touch + icon: mdi:gesture-two-tap + internal: false + platform: template + on_click: + then: + - lambda: send_event_to_ha->execute("multi_touch", "multi_touch"); + + - id: bs_swipe_left + name: Swipe left + icon: mdi:gesture-swipe-left + internal: true + platform: template + on_click: + then: + - lambda: send_event_to_ha->execute("swipe", "left"); + + - id: bs_swipe_right + name: Swipe right + icon: mdi:gesture-swipe-right + internal: true + platform: template + on_click: + then: + - lambda: send_event_to_ha->execute("swipe", "right"); + + - id: bs_swipe_up + name: Swipe up + icon: mdi:gesture-swipe-up + internal: true + platform: template + on_click: + then: + - lambda: send_event_to_ha->execute("swipe", "up"); + + - id: bs_swipe_down + name: Swipe down + icon: mdi:gesture-swipe-down + internal: true + platform: template + on_click: + then: + - lambda: send_event_to_ha->execute("swipe", "down"); + +external_components: + - source: github://edwardtfn/TX-Ultimate-Easy@dev # Change this before releasing + components: + - tx_ultimate_easy + +number: + - id: nr_touch_duration + name: Touch duration + icon: mdi:timer-cog-outline + unit_of_measurement: ms + # mode: box + internal: false + entity_category: config + platform: template + min_value: 10 + max_value: 1500 + step: 1 + initial_value: 250 + optimistic: true + restore_value: true + +script: + - id: touch_on_multi_touch_release + mode: restart + then: + # Extended by: + # - HW Buttons + # - HW Vibration + - script.execute: touch_on_multi_touch_release_touch + + - id: touch_on_multi_touch_release_touch + mode: restart + then: + - lambda: bs_multi_touch->publish_state(true); + - delay: !lambda return nr_touch_duration->state; + - lambda: bs_multi_touch->publish_state(false); + + - id: touch_on_press + mode: restart + parameters: + touch_x: uint8_t + then: + # Extended by: + # - HW Buttons + # - HW Vibration + + - id: touch_on_release + mode: restart + then: + # Extended by: + # - HW Buttons + # - HW Vibration + - script.execute: touch_swipe_turn_off_binary_sensor + + - id: touch_swipe_left + mode: restart + then: + # Extended by: + # - HW Buttons + - script.execute: touch_swipe_left_touch + + - id: touch_swipe_left_touch + mode: restart + then: + - binary_sensor.template.publish: + id: bs_swipe_left + state: ON + - delay: !lambda return nr_touch_duration->state; + - script.execute: touch_swipe_turn_off_binary_sensor + + - id: touch_swipe_right + mode: restart + then: + # Extended by: + # - HW Buttons + - script.execute: touch_swipe_right_touch + + - id: touch_swipe_right_touch + mode: restart + then: + - binary_sensor.template.publish: + id: bs_swipe_right + state: ON + - delay: !lambda return nr_touch_duration->state; + - script.execute: touch_swipe_turn_off_binary_sensor + + - id: touch_swipe_turn_off_binary_sensor + mode: restart + then: + - if: + condition: + binary_sensor.is_on: bs_swipe_left + then: + - binary_sensor.template.publish: + id: bs_swipe_left + state: OFF + - if: + condition: + binary_sensor.is_on: bs_swipe_right + then: + - binary_sensor.template.publish: + id: bs_swipe_right + state: OFF + +switch: + - id: sw_touch_panel_power + name: Touch panel - Power + platform: gpio + pin: + number: GPIO5 + inverted: true + restore_mode: ALWAYS_ON + internal: false + entity_category: config + +tx_ultimate_easy: + id: tx_ultimate + uart: uart_touch + + on_multi_touch_release: + - lambda: ESP_LOGI("tx_ultimate_easy", "Multi-touch released"); + - script.execute: touch_on_multi_touch_release + + on_press: + - lambda: ESP_LOGI("tx_ultimate_easy", "Pressed"); + - script.execute: + id: touch_on_multi_touch_press + touch_x: !lambda return static_cast(touch.x); + + on_release: + - lambda: ESP_LOGI("tx_ultimate_easy", "Released"); + - script.execute: touch_on_release + + on_swipe_left: + - lambda: ESP_LOGI("tx_ultimate_easy", "Swipe left"); + - script.execute: touch_swipe_left + + on_swipe_right: + - lambda: ESP_LOGI("tx_ultimate_easy", "Swipe right"); + - script.execute: touch_swipe_right + + on_touch_event: + - lambda: |- + ESP_LOGD("tx_ultimate_easy", "Touch event:"); + ESP_LOGD("tx_ultimate_easy", " State: %i (%s)", touch.state, touch.state_str.c_str()); + ESP_LOGD("tx_ultimate_easy", " Position: %i", touch.x); + +uart: + id: uart_touch + tx_pin: GPIO19 + rx_pin: GPIO22 + baud_rate: 115200 +... diff --git a/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_vibration.yaml b/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_vibration.yaml new file mode 100644 index 0000000..366d77f --- /dev/null +++ b/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_vibration.yaml @@ -0,0 +1,120 @@ +#################################################################################################### +##### TX Ultimate Easy for ESPHome ##### +##### Repository: https://github.com/edwardtfn/TX-Ultimate-Easy ##### +#################################################################################################### +##### Purpose: ESPHome Core - Hardware - Vibration system ##### +#################################################################################################### +##### Author: edwardtfn - https://github.com/edwardtfn - https://buymeacoffee.com/edwardfirmo ##### +#################################################################################################### +##### NOTE: ##### +##### - Make changes ONLY if absolutely necessary and you have the required knowledge. ##### +##### - For normal system use, modifications to this file are NOT required. ##### +#################################################################################################### +--- +binary_sensor: + - id: bs_vibrating + name: Vibrating + icon: mdi:vibrate + internal: false + platform: template + lambda: return sw_vibration_motor->state; + +button: + - id: bt_vibrate + name: Vibrate + icon: mdi:vibrate + internal: false + platform: template + on_press: + then: + - script.execute: vibrate + +number: + - id: nr_vibrating_duration + name: Vibrate duration + icon: mdi:vibrate + unit_of_measurement: ms + # mode: box + internal: false + entity_category: config + platform: template + min_value: 1 + max_value: 500 + step: 1 + initial_value: 15 + optimistic: true + restore_value: true + +script: + - id: !extend touch_on_multi_touch_release + then: + - script.execute: touch_on_multi_touch_release_vibration + + - id: touch_on_multi_touch_release_vibration + mode: restart + then: + - lambda: |- + if (sl_touch_vibration_feedback->state != "Disabled") + vibrate->execute(); + + - id: !extend touch_on_press + then: + - script.execute: touch_on_press_vibration + + - id: touch_on_press_vibration + mode: restart + then: + - lambda: |- + if (sl_touch_vibration_feedback->state == "On press" or sl_touch_vibration_feedback->state == "Always") + vibrate->execute(); + + - id: !extend touch_on_release + then: + - script.execute: touch_on_release_vibration + + - id: touch_on_release_vibration + mode: restart + then: + - lambda: |- + if (sl_touch_vibration_feedback->state == "On release" or sl_touch_vibration_feedback->state == "Always") + vibrate->execute(); + + - id: vibrate + mode: restart + then: + - switch.turn_on: sw_vibration_motor + - delay: !lambda return nr_vibrating_duration->state; + - switch.turn_off: sw_vibration_motor + +select: + - id: sl_touch_vibration_feedback + name: Touch - Vibration feedback + platform: template + options: + - "Disabled" + - "On press" + - "On release" + - "Always" + initial_option: "Disabled" + optimistic: true + restore_value: true + internal: false + entity_category: config + disabled_by_default: false + icon: mdi:vibrate + +switch: + - id: sw_vibration_motor + name: Vibration motor + platform: gpio + pin: GPIO21 + restore_mode: ALWAYS_OFF + internal: true + on_turn_on: + then: + - lambda: bs_vibrating->publish_state(true); + on_turn_off: + then: + - lambda: bs_vibrating->publish_state(false); + +... diff --git a/TX-Ultimate-Easy-ESPHome.yaml b/TX-Ultimate-Easy-ESPHome.yaml index f171b9a..3b95ea8 100644 --- a/TX-Ultimate-Easy-ESPHome.yaml +++ b/TX-Ultimate-Easy-ESPHome.yaml @@ -1,3 +1,9 @@ +#################################################################################################### +##### TX Ultimate Easy for ESPHome ##### +##### Repository: https://github.com/edwardtfn/TX-Ultimate-Easy ##### +#################################################################################################### +##### Author: edwardtfn - https://github.com/edwardtfn - https://buymeacoffee.com/edwardfirmo ##### +#################################################################################################### --- substitutions: name: tx-ultimate-easy From 3f86f7dee9504281f21d20fcc1db2306482824d1 Mon Sep 17 00:00:00 2001 From: Edward Firmo <94725493+edwardtfn@users.noreply.github.com> Date: Thu, 19 Dec 2024 20:11:52 +0100 Subject: [PATCH 03/36] Reorg led files --- ESPHome/TX-Ultimate-Easy-ESPHome_core.yaml | 2 +- ...X-Ultimate-Easy-ESPHome_core_hw_leds.yaml} | 346 ++++++------------ ...-Easy-ESPHome_core_hw_leds_light_base.yaml | 2 + ...sy-ESPHome_core_hw_leds_light_effects.yaml | 41 +++ ...y-ESPHome_core_hw_leds_light_internal.yaml | 2 + ...X-Ultimate-Easy-ESPHome_core_hw_touch.yaml | 2 +- 6 files changed, 153 insertions(+), 242 deletions(-) rename ESPHome/{TX-Ultimate-Easy-ESPHome_core_hw_led.yaml => TX-Ultimate-Easy-ESPHome_core_hw_leds.yaml} (65%) create mode 100644 ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_leds_light_base.yaml create mode 100644 ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_leds_light_effects.yaml create mode 100644 ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_leds_light_internal.yaml diff --git a/ESPHome/TX-Ultimate-Easy-ESPHome_core.yaml b/ESPHome/TX-Ultimate-Easy-ESPHome_core.yaml index 843dbe8..62a0a48 100644 --- a/ESPHome/TX-Ultimate-Easy-ESPHome_core.yaml +++ b/ESPHome/TX-Ultimate-Easy-ESPHome_core.yaml @@ -25,7 +25,7 @@ packages: # yamllint disable rule:colons core_api: !include TX-Ultimate-Easy-ESPHome_core_api.yaml core_hw_buttons: !include TX-Ultimate-Easy-ESPHome_core_hw_buttons.yaml - core_hw_led: !include TX-Ultimate-Easy-ESPHome_core_hw_led.yaml + core_hw_leds: !include TX-Ultimate-Easy-ESPHome_core_hw_leds.yaml core_hw_relays: !include TX-Ultimate-Easy-ESPHome_core_hw_relays.yaml core_hw_speaker: !include TX-Ultimate-Easy-ESPHome_core_hw_speaker.yaml core_hw_touch: !include TX-Ultimate-Easy-ESPHome_core_hw_touch.yaml diff --git a/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_led.yaml b/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_leds.yaml similarity index 65% rename from ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_led.yaml rename to ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_leds.yaml index 2f45d71..9f101d2 100644 --- a/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_led.yaml +++ b/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_leds.yaml @@ -2,7 +2,7 @@ ##### TX Ultimate Easy for ESPHome ##### ##### Repository: https://github.com/edwardtfn/TX-Ultimate-Easy ##### #################################################################################################### -##### Purpose: ESPHome Core - Hardware - LED ##### +##### Purpose: ESPHome Core - Hardware - LEDs ##### #################################################################################################### ##### Author: edwardtfn - https://github.com/edwardtfn - https://buymeacoffee.com/edwardfirmo ##### #################################################################################################### @@ -57,94 +57,48 @@ light: - id: light_eu name: Light internal: true - platform: partition - default_transition_length: ${default_transition_length} + <<: !include TX-Ultimate-Easy-ESPHome_core_hw_leds_light_base.yaml + <<: !include TX-Ultimate-Easy-ESPHome_core_hw_leds_light_effects.yaml segments: - id: light_full from: 0 to: 27 - effects: &light_effects_full - - addressable_rainbow: - - addressable_rainbow: - name: "Rainbow - Fast" - speed: 50 - - pulse: - - pulse: - name: "Pulse - Fast" - transition_length: 0.5s - update_interval: 0.5s - - pulse: - name: "Pulse - Slow" - update_interval: 2s - - addressable_scan: - - addressable_scan: - name: Scan Effect With Custom Values - move_interval: 100ms - scan_width: 3 - - addressable_twinkle: - - addressable_twinkle: - name: Twinkle Effect With Custom Values - twinkle_probability: 5% - progress_interval: 4ms - - addressable_random_twinkle: - - addressable_random_twinkle: - name: Random Twinkle Effect With Custom Values - twinkle_probability: 20% - progress_interval: 32ms - - addressable_fireworks: - - addressable_fireworks: - name: Fireworks Effect With Custom Values - update_interval: 32ms - spark_probability: 10% - use_random_color: false - fade_out_rate: 120 - - addressable_flicker: - - addressable_flicker: - name: Flicker Effect With Custom Values - update_interval: 16ms - intensity: 5% - - random: + - id: light_us name: Light internal: true - platform: partition - default_transition_length: ${default_transition_length} + <<: !include TX-Ultimate-Easy-ESPHome_core_hw_leds_light_base.yaml + <<: !include TX-Ultimate-Easy-ESPHome_core_hw_leds_light_effects.yaml segments: - id: light_full from: 0 to: 31 - effects: *light_effects_full - id: light_eu_bottom name: Light - Bottom - internal: true - disabled_by_default: true - platform: partition - default_transition_length: ${default_transition_length} + <<: !include TX-Ultimate-Easy-ESPHome_core_hw_leds_light_internal.yaml + <<: !include TX-Ultimate-Easy-ESPHome_core_hw_leds_light_base.yaml + <<: !include TX-Ultimate-Easy-ESPHome_core_hw_leds_light_effects.yaml segments: - id: light_full from: 6 to: 12 reversed: true - effects: *light_effects_full - id: light_eu_left name: Light - Left - internal: true - disabled_by_default: true - platform: partition - default_transition_length: ${default_transition_length} + <<: !include TX-Ultimate-Easy-ESPHome_core_hw_leds_light_internal.yaml + <<: !include TX-Ultimate-Easy-ESPHome_core_hw_leds_light_base.yaml + <<: !include TX-Ultimate-Easy-ESPHome_core_hw_leds_light_effects.yaml segments: - id: light_full from: 13 to: 19 reversed: true - effects: *light_effects_full - id: light_eu_right name: Light - Right - internal: true - disabled_by_default: true - platform: partition - default_transition_length: ${default_transition_length} + <<: !include TX-Ultimate-Easy-ESPHome_core_hw_leds_light_internal.yaml + <<: !include TX-Ultimate-Easy-ESPHome_core_hw_leds_light_base.yaml + <<: !include TX-Ultimate-Easy-ESPHome_core_hw_leds_light_effects.yaml segments: - id: light_full from: 27 @@ -154,49 +108,41 @@ light: from: 0 to: 5 reversed: false - effects: *light_effects_full - id: light_eu_top name: Light - Top - internal: true - disabled_by_default: true - platform: partition - default_transition_length: ${default_transition_length} + <<: !include TX-Ultimate-Easy-ESPHome_core_hw_leds_light_internal.yaml + <<: !include TX-Ultimate-Easy-ESPHome_core_hw_leds_light_base.yaml + <<: !include TX-Ultimate-Easy-ESPHome_core_hw_leds_light_effects.yaml segments: - id: light_full from: 20 to: 26 reversed: false - effects: *light_effects_full - id: light_us_bottom name: Light - Bottom - internal: true - disabled_by_default: true - platform: partition - default_transition_length: ${default_transition_length} + <<: !include TX-Ultimate-Easy-ESPHome_core_hw_leds_light_internal.yaml + <<: !include TX-Ultimate-Easy-ESPHome_core_hw_leds_light_base.yaml + <<: !include TX-Ultimate-Easy-ESPHome_core_hw_leds_light_effects.yaml segments: - id: light_full from: 9 to: 14 reversed: true - effects: *light_effects_full - id: light_us_left name: Light - Left - internal: true - disabled_by_default: true - platform: partition - default_transition_length: ${default_transition_length} + <<: !include TX-Ultimate-Easy-ESPHome_core_hw_leds_light_internal.yaml + <<: !include TX-Ultimate-Easy-ESPHome_core_hw_leds_light_base.yaml + <<: !include TX-Ultimate-Easy-ESPHome_core_hw_leds_light_effects.yaml segments: - id: light_full from: 15 to: 24 reversed: true - effects: *light_effects_full - id: light_us_right name: Light - Right - internal: true - disabled_by_default: true - platform: partition - default_transition_length: ${default_transition_length} + <<: !include TX-Ultimate-Easy-ESPHome_core_hw_leds_light_internal.yaml + <<: !include TX-Ultimate-Easy-ESPHome_core_hw_leds_light_base.yaml + <<: !include TX-Ultimate-Easy-ESPHome_core_hw_leds_light_effects.yaml segments: - id: light_full from: 31 @@ -206,25 +152,21 @@ light: from: 0 to: 8 reversed: false - effects: *light_effects_full - id: light_us_top name: Light - Top - internal: true - disabled_by_default: true - platform: partition - default_transition_length: ${default_transition_length} + <<: !include TX-Ultimate-Easy-ESPHome_core_hw_leds_light_internal.yaml + <<: !include TX-Ultimate-Easy-ESPHome_core_hw_leds_light_base.yaml + <<: !include TX-Ultimate-Easy-ESPHome_core_hw_leds_light_effects.yaml segments: - id: light_full from: 25 to: 30 reversed: false - effects: *light_effects_full - id: light_00 name: Light - LED 00 disabled_by_default: true - platform: partition - default_transition_length: ${default_transition_length} + <<: !include TX-Ultimate-Easy-ESPHome_core_hw_leds_light_base.yaml segments: - id: light_full from: 0 @@ -232,8 +174,7 @@ light: - id: light_01 name: Light - LED 01 disabled_by_default: true - platform: partition - default_transition_length: ${default_transition_length} + <<: !include TX-Ultimate-Easy-ESPHome_core_hw_leds_light_base.yaml segments: - id: light_full from: 1 @@ -241,8 +182,7 @@ light: - id: light_02 name: Light - LED 02 disabled_by_default: true - platform: partition - default_transition_length: ${default_transition_length} + <<: !include TX-Ultimate-Easy-ESPHome_core_hw_leds_light_base.yaml segments: - id: light_full from: 2 @@ -250,8 +190,7 @@ light: - id: light_03 name: Light - LED 03 disabled_by_default: true - platform: partition - default_transition_length: ${default_transition_length} + <<: !include TX-Ultimate-Easy-ESPHome_core_hw_leds_light_base.yaml segments: - id: light_full from: 3 @@ -259,8 +198,7 @@ light: - id: light_04 name: Light - LED 04 disabled_by_default: true - platform: partition - default_transition_length: ${default_transition_length} + <<: !include TX-Ultimate-Easy-ESPHome_core_hw_leds_light_base.yaml segments: - id: light_full from: 4 @@ -268,8 +206,7 @@ light: - id: light_05 name: Light - LED 05 disabled_by_default: true - platform: partition - default_transition_length: ${default_transition_length} + <<: !include TX-Ultimate-Easy-ESPHome_core_hw_leds_light_base.yaml segments: - id: light_full from: 5 @@ -277,8 +214,7 @@ light: - id: light_06 name: Light - LED 06 disabled_by_default: true - platform: partition - default_transition_length: ${default_transition_length} + <<: !include TX-Ultimate-Easy-ESPHome_core_hw_leds_light_base.yaml segments: - id: light_full from: 6 @@ -286,8 +222,7 @@ light: - id: light_07 name: Light - LED 07 disabled_by_default: true - platform: partition - default_transition_length: ${default_transition_length} + <<: !include TX-Ultimate-Easy-ESPHome_core_hw_leds_light_base.yaml segments: - id: light_full from: 7 @@ -295,8 +230,7 @@ light: - id: light_08 name: Light - LED 08 disabled_by_default: true - platform: partition - default_transition_length: ${default_transition_length} + <<: !include TX-Ultimate-Easy-ESPHome_core_hw_leds_light_base.yaml segments: - id: light_full from: 8 @@ -304,8 +238,7 @@ light: - id: light_09 name: Light - LED 09 disabled_by_default: true - platform: partition - default_transition_length: ${default_transition_length} + <<: !include TX-Ultimate-Easy-ESPHome_core_hw_leds_light_base.yaml segments: - id: light_full from: 9 @@ -313,8 +246,7 @@ light: - id: light_10 name: Light - LED 10 disabled_by_default: true - platform: partition - default_transition_length: ${default_transition_length} + <<: !include TX-Ultimate-Easy-ESPHome_core_hw_leds_light_base.yaml segments: - id: light_full from: 10 @@ -322,8 +254,7 @@ light: - id: light_11 name: Light - LED 11 disabled_by_default: true - platform: partition - default_transition_length: ${default_transition_length} + <<: !include TX-Ultimate-Easy-ESPHome_core_hw_leds_light_base.yaml segments: - id: light_full from: 11 @@ -331,8 +262,7 @@ light: - id: light_12 name: Light - LED 12 disabled_by_default: true - platform: partition - default_transition_length: ${default_transition_length} + <<: !include TX-Ultimate-Easy-ESPHome_core_hw_leds_light_base.yaml segments: - id: light_full from: 12 @@ -340,8 +270,7 @@ light: - id: light_13 name: Light - LED 13 disabled_by_default: true - platform: partition - default_transition_length: ${default_transition_length} + <<: !include TX-Ultimate-Easy-ESPHome_core_hw_leds_light_base.yaml segments: - id: light_full from: 13 @@ -349,8 +278,7 @@ light: - id: light_14 name: Light - LED 14 disabled_by_default: true - platform: partition - default_transition_length: ${default_transition_length} + <<: !include TX-Ultimate-Easy-ESPHome_core_hw_leds_light_base.yaml segments: - id: light_full from: 14 @@ -358,8 +286,7 @@ light: - id: light_15 name: Light - LED 15 disabled_by_default: true - platform: partition - default_transition_length: ${default_transition_length} + <<: !include TX-Ultimate-Easy-ESPHome_core_hw_leds_light_base.yaml segments: - id: light_full from: 15 @@ -367,8 +294,7 @@ light: - id: light_16 name: Light - LED 16 disabled_by_default: true - platform: partition - default_transition_length: ${default_transition_length} + <<: !include TX-Ultimate-Easy-ESPHome_core_hw_leds_light_base.yaml segments: - id: light_full from: 16 @@ -376,8 +302,7 @@ light: - id: light_17 name: Light - LED 17 disabled_by_default: true - platform: partition - default_transition_length: ${default_transition_length} + <<: !include TX-Ultimate-Easy-ESPHome_core_hw_leds_light_base.yaml segments: - id: light_full from: 17 @@ -385,8 +310,7 @@ light: - id: light_18 name: Light - LED 18 disabled_by_default: true - platform: partition - default_transition_length: ${default_transition_length} + <<: !include TX-Ultimate-Easy-ESPHome_core_hw_leds_light_base.yaml segments: - id: light_full from: 18 @@ -394,8 +318,7 @@ light: - id: light_19 name: Light - LED 19 disabled_by_default: true - platform: partition - default_transition_length: ${default_transition_length} + <<: !include TX-Ultimate-Easy-ESPHome_core_hw_leds_light_base.yaml segments: - id: light_full from: 19 @@ -403,8 +326,7 @@ light: - id: light_20 name: Light - LED 20 disabled_by_default: true - platform: partition - default_transition_length: ${default_transition_length} + <<: !include TX-Ultimate-Easy-ESPHome_core_hw_leds_light_base.yaml segments: - id: light_full from: 20 @@ -412,8 +334,7 @@ light: - id: light_21 name: Light - LED 21 disabled_by_default: true - platform: partition - default_transition_length: ${default_transition_length} + <<: !include TX-Ultimate-Easy-ESPHome_core_hw_leds_light_base.yaml segments: - id: light_full from: 21 @@ -421,8 +342,7 @@ light: - id: light_22 name: Light - LED 22 disabled_by_default: true - platform: partition - default_transition_length: ${default_transition_length} + <<: !include TX-Ultimate-Easy-ESPHome_core_hw_leds_light_base.yaml segments: - id: light_full from: 22 @@ -430,8 +350,7 @@ light: - id: light_23 name: Light - LED 23 disabled_by_default: true - platform: partition - default_transition_length: ${default_transition_length} + <<: !include TX-Ultimate-Easy-ESPHome_core_hw_leds_light_base.yaml segments: - id: light_full from: 23 @@ -439,8 +358,7 @@ light: - id: light_24 name: Light - LED 24 disabled_by_default: true - platform: partition - default_transition_length: ${default_transition_length} + <<: !include TX-Ultimate-Easy-ESPHome_core_hw_leds_light_base.yaml segments: - id: light_full from: 24 @@ -448,8 +366,7 @@ light: - id: light_25 name: Light - LED 25 disabled_by_default: true - platform: partition - default_transition_length: ${default_transition_length} + <<: !include TX-Ultimate-Easy-ESPHome_core_hw_leds_light_base.yaml segments: - id: light_full from: 25 @@ -457,8 +374,7 @@ light: - id: light_26 name: Light - LED 26 disabled_by_default: true - platform: partition - default_transition_length: ${default_transition_length} + <<: !include TX-Ultimate-Easy-ESPHome_core_hw_leds_light_base.yaml segments: - id: light_full from: 26 @@ -466,48 +382,39 @@ light: - id: light_27 name: Light - LED 27 disabled_by_default: true - platform: partition - default_transition_length: ${default_transition_length} + <<: !include TX-Ultimate-Easy-ESPHome_core_hw_leds_light_base.yaml segments: - id: light_full from: 27 to: 27 - id: light_28 name: Light - LED 28 - internal: true - disabled_by_default: true - platform: partition - default_transition_length: ${default_transition_length} + <<: !include TX-Ultimate-Easy-ESPHome_core_hw_leds_light_internal.yaml + <<: !include TX-Ultimate-Easy-ESPHome_core_hw_leds_light_base.yaml segments: - id: light_full from: 28 to: 28 - id: light_29 name: Light - LED 29 - internal: true - disabled_by_default: true - platform: partition - default_transition_length: ${default_transition_length} + <<: !include TX-Ultimate-Easy-ESPHome_core_hw_leds_light_internal.yaml + <<: !include TX-Ultimate-Easy-ESPHome_core_hw_leds_light_base.yaml segments: - id: light_full from: 29 to: 29 - id: light_30 name: Light - LED 30 - internal: true - disabled_by_default: true - platform: partition - default_transition_length: ${default_transition_length} + <<: !include TX-Ultimate-Easy-ESPHome_core_hw_leds_light_internal.yaml + <<: !include TX-Ultimate-Easy-ESPHome_core_hw_leds_light_base.yaml segments: - id: light_full from: 30 to: 30 - id: light_31 name: Light - LED 31 - internal: true - disabled_by_default: true - platform: partition - default_transition_length: ${default_transition_length} + <<: !include TX-Ultimate-Easy-ESPHome_core_hw_leds_light_internal.yaml + <<: !include TX-Ultimate-Easy-ESPHome_core_hw_leds_light_base.yaml segments: - id: light_full from: 31 @@ -516,8 +423,7 @@ light: - id: light_eu_rl_1_1_bottom name: Light - Relay 1 of 1 (bottom) internal: true - platform: partition - default_transition_length: ${default_transition_length} + <<: !include TX-Ultimate-Easy-ESPHome_core_hw_leds_light_base.yaml segments: - id: light_full from: 9 @@ -525,8 +431,7 @@ light: - id: light_eu_rl_1_1_top name: Light - Relay 1 of 1 (top) internal: true - platform: partition - default_transition_length: ${default_transition_length} + <<: !include TX-Ultimate-Easy-ESPHome_core_hw_leds_light_base.yaml segments: - id: light_full from: 23 @@ -534,8 +439,7 @@ light: - id: light_eu_rl_1_2_bottom name: Light - Relay 1 of 2 (bottom) internal: true - platform: partition - default_transition_length: ${default_transition_length} + <<: !include TX-Ultimate-Easy-ESPHome_core_hw_leds_light_base.yaml segments: - id: light_full from: 11 @@ -543,8 +447,7 @@ light: - id: light_eu_rl_1_2_top name: Light - Relay 1 of 2 (top) internal: true - platform: partition - default_transition_length: ${default_transition_length} + <<: !include TX-Ultimate-Easy-ESPHome_core_hw_leds_light_base.yaml segments: - id: light_full from: 21 @@ -552,8 +455,7 @@ light: - id: light_eu_rl_2_2_bottom name: Light - Relay 2 of 2 (bottom) internal: true - platform: partition - default_transition_length: ${default_transition_length} + <<: !include TX-Ultimate-Easy-ESPHome_core_hw_leds_light_base.yaml segments: - id: light_full from: 7 @@ -561,8 +463,7 @@ light: - id: light_eu_rl_2_2_top name: Light - Relay 2 of 2 (top) internal: true - platform: partition - default_transition_length: ${default_transition_length} + <<: !include TX-Ultimate-Easy-ESPHome_core_hw_leds_light_base.yaml segments: - id: light_full from: 25 @@ -570,8 +471,7 @@ light: - id: light_eu_rl_1_3_bottom name: Light - Relay 1 of 3 (bottom) internal: true - platform: partition - default_transition_length: ${default_transition_length} + <<: !include TX-Ultimate-Easy-ESPHome_core_hw_leds_light_base.yaml segments: - id: light_full from: 12 @@ -579,8 +479,7 @@ light: - id: light_eu_rl_1_3_top name: Light - Relay 1 of 3 (top) internal: true - platform: partition - default_transition_length: ${default_transition_length} + <<: !include TX-Ultimate-Easy-ESPHome_core_hw_leds_light_base.yaml segments: - id: light_full from: 20 @@ -588,8 +487,7 @@ light: - id: light_eu_rl_2_3_bottom name: Light - Relay 2 of 3 (bottom) internal: true - platform: partition - default_transition_length: ${default_transition_length} + <<: !include TX-Ultimate-Easy-ESPHome_core_hw_leds_light_base.yaml segments: - id: light_full from: 9 @@ -597,8 +495,7 @@ light: - id: light_eu_rl_2_3_top name: Light - Relay 2 of 3 (top) internal: true - platform: partition - default_transition_length: ${default_transition_length} + <<: !include TX-Ultimate-Easy-ESPHome_core_hw_leds_light_base.yaml segments: - id: light_full from: 23 @@ -606,8 +503,7 @@ light: - id: light_eu_rl_3_3_bottom name: Light - Relay 3 of 3 (bottom) internal: true - platform: partition - default_transition_length: ${default_transition_length} + <<: !include TX-Ultimate-Easy-ESPHome_core_hw_leds_light_base.yaml segments: - id: light_full from: 6 @@ -615,8 +511,7 @@ light: - id: light_eu_rl_3_3_top name: Light - Relay 3 of 3 (top) internal: true - platform: partition - default_transition_length: ${default_transition_length} + <<: !include TX-Ultimate-Easy-ESPHome_core_hw_leds_light_base.yaml segments: - id: light_full from: 26 @@ -624,8 +519,7 @@ light: - id: light_eu_rl_1_4_bottom name: Light - Relay 1 of 4 (bottom) internal: true - platform: partition - default_transition_length: ${default_transition_length} + <<: !include TX-Ultimate-Easy-ESPHome_core_hw_leds_light_base.yaml segments: - id: light_full from: 12 @@ -633,8 +527,7 @@ light: - id: light_eu_rl_1_4_top name: Light - Relay 1 of 4 (top) internal: true - platform: partition - default_transition_length: ${default_transition_length} + <<: !include TX-Ultimate-Easy-ESPHome_core_hw_leds_light_base.yaml segments: - id: light_full from: 20 @@ -642,8 +535,7 @@ light: - id: light_eu_rl_2_4_bottom name: Light - Relay 2 of 4 (bottom) internal: true - platform: partition - default_transition_length: ${default_transition_length} + <<: !include TX-Ultimate-Easy-ESPHome_core_hw_leds_light_base.yaml segments: - id: light_full from: 10 @@ -651,8 +543,7 @@ light: - id: light_eu_rl_2_4_top name: Light - Relay 2 of 4 (top) internal: true - platform: partition - default_transition_length: ${default_transition_length} + <<: !include TX-Ultimate-Easy-ESPHome_core_hw_leds_light_base.yaml segments: - id: light_full from: 22 @@ -660,8 +551,7 @@ light: - id: light_eu_rl_3_4_bottom name: Light - Relay 3 of 4 (bottom) internal: true - platform: partition - default_transition_length: ${default_transition_length} + <<: !include TX-Ultimate-Easy-ESPHome_core_hw_leds_light_base.yaml segments: - id: light_full from: 8 @@ -669,8 +559,7 @@ light: - id: light_eu_rl_3_4_top name: Light - Relay 3 of 4 (top) internal: true - platform: partition - default_transition_length: ${default_transition_length} + <<: !include TX-Ultimate-Easy-ESPHome_core_hw_leds_light_base.yaml segments: - id: light_full from: 24 @@ -678,8 +567,7 @@ light: - id: light_eu_rl_4_4_bottom name: Light - Relay 4 of 4 (bottom) internal: true - platform: partition - default_transition_length: ${default_transition_length} + <<: !include TX-Ultimate-Easy-ESPHome_core_hw_leds_light_base.yaml segments: - id: light_full from: 6 @@ -687,8 +575,7 @@ light: - id: light_eu_rl_4_4_top name: Light - Relay 4 of 4 (top) internal: true - platform: partition - default_transition_length: ${default_transition_length} + <<: !include TX-Ultimate-Easy-ESPHome_core_hw_leds_light_base.yaml segments: - id: light_full from: 26 @@ -696,8 +583,7 @@ light: - id: light_us_rl_1_1_left name: Light - Relay 1 of 1 (left) internal: true - platform: partition - default_transition_length: ${default_transition_length} + <<: !include TX-Ultimate-Easy-ESPHome_core_hw_leds_light_base.yaml segments: - id: light_full from: 15 @@ -705,8 +591,7 @@ light: - id: light_us_rl_1_1_right name: Light - Relay 1 of 1 (right) internal: true - platform: partition - default_transition_length: ${default_transition_length} + <<: !include TX-Ultimate-Easy-ESPHome_core_hw_leds_light_base.yaml segments: - id: light_full from: 31 @@ -717,8 +602,7 @@ light: - id: light_us_rl_1_2_left name: Light - Relay 1 of 2 (left) internal: true - platform: partition - default_transition_length: ${default_transition_length} + <<: !include TX-Ultimate-Easy-ESPHome_core_hw_leds_light_base.yaml segments: - id: light_full from: 20 @@ -726,8 +610,7 @@ light: - id: light_us_rl_1_2_right name: Light - Relay 1 of 2 (right) internal: true - platform: partition - default_transition_length: ${default_transition_length} + <<: !include TX-Ultimate-Easy-ESPHome_core_hw_leds_light_base.yaml segments: - id: light_full from: 31 @@ -738,8 +621,7 @@ light: - id: light_us_rl_2_2_left name: Light - Relay 2 of 2 (left) internal: true - platform: partition - default_transition_length: ${default_transition_length} + <<: !include TX-Ultimate-Easy-ESPHome_core_hw_leds_light_base.yaml segments: - id: light_full from: 15 @@ -747,8 +629,7 @@ light: - id: light_us_rl_2_2_right name: Light - Relay 2 of 2 (right) internal: true - platform: partition - default_transition_length: ${default_transition_length} + <<: !include TX-Ultimate-Easy-ESPHome_core_hw_leds_light_base.yaml segments: - id: light_full from: 4 @@ -756,8 +637,7 @@ light: - id: light_us_rl_1_3_left name: Light - Relay 1 of 3 (left) internal: true - platform: partition - default_transition_length: ${default_transition_length} + <<: !include TX-Ultimate-Easy-ESPHome_core_hw_leds_light_base.yaml segments: - id: light_full from: 22 @@ -765,8 +645,7 @@ light: - id: light_us_rl_1_3_right name: Light - Relay 1 of 3 (right) internal: true - platform: partition - default_transition_length: ${default_transition_length} + <<: !include TX-Ultimate-Easy-ESPHome_core_hw_leds_light_base.yaml segments: - id: light_full from: 0 @@ -774,8 +653,7 @@ light: - id: light_us_rl_2_3_left name: Light - Relay 2 of 3 (left) internal: true - platform: partition - default_transition_length: ${default_transition_length} + <<: !include TX-Ultimate-Easy-ESPHome_core_hw_leds_light_base.yaml segments: - id: light_full from: 19 @@ -783,8 +661,7 @@ light: - id: light_us_rl_2_3_right name: Light - Relay 2 of 3 (right) internal: true - platform: partition - default_transition_length: ${default_transition_length} + <<: !include TX-Ultimate-Easy-ESPHome_core_hw_leds_light_base.yaml segments: - id: light_full from: 3 @@ -792,8 +669,7 @@ light: - id: light_us_rl_3_3_left name: Light - Relay 3 of 3 (left) internal: true - platform: partition - default_transition_length: ${default_transition_length} + <<: !include TX-Ultimate-Easy-ESPHome_core_hw_leds_light_base.yaml segments: - id: light_full from: 17 @@ -801,8 +677,7 @@ light: - id: light_us_rl_3_3_right name: Light - Relay 3 of 3 (right) internal: true - platform: partition - default_transition_length: ${default_transition_length} + <<: !include TX-Ultimate-Easy-ESPHome_core_hw_leds_light_base.yaml segments: - id: light_full from: 6 @@ -810,8 +685,7 @@ light: - id: light_us_rl_1_4_left name: Light - Relay 1 of 4 (left) internal: true - platform: partition - default_transition_length: ${default_transition_length} + <<: !include TX-Ultimate-Easy-ESPHome_core_hw_leds_light_base.yaml segments: - id: light_full from: 12 @@ -819,8 +693,7 @@ light: - id: light_us_rl_1_4_right name: Light - Relay 1 of 4 (right) internal: true - platform: partition - default_transition_length: ${default_transition_length} + <<: !include TX-Ultimate-Easy-ESPHome_core_hw_leds_light_base.yaml segments: - id: light_full from: 31 @@ -828,8 +701,7 @@ light: - id: light_us_rl_2_4_left name: Light - Relay 2 of 4 (left) internal: true - platform: partition - default_transition_length: ${default_transition_length} + <<: !include TX-Ultimate-Easy-ESPHome_core_hw_leds_light_base.yaml segments: - id: light_full from: 24 @@ -837,8 +709,7 @@ light: - id: light_us_rl_2_4_right name: Light - Relay 2 of 4 (right) internal: true - platform: partition - default_transition_length: ${default_transition_length} + <<: !include TX-Ultimate-Easy-ESPHome_core_hw_leds_light_base.yaml segments: - id: light_full from: 2 @@ -846,8 +717,7 @@ light: - id: light_us_rl_3_4_left name: Light - Relay 3 of 4 (left) internal: true - platform: partition - default_transition_length: ${default_transition_length} + <<: !include TX-Ultimate-Easy-ESPHome_core_hw_leds_light_base.yaml segments: - id: light_full from: 21 @@ -855,8 +725,7 @@ light: - id: light_us_rl_3_4_right name: Light - Relay 3 of 4 (right) internal: true - platform: partition - default_transition_length: ${default_transition_length} + <<: !include TX-Ultimate-Easy-ESPHome_core_hw_leds_light_base.yaml segments: - id: light_full from: 4 @@ -864,8 +733,7 @@ light: - id: light_us_rl_4_4_left name: Light - Relay 4 of 4 (left) internal: true - platform: partition - default_transition_length: ${default_transition_length} + <<: !include TX-Ultimate-Easy-ESPHome_core_hw_leds_light_base.yaml segments: - id: light_full from: 19 @@ -873,8 +741,7 @@ light: - id: light_us_rl_4_4_right name: Light - Relay 4 of 4 (right) internal: true - platform: partition - default_transition_length: ${default_transition_length} + <<: !include TX-Ultimate-Easy-ESPHome_core_hw_leds_light_base.yaml segments: - id: light_full from: 7 @@ -1008,5 +875,4 @@ select: entity_category: config disabled_by_default: false icon: mdi:dots-square - ... diff --git a/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_leds_light_base.yaml b/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_leds_light_base.yaml new file mode 100644 index 0000000..e4191a8 --- /dev/null +++ b/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_leds_light_base.yaml @@ -0,0 +1,2 @@ +platform: partition +default_transition_length: ${default_transition_length} \ No newline at end of file diff --git a/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_leds_light_effects.yaml b/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_leds_light_effects.yaml new file mode 100644 index 0000000..e0c1a83 --- /dev/null +++ b/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_leds_light_effects.yaml @@ -0,0 +1,41 @@ +effects: &light_effects_full + - addressable_rainbow: + - addressable_rainbow: + name: "Rainbow - Fast" + speed: 50 + - pulse: + - pulse: + name: "Pulse - Fast" + transition_length: 0.5s + update_interval: 0.5s + - pulse: + name: "Pulse - Slow" + update_interval: 2s + - addressable_scan: + - addressable_scan: + name: Scan Effect With Custom Values + move_interval: 100ms + scan_width: 3 + - addressable_twinkle: + - addressable_twinkle: + name: Twinkle Effect With Custom Values + twinkle_probability: 5% + progress_interval: 4ms + - addressable_random_twinkle: + - addressable_random_twinkle: + name: Random Twinkle Effect With Custom Values + twinkle_probability: 20% + progress_interval: 32ms + - addressable_fireworks: + - addressable_fireworks: + name: Fireworks Effect With Custom Values + update_interval: 32ms + spark_probability: 10% + use_random_color: false + fade_out_rate: 120 + - addressable_flicker: + - addressable_flicker: + name: Flicker Effect With Custom Values + update_interval: 16ms + intensity: 5% + - random: \ No newline at end of file diff --git a/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_leds_light_internal.yaml b/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_leds_light_internal.yaml new file mode 100644 index 0000000..7849093 --- /dev/null +++ b/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_leds_light_internal.yaml @@ -0,0 +1,2 @@ +internal: true +disabled_by_default: true \ No newline at end of file diff --git a/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_touch.yaml b/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_touch.yaml index e9de90b..ec73074 100644 --- a/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_touch.yaml +++ b/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_touch.yaml @@ -183,7 +183,7 @@ tx_ultimate_easy: on_press: - lambda: ESP_LOGI("tx_ultimate_easy", "Pressed"); - script.execute: - id: touch_on_multi_touch_press + id: touch_on_press touch_x: !lambda return static_cast(touch.x); on_release: From 01293fd62dd1eb1eda06420ac283cd2b986c40d5 Mon Sep 17 00:00:00 2001 From: Edward Firmo <94725493+edwardtfn@users.noreply.github.com> Date: Thu, 19 Dec 2024 20:13:17 +0100 Subject: [PATCH 04/36] Review effects --- ...TX-Ultimate-Easy-ESPHome_core_hw_leds.yaml | 1 + ...sy-ESPHome_core_hw_leds_light_effects.yaml | 29 +++++++++---------- 2 files changed, 14 insertions(+), 16 deletions(-) diff --git a/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_leds.yaml b/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_leds.yaml index 9f101d2..98e2b32 100644 --- a/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_leds.yaml +++ b/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_leds.yaml @@ -74,6 +74,7 @@ light: from: 0 to: 31 + # Those lights are available based on the model selections - id: light_eu_bottom name: Light - Bottom <<: !include TX-Ultimate-Easy-ESPHome_core_hw_leds_light_internal.yaml diff --git a/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_leds_light_effects.yaml b/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_leds_light_effects.yaml index e0c1a83..48fcaeb 100644 --- a/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_leds_light_effects.yaml +++ b/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_leds_light_effects.yaml @@ -1,41 +1,38 @@ -effects: &light_effects_full +effects: - addressable_rainbow: + name: "Rainbow" - addressable_rainbow: name: "Rainbow - Fast" speed: 50 - pulse: - - pulse: - name: "Pulse - Fast" - transition_length: 0.5s - update_interval: 0.5s + name: "Pulse" + transition_length: 1s + update_interval: 1s - pulse: name: "Pulse - Slow" + transition_length: 2s update_interval: 2s - addressable_scan: - - addressable_scan: - name: Scan Effect With Custom Values + name: "Scan" move_interval: 100ms scan_width: 3 - addressable_twinkle: - - addressable_twinkle: - name: Twinkle Effect With Custom Values + name: "Twinkle" twinkle_probability: 5% progress_interval: 4ms - addressable_random_twinkle: - - addressable_random_twinkle: - name: Random Twinkle Effect With Custom Values + name: "Random Twinkle" twinkle_probability: 20% progress_interval: 32ms - addressable_fireworks: - - addressable_fireworks: - name: Fireworks Effect With Custom Values + name: "Fireworks" update_interval: 32ms spark_probability: 10% use_random_color: false fade_out_rate: 120 - addressable_flicker: - - addressable_flicker: - name: Flicker Effect With Custom Values + name: "Flicker" update_interval: 16ms intensity: 5% - - random: \ No newline at end of file + - random: + name: "Random" \ No newline at end of file From 51bf0dceab6a2a212dfff86873f90b3435d8123c Mon Sep 17 00:00:00 2001 From: Edward Firmo <94725493+edwardtfn@users.noreply.github.com> Date: Thu, 19 Dec 2024 20:20:05 +0100 Subject: [PATCH 05/36] Reorg led select --- ...TX-Ultimate-Easy-ESPHome_core_hw_leds.yaml | 104 +++--------------- 1 file changed, 18 insertions(+), 86 deletions(-) diff --git a/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_leds.yaml b/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_leds.yaml index 98e2b32..951ae5f 100644 --- a/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_leds.yaml +++ b/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_leds.yaml @@ -749,7 +749,9 @@ light: to: 7 select: - - id: sl_relay_1_light_mode_eu + # EU relay light mode template + - &relay_light_mode_eu + id: sl_relay_1_light_mode_eu name: Relay 1 light mode platform: template options: @@ -765,55 +767,21 @@ select: disabled_by_default: false icon: mdi:dots-square - - id: sl_relay_2_light_mode_eu + - <<: *relay_light_mode_eu + id: sl_relay_2_light_mode_eu name: Relay 2 light mode - platform: template - options: - - "Disabled" - - "Bottom" - - "Top" - - "Both" - initial_option: "Bottom" - optimistic: true - restore_value: true - internal: true - entity_category: config - disabled_by_default: false - icon: mdi:dots-square - - id: sl_relay_3_light_mode_eu + - <<: *relay_light_mode_eu + id: sl_relay_3_light_mode_eu name: Relay 3 light mode - platform: template - options: - - "Disabled" - - "Bottom" - - "Top" - - "Both" - initial_option: "Bottom" - optimistic: true - restore_value: true - internal: true - entity_category: config - disabled_by_default: false - icon: mdi:dots-square - - id: sl_relay_4_light_mode_eu + - <<: *relay_light_mode_eu + id: sl_relay_4_light_mode_eu name: Relay 4 light mode - platform: template - options: - - "Disabled" - - "Bottom" - - "Top" - - "Both" - initial_option: "Bottom" - optimistic: true - restore_value: true - internal: true - entity_category: config - disabled_by_default: false - icon: mdi:dots-square - - id: sl_relay_1_light_mode_us + # US relay light mode template + - &relay_light_mode_us + id: sl_relay_1_light_mode_us name: Relay 1 light mode platform: template options: @@ -829,51 +797,15 @@ select: disabled_by_default: false icon: mdi:dots-square - - id: sl_relay_2_light_mode_us + - <<: *relay_light_mode_us + id: sl_relay_2_light_mode_us name: Relay 2 light mode - platform: template - options: - - "Disabled" - - "Left" - - "Right" - - "Both" - initial_option: "Right" - optimistic: true - restore_value: true - internal: true - entity_category: config - disabled_by_default: false - icon: mdi:dots-square - - id: sl_relay_3_light_mode_us + - <<: *relay_light_mode_us + id: sl_relay_3_light_mode_us name: Relay 3 light mode - platform: template - options: - - "Disabled" - - "Left" - - "Right" - - "Both" - initial_option: "Right" - optimistic: true - restore_value: true - internal: true - entity_category: config - disabled_by_default: false - icon: mdi:dots-square - - id: sl_relay_4_light_mode_us + - <<: *relay_light_mode_us + id: sl_relay_4_light_mode_us name: Relay 4 light mode - platform: template - options: - - "Disabled" - - "Left" - - "Right" - - "Both" - initial_option: "Right" - optimistic: true - restore_value: true - internal: true - entity_category: config - disabled_by_default: false - icon: mdi:dots-square ... From 13722eccd07c07e2cf9caeb84dced45027cb589f Mon Sep 17 00:00:00 2001 From: Edward Firmo <94725493+edwardtfn@users.noreply.github.com> Date: Thu, 19 Dec 2024 20:30:55 +0100 Subject: [PATCH 06/36] Reorg relays --- ...TX-Ultimate-Easy-ESPHome_core_hw_leds.yaml | 24 +++++++------- ...-Ultimate-Easy-ESPHome_core_hw_relays.yaml | 33 +++---------------- 2 files changed, 17 insertions(+), 40 deletions(-) diff --git a/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_leds.yaml b/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_leds.yaml index 951ae5f..555b5ca 100644 --- a/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_leds.yaml +++ b/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_leds.yaml @@ -767,17 +767,17 @@ select: disabled_by_default: false icon: mdi:dots-square - - <<: *relay_light_mode_eu - id: sl_relay_2_light_mode_eu + - id: sl_relay_2_light_mode_eu name: Relay 2 light mode + <<: *relay_light_mode_eu - - <<: *relay_light_mode_eu - id: sl_relay_3_light_mode_eu + - id: sl_relay_3_light_mode_eu name: Relay 3 light mode + <<: *relay_light_mode_eu - - <<: *relay_light_mode_eu - id: sl_relay_4_light_mode_eu + - id: sl_relay_4_light_mode_eu name: Relay 4 light mode + <<: *relay_light_mode_eu # US relay light mode template - &relay_light_mode_us @@ -797,15 +797,15 @@ select: disabled_by_default: false icon: mdi:dots-square - - <<: *relay_light_mode_us - id: sl_relay_2_light_mode_us + - id: sl_relay_2_light_mode_us name: Relay 2 light mode + <<: *relay_light_mode_us - - <<: *relay_light_mode_us - id: sl_relay_3_light_mode_us + - id: sl_relay_3_light_mode_us name: Relay 3 light mode + <<: *relay_light_mode_us - - <<: *relay_light_mode_us - id: sl_relay_4_light_mode_us + - id: sl_relay_4_light_mode_us name: Relay 4 light mode + <<: *relay_light_mode_us ... diff --git a/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_relays.yaml b/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_relays.yaml index 04008e9..eeaf855 100644 --- a/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_relays.yaml +++ b/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_relays.yaml @@ -172,7 +172,8 @@ select: icon: mdi:dip-switch switch: - - id: sw_relay_1 + - &relay_switch_base + id: sw_relay_1 name: Relay 1 platform: output output: output_relay_1 @@ -187,40 +188,16 @@ switch: - id: sw_relay_2 name: Relay 2 - platform: output output: output_relay_2 - restore_mode: RESTORE_DEFAULT_OFF - internal: true - on_turn_on: - then: - - script.execute: show_relay_status - on_turn_off: - then: - - script.execute: show_relay_status + <<: *relay_switch_base - id: sw_relay_3 name: Relay 3 - platform: output output: output_relay_3 - restore_mode: RESTORE_DEFAULT_OFF - internal: true - on_turn_on: - then: - - script.execute: show_relay_status - on_turn_off: - then: - - script.execute: show_relay_status + <<: *relay_switch_base - id: sw_relay_4 name: Relay 4 - platform: output output: output_relay_4 - restore_mode: RESTORE_DEFAULT_OFF - internal: true - on_turn_on: - then: - - script.execute: show_relay_status - on_turn_off: - then: - - script.execute: show_relay_status + <<: *relay_switch_base ... From 2f92e874b3171eb9913cc699439bf5fe43eee3d4 Mon Sep 17 00:00:00 2001 From: Edward Firmo <94725493+edwardtfn@users.noreply.github.com> Date: Thu, 19 Dec 2024 20:45:31 +0100 Subject: [PATCH 07/36] Clean-up relay mode select --- ...Ultimate-Easy-ESPHome_core_hw_buttons.yaml | 1 - ...-Ultimate-Easy-ESPHome_core_hw_relays.yaml | 96 ++++++++----------- 2 files changed, 39 insertions(+), 58 deletions(-) diff --git a/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_buttons.yaml b/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_buttons.yaml index ffd32d8..2f5b1ef 100644 --- a/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_buttons.yaml +++ b/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_buttons.yaml @@ -244,5 +244,4 @@ select: entity_category: config disabled_by_default: false icon: mdi:dip-switch - ... diff --git a/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_relays.yaml b/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_relays.yaml index eeaf855..4f67524 100644 --- a/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_relays.yaml +++ b/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_relays.yaml @@ -82,40 +82,52 @@ script: mode: restart then: - lambda: |- - return; - show_relay_status->stop(); auto model_format = sl_tx_model_format->active_index(); - std::vector relay_modes; + if (!model_format.has_value()) return; // Early return if no model format - if (model_format.has_value() and model_format.value() == 0) { - relay_modes = {sl_relay_1_light_mode_eu, sl_relay_2_light_mode_eu, sl_relay_3_light_mode_eu, sl_relay_4_light_mode_eu}; + std::vector relay_modes; + const bool is_eu_model = model_format.value() == 0; + + // Select appropriate light mode selectors based on model + if (is_eu_model) { + relay_modes = {sl_relay_1_light_mode_eu, sl_relay_2_light_mode_eu, + sl_relay_3_light_mode_eu, sl_relay_4_light_mode_eu}; } else { - relay_modes = {sl_relay_1_light_mode_us, sl_relay_2_light_mode_us, sl_relay_3_light_mode_us, sl_relay_4_light_mode_us}; + relay_modes = {sl_relay_1_light_mode_us, sl_relay_2_light_mode_us, + sl_relay_3_light_mode_us, sl_relay_4_light_mode_us}; } - std::vector switches = {sw_relay_1, sw_relay_2, sw_relay_3, sw_relay_4}; - for (int i = 0; i < relay_modes.size(); ++i) { + // Get switch states + const std::vector switches = {sw_relay_1, sw_relay_2, sw_relay_3, sw_relay_4}; + + // Update lights based on relay states + for (size_t i = 0; i < relay_modes.size(); ++i) { auto light_index = relay_modes[i]->active_index(); - if (light_index.has_value()) { - uint8_t light_idx = light_index.value(); - bool switch_state = switches[i]->state; - if (light_idx == 1 || light_idx == 3) { - if (switch_state) - id(gb_lights_1)[i]->turn_on().perform(); - else - id(gb_lights_1)[i]->turn_off().perform(); - } - if (light_idx == 2 || light_idx == 3) { - if (switch_state) - id(gb_lights_2)[i]->turn_on().perform(); - else - id(gb_lights_2)[i]->turn_off().perform(); - } + if (!light_index.has_value()) continue; + + const uint8_t light_idx = light_index.value(); + const bool switch_state = switches[i]->state; + + // Update first light group (bottom/left) + if (light_idx == 1 || light_idx == 3) { + if (switch_state) + id(gb_lights_1)[i]->turn_on(); + else + id(gb_lights_1)[i]->turn_off(); + } + + // Update second light group (top/right) + if (light_idx == 2 || light_idx == 3) { + if (switch_state) + id(gb_lights_2)[i]->turn_on(); + else + id(gb_lights_2)[i]->turn_off(); } } select: - - id: sl_relay_1_mode + - &relay_mode_base + id: sl_relay_1_mode name: Relay 1 mode platform: template options: @@ -131,45 +143,15 @@ select: - id: sl_relay_2_mode name: Relay 2 mode - platform: template - options: - - "Relay" - - "Light" - - "Not in use" - optimistic: true - restore_value: true - internal: true - entity_category: config - disabled_by_default: false - icon: mdi:dip-switch + <<: *relay_mode_base - id: sl_relay_3_mode name: Relay 3 mode - platform: template - options: - - "Relay" - - "Light" - - "Not in use" - optimistic: true - restore_value: true - internal: true - entity_category: config - disabled_by_default: false - icon: mdi:dip-switch + <<: *relay_mode_base - id: sl_relay_4_mode name: Relay 4 mode - platform: template - options: - - "Relay" - - "Light" - - "Not in use" - optimistic: true - restore_value: true - internal: true - entity_category: config - disabled_by_default: false - icon: mdi:dip-switch + <<: *relay_mode_base switch: - &relay_switch_base From 818c6067e01b10b4e79027fbcb03313f0dcd375a Mon Sep 17 00:00:00 2001 From: Edward Firmo <94725493+edwardtfn@users.noreply.github.com> Date: Thu, 19 Dec 2024 20:46:19 +0100 Subject: [PATCH 08/36] Bump to v0.0.4 --- ESPHome/TX-Ultimate-Easy-ESPHome_core.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ESPHome/TX-Ultimate-Easy-ESPHome_core.yaml b/ESPHome/TX-Ultimate-Easy-ESPHome_core.yaml index 62a0a48..32c8d4e 100644 --- a/ESPHome/TX-Ultimate-Easy-ESPHome_core.yaml +++ b/ESPHome/TX-Ultimate-Easy-ESPHome_core.yaml @@ -19,7 +19,7 @@ substitutions: longitude: '0' zone_home: 'zone.home' - version: '0.0.3' + version: '0.0.4' packages: # yamllint disable rule:colons From 2e15149d3de9ec6a12527519f15c8410b3de4549 Mon Sep 17 00:00:00 2001 From: Edward Firmo <94725493+edwardtfn@users.noreply.github.com> Date: Thu, 19 Dec 2024 21:11:55 +0100 Subject: [PATCH 09/36] Clean-up buttons --- ...Ultimate-Easy-ESPHome_core_hw_buttons.yaml | 57 +++++++++++-------- ...-Ultimate-Easy-ESPHome_core_hw_relays.yaml | 8 +-- ...X-Ultimate-Easy-ESPHome_core_hw_touch.yaml | 8 +-- ...timate-Easy-ESPHome_core_hw_vibration.yaml | 6 +- 4 files changed, 44 insertions(+), 35 deletions(-) diff --git a/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_buttons.yaml b/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_buttons.yaml index 2f5b1ef..7b3e76e 100644 --- a/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_buttons.yaml +++ b/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_buttons.yaml @@ -133,11 +133,34 @@ script: - id: buttons_release mode: restart then: - - lambda: |- - if (bs_button_1->state) bs_button_1->publish_state(false); - if (bs_button_2->state) bs_button_2->publish_state(false); - if (bs_button_3->state) bs_button_3->publish_state(false); - if (bs_button_4->state) bs_button_4->publish_state(false); + - if: + condition: + binary_sensor.is_on: bs_button_1 + then: + - binary_sensor.template.publish: + id: bs_button_1 + state: OFF # yamllint disable-line rule:truthy + - if: + condition: + binary_sensor.is_on: bs_button_2 + then: + - binary_sensor.template.publish: + id: bs_button_2 + state: OFF # yamllint disable-line rule:truthy + - if: + condition: + binary_sensor.is_on: bs_button_3 + then: + - binary_sensor.template.publish: + id: bs_button_3 + state: OFF # yamllint disable-line rule:truthy + - if: + condition: + binary_sensor.is_on: bs_button_4 + then: + - binary_sensor.template.publish: + id: bs_button_4 + state: OFF # yamllint disable-line rule:truthy - id: !extend touch_on_multi_touch_release then: @@ -193,7 +216,8 @@ script: - script.execute: buttons_release select: - - id: sl_button_1_action + - &button_select_action_base + id: sl_button_1_action name: Button 1 action platform: template options: @@ -212,12 +236,7 @@ select: options: - "None" - "Relay 2 (toggle)" - optimistic: true - restore_value: true - internal: true - entity_category: config - disabled_by_default: false - icon: mdi:dip-switch + <<: *button_select_action_base - id: sl_button_3_action name: Button 3 action @@ -225,12 +244,7 @@ select: options: - "None" - "Relay 3 (toggle)" - optimistic: true - restore_value: true - internal: true - entity_category: config - disabled_by_default: false - icon: mdi:dip-switch + <<: *button_select_action_base - id: sl_button_4_action name: Button 4 action @@ -238,10 +252,5 @@ select: options: - "None" - "Relay 4 (toggle)" - optimistic: true - restore_value: true - internal: true - entity_category: config - disabled_by_default: false - icon: mdi:dip-switch + <<: *button_select_action_base ... diff --git a/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_relays.yaml b/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_relays.yaml index 4f67524..04cd406 100644 --- a/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_relays.yaml +++ b/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_relays.yaml @@ -126,7 +126,7 @@ script: } select: - - &relay_mode_base + - &relay_select_mode_base id: sl_relay_1_mode name: Relay 1 mode platform: template @@ -143,15 +143,15 @@ select: - id: sl_relay_2_mode name: Relay 2 mode - <<: *relay_mode_base + <<: *relay_select_mode_base - id: sl_relay_3_mode name: Relay 3 mode - <<: *relay_mode_base + <<: *relay_select_mode_base - id: sl_relay_4_mode name: Relay 4 mode - <<: *relay_mode_base + <<: *relay_select_mode_base switch: - &relay_switch_base diff --git a/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_touch.yaml b/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_touch.yaml index ec73074..dc5dcc4 100644 --- a/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_touch.yaml +++ b/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_touch.yaml @@ -123,7 +123,7 @@ script: then: - binary_sensor.template.publish: id: bs_swipe_left - state: ON + state: ON # yamllint disable-line rule:truthy - delay: !lambda return nr_touch_duration->state; - script.execute: touch_swipe_turn_off_binary_sensor @@ -139,7 +139,7 @@ script: then: - binary_sensor.template.publish: id: bs_swipe_right - state: ON + state: ON # yamllint disable-line rule:truthy - delay: !lambda return nr_touch_duration->state; - script.execute: touch_swipe_turn_off_binary_sensor @@ -152,14 +152,14 @@ script: then: - binary_sensor.template.publish: id: bs_swipe_left - state: OFF + state: OFF # yamllint disable-line rule:truthy - if: condition: binary_sensor.is_on: bs_swipe_right then: - binary_sensor.template.publish: id: bs_swipe_right - state: OFF + state: OFF # yamllint disable-line rule:truthy switch: - id: sw_touch_panel_power diff --git a/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_vibration.yaml b/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_vibration.yaml index 366d77f..2d1689c 100644 --- a/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_vibration.yaml +++ b/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_vibration.yaml @@ -49,7 +49,7 @@ script: - id: !extend touch_on_multi_touch_release then: - script.execute: touch_on_multi_touch_release_vibration - + - id: touch_on_multi_touch_release_vibration mode: restart then: @@ -60,7 +60,7 @@ script: - id: !extend touch_on_press then: - script.execute: touch_on_press_vibration - + - id: touch_on_press_vibration mode: restart then: @@ -71,7 +71,7 @@ script: - id: !extend touch_on_release then: - script.execute: touch_on_release_vibration - + - id: touch_on_release_vibration mode: restart then: From 7c04d152a0321529800c414b520d8df9d4ceac5b Mon Sep 17 00:00:00 2001 From: Edward Firmo <94725493+edwardtfn@users.noreply.github.com> Date: Thu, 19 Dec 2024 21:15:18 +0100 Subject: [PATCH 10/36] Lint --- ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_leds_light_base.yaml | 4 +++- .../TX-Ultimate-Easy-ESPHome_core_hw_leds_light_effects.yaml | 4 +++- .../TX-Ultimate-Easy-ESPHome_core_hw_leds_light_internal.yaml | 4 +++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_leds_light_base.yaml b/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_leds_light_base.yaml index e4191a8..e00298e 100644 --- a/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_leds_light_base.yaml +++ b/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_leds_light_base.yaml @@ -1,2 +1,4 @@ +# yamllint disable rule:document-start rule:document-end rule:new-line-at-end-of-file platform: partition -default_transition_length: ${default_transition_length} \ No newline at end of file +default_transition_length: ${default_transition_length} +# yamllint enable rule:document-start rule:document-end rule:new-line-at-end-of-file diff --git a/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_leds_light_effects.yaml b/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_leds_light_effects.yaml index 48fcaeb..85535aa 100644 --- a/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_leds_light_effects.yaml +++ b/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_leds_light_effects.yaml @@ -1,3 +1,4 @@ +# yamllint disable rule:document-start rule:document-end rule:new-line-at-end-of-file effects: - addressable_rainbow: name: "Rainbow" @@ -35,4 +36,5 @@ effects: update_interval: 16ms intensity: 5% - random: - name: "Random" \ No newline at end of file + name: "Random" +# yamllint enable rule:document-start rule:document-end rule:new-line-at-end-of-file \ No newline at end of file diff --git a/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_leds_light_internal.yaml b/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_leds_light_internal.yaml index 7849093..a4405b7 100644 --- a/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_leds_light_internal.yaml +++ b/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_leds_light_internal.yaml @@ -1,2 +1,4 @@ +# yamllint disable rule:document-start rule:document-end rule:new-line-at-end-of-file internal: true -disabled_by_default: true \ No newline at end of file +disabled_by_default: true +# yamllint enable rule:document-start rule:document-end rule:new-line-at-end-of-file \ No newline at end of file From a4eff7276a245aef2ddc35c33bb262e573819ffd Mon Sep 17 00:00:00 2001 From: Edward Firmo <94725493+edwardtfn@users.noreply.github.com> Date: Thu, 19 Dec 2024 21:17:46 +0100 Subject: [PATCH 11/36] Lint --- ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_leds_light_base.yaml | 4 ++-- .../TX-Ultimate-Easy-ESPHome_core_hw_leds_light_effects.yaml | 4 ++-- .../TX-Ultimate-Easy-ESPHome_core_hw_leds_light_internal.yaml | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_leds_light_base.yaml b/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_leds_light_base.yaml index e00298e..c733079 100644 --- a/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_leds_light_base.yaml +++ b/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_leds_light_base.yaml @@ -1,4 +1,4 @@ -# yamllint disable rule:document-start rule:document-end rule:new-line-at-end-of-file +# yamllint disable rule:document-start rule:document-end platform: partition default_transition_length: ${default_transition_length} -# yamllint enable rule:document-start rule:document-end rule:new-line-at-end-of-file +# yamllint enable rule:document-start rule:document-end diff --git a/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_leds_light_effects.yaml b/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_leds_light_effects.yaml index 85535aa..f2f912c 100644 --- a/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_leds_light_effects.yaml +++ b/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_leds_light_effects.yaml @@ -1,4 +1,4 @@ -# yamllint disable rule:document-start rule:document-end rule:new-line-at-end-of-file +# yamllint disable rule:document-start rule:document-end effects: - addressable_rainbow: name: "Rainbow" @@ -37,4 +37,4 @@ effects: intensity: 5% - random: name: "Random" -# yamllint enable rule:document-start rule:document-end rule:new-line-at-end-of-file \ No newline at end of file +# yamllint enable rule:document-start rule:document-end diff --git a/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_leds_light_internal.yaml b/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_leds_light_internal.yaml index a4405b7..814b6f1 100644 --- a/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_leds_light_internal.yaml +++ b/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_leds_light_internal.yaml @@ -1,4 +1,4 @@ -# yamllint disable rule:document-start rule:document-end rule:new-line-at-end-of-file +# yamllint disable rule:document-start rule:document-end internal: true disabled_by_default: true -# yamllint enable rule:document-start rule:document-end rule:new-line-at-end-of-file \ No newline at end of file +# yamllint enable rule:document-start rule:document-end From 3412e2389a03ea91d578eb6fe863519b26fabcc8 Mon Sep 17 00:00:00 2001 From: Edward Firmo <94725493+edwardtfn@users.noreply.github.com> Date: Thu, 19 Dec 2024 21:25:58 +0100 Subject: [PATCH 12/36] Test with Beta --- .github/workflows/validate_esphome.yml | 24 +++---------------- .github/workflows/validate_esphome_beta.yml | 20 +++++++++++++++- ...aml => esphome_idf53_bluetooth_proxy.yaml} | 4 ++-- ...-Easy-ESPHome_core_hw_leds_light_base.yaml | 4 ++-- ...sy-ESPHome_core_hw_leds_light_effects.yaml | 4 ++-- ...y-ESPHome_core_hw_leds_light_internal.yaml | 4 ++-- 6 files changed, 30 insertions(+), 30 deletions(-) rename .test/{esphome_idf5_bluetooth_proxy.yaml => esphome_idf53_bluetooth_proxy.yaml} (82%) diff --git a/.github/workflows/validate_esphome.yml b/.github/workflows/validate_esphome.yml index 8224773..017e239 100644 --- a/.github/workflows/validate_esphome.yml +++ b/.github/workflows/validate_esphome.yml @@ -3,24 +3,6 @@ name: Validate ESPHome # yamllint disable-line rule:truthy on: - push: - paths: - - "*.yaml" - - "prebuilt/*.yaml" - - ".test/*.yaml" - - "*.h" - - "*.c" - - "*.cpp" - - "*.py" - pull_request: - paths: - - "*.yaml" - - "prebuilt/*.yaml" - - ".test/*.yaml" - - "*.h" - - "*.c" - - "*.cpp" - - "*.py" workflow_dispatch: concurrency: @@ -69,8 +51,8 @@ jobs: with: yaml_file: ".test/esphome_idf_bluetooth_proxy.yaml" - build_bluetooth_proxy_5: - name: Bluetooth Proxy (IDF v5) + build_bluetooth_proxy_53: + name: Bluetooth Proxy (IDF v5.3) needs: build_basic runs-on: ubuntu-latest steps: @@ -78,5 +60,5 @@ jobs: - name: Build core uses: esphome/build-action@main with: - yaml_file: ".test/esphome_idf5_bluetooth_proxy.yaml" + yaml_file: ".test/esphome_idf53_bluetooth_proxy.yaml" ... diff --git a/.github/workflows/validate_esphome_beta.yml b/.github/workflows/validate_esphome_beta.yml index 621e710..c2bf5e7 100644 --- a/.github/workflows/validate_esphome_beta.yml +++ b/.github/workflows/validate_esphome_beta.yml @@ -3,6 +3,24 @@ name: Validate ESPHome (Beta) # yamllint disable-line rule:truthy on: + push: + paths: + - "*.yaml" + - "ESPHome/*.yaml" + - ".test/*.yaml" + - "*.h" + - "*.c" + - "*.cpp" + - "*.py" + pull_request: + paths: + - "*.yaml" + - "ESPHome/*.yaml" + - ".test/*.yaml" + - "*.h" + - "*.c" + - "*.cpp" + - "*.py" workflow_dispatch: concurrency: @@ -86,7 +104,7 @@ jobs: yaml_file: ".test/esphome_idf_bluetooth_proxy.yaml" - id: idf_v5 base: idf_v5 - yaml_file: ".test/esphome_idf5_bluetooth_proxy.yaml" + yaml_file: ".test/esphome_idf53_bluetooth_proxy.yaml" steps: - name: Checkout repository diff --git a/.test/esphome_idf5_bluetooth_proxy.yaml b/.test/esphome_idf53_bluetooth_proxy.yaml similarity index 82% rename from .test/esphome_idf5_bluetooth_proxy.yaml rename to .test/esphome_idf53_bluetooth_proxy.yaml index 1ca452f..1e8643f 100644 --- a/.test/esphome_idf5_bluetooth_proxy.yaml +++ b/.test/esphome_idf53_bluetooth_proxy.yaml @@ -6,6 +6,6 @@ packages: esp32: framework: type: esp-idf - version: 5.0.2 - platform_version: 6.3.2 + version: 5.3.1 + platform_version: 6.9.0 ... diff --git a/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_leds_light_base.yaml b/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_leds_light_base.yaml index c733079..9430a37 100644 --- a/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_leds_light_base.yaml +++ b/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_leds_light_base.yaml @@ -1,4 +1,4 @@ -# yamllint disable rule:document-start rule:document-end +--- platform: partition default_transition_length: ${default_transition_length} -# yamllint enable rule:document-start rule:document-end +... diff --git a/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_leds_light_effects.yaml b/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_leds_light_effects.yaml index f2f912c..dcdf7fb 100644 --- a/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_leds_light_effects.yaml +++ b/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_leds_light_effects.yaml @@ -1,4 +1,4 @@ -# yamllint disable rule:document-start rule:document-end +--- effects: - addressable_rainbow: name: "Rainbow" @@ -37,4 +37,4 @@ effects: intensity: 5% - random: name: "Random" -# yamllint enable rule:document-start rule:document-end +... diff --git a/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_leds_light_internal.yaml b/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_leds_light_internal.yaml index 814b6f1..42e596a 100644 --- a/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_leds_light_internal.yaml +++ b/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_leds_light_internal.yaml @@ -1,4 +1,4 @@ -# yamllint disable rule:document-start rule:document-end +--- internal: true disabled_by_default: true -# yamllint enable rule:document-start rule:document-end +... From fa2c212efe15d78e76584f7f1f2e91a568ef3bec Mon Sep 17 00:00:00 2001 From: Edward Firmo <94725493+edwardtfn@users.noreply.github.com> Date: Thu, 19 Dec 2024 21:32:39 +0100 Subject: [PATCH 13/36] Update validate_esphome_beta.yml --- .github/workflows/validate_esphome_beta.yml | 77 ++++++--------------- 1 file changed, 22 insertions(+), 55 deletions(-) diff --git a/.github/workflows/validate_esphome_beta.yml b/.github/workflows/validate_esphome_beta.yml index c2bf5e7..285b93c 100644 --- a/.github/workflows/validate_esphome_beta.yml +++ b/.github/workflows/validate_esphome_beta.yml @@ -28,32 +28,9 @@ concurrency: cancel-in-progress: true jobs: - setup_dependencies: - name: Setup & Cache Dependencies - runs-on: ubuntu-latest - outputs: - cache-hit-arduino: ${{ steps.cache-arduino.outputs.cache-hit }} - - steps: - - name: Checkout repository - uses: actions/checkout@main - - - name: Cache Arduino Dependencies - id: cache-arduino - uses: actions/cache@main - with: - path: | - ~/.esphome/cache - ~/.platformio/packages - ~/.platformio/platforms - key: ${{ runner.os }}-arduino-${{ hashFiles('**/esphome_ard_basic.yaml') }} - restore-keys: | - ${{ runner.os }}-arduino- - code_scan: name: Code scan (YAML) runs-on: "ubuntu-latest" - needs: setup_dependencies steps: - name: Checkout Code uses: actions/checkout@main @@ -71,48 +48,38 @@ jobs: build_basic: name: Basic - needs: [code_scan, setup_dependencies] + needs: + - code_scan runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - include: - - id: ard - yaml_file: ".test/esphome_ard_basic.yaml" - cache-hit: ${{ needs.setup_dependencies.outputs.cache-hit-arduino }} - steps: - - name: Checkout repository - uses: actions/checkout@main - - - name: Firmware - if: steps.matrix.outputs.cache-hit != 'true' + - uses: actions/checkout@main + - name: Build core uses: esphome/build-action@main with: - yaml_file: ${{ matrix.yaml_file }} + yaml_file: ".test/esphome_ard_basic.yaml" version: beta - build_bluetooth_proxy: - name: Bluetooth Proxy + build_bluetooth_proxy_4: + name: Bluetooth Proxy (IDF v4) needs: build_basic runs-on: ubuntu-latest - strategy: - matrix: - include: - - id: idf_v4 - base: idf_v4 - yaml_file: ".test/esphome_idf_bluetooth_proxy.yaml" - - id: idf_v5 - base: idf_v5 - yaml_file: ".test/esphome_idf53_bluetooth_proxy.yaml" - steps: - - name: Checkout repository - uses: actions/checkout@main - - - name: Build Bluetooth Proxy Firmware + - uses: actions/checkout@main + - name: Build core uses: esphome/build-action@main with: - yaml_file: ${{ matrix.yaml_file }} + yaml_file: ".test/esphome_idf_bluetooth_proxy.yaml" + version: beta + + build_bluetooth_proxy_53: + name: Bluetooth Proxy (IDF v5.3) + needs: build_basic + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@main + - name: Build core + uses: esphome/build-action@main + with: + yaml_file: ".test/esphome_idf53_bluetooth_proxy.yaml" version: beta ... From 6d11d50e25fc856afefc3bd5c1a7ac42ab853021 Mon Sep 17 00:00:00 2001 From: Edward Firmo <94725493+edwardtfn@users.noreply.github.com> Date: Thu, 19 Dec 2024 21:40:53 +0100 Subject: [PATCH 14/36] Fix yaml-file reference --- .github/workflows/validate_esphome.yml | 6 +++--- .github/workflows/validate_esphome_beta.yml | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/validate_esphome.yml b/.github/workflows/validate_esphome.yml index 017e239..b458f57 100644 --- a/.github/workflows/validate_esphome.yml +++ b/.github/workflows/validate_esphome.yml @@ -38,7 +38,7 @@ jobs: - name: Build core uses: esphome/build-action@main with: - yaml_file: ".test/esphome_ard_basic.yaml" + yaml-file: ".test/esphome_ard_basic.yaml" build_bluetooth_proxy_4: name: Bluetooth Proxy (IDF v4) @@ -49,7 +49,7 @@ jobs: - name: Build core uses: esphome/build-action@main with: - yaml_file: ".test/esphome_idf_bluetooth_proxy.yaml" + yaml-file: ".test/esphome_idf_bluetooth_proxy.yaml" build_bluetooth_proxy_53: name: Bluetooth Proxy (IDF v5.3) @@ -60,5 +60,5 @@ jobs: - name: Build core uses: esphome/build-action@main with: - yaml_file: ".test/esphome_idf53_bluetooth_proxy.yaml" + yaml-file: ".test/esphome_idf53_bluetooth_proxy.yaml" ... diff --git a/.github/workflows/validate_esphome_beta.yml b/.github/workflows/validate_esphome_beta.yml index 285b93c..9635d75 100644 --- a/.github/workflows/validate_esphome_beta.yml +++ b/.github/workflows/validate_esphome_beta.yml @@ -56,7 +56,7 @@ jobs: - name: Build core uses: esphome/build-action@main with: - yaml_file: ".test/esphome_ard_basic.yaml" + yaml-file: ".test/esphome_ard_basic.yaml" version: beta build_bluetooth_proxy_4: @@ -68,7 +68,7 @@ jobs: - name: Build core uses: esphome/build-action@main with: - yaml_file: ".test/esphome_idf_bluetooth_proxy.yaml" + yaml-file: ".test/esphome_idf_bluetooth_proxy.yaml" version: beta build_bluetooth_proxy_53: @@ -80,6 +80,6 @@ jobs: - name: Build core uses: esphome/build-action@main with: - yaml_file: ".test/esphome_idf53_bluetooth_proxy.yaml" + yaml-file: ".test/esphome_idf53_bluetooth_proxy.yaml" version: beta ... From 81bf402e35fc023077d680ed28d08e57789f8bc5 Mon Sep 17 00:00:00 2001 From: Edward Firmo <94725493+edwardtfn@users.noreply.github.com> Date: Thu, 19 Dec 2024 21:43:06 +0100 Subject: [PATCH 15/36] Fix IDF version label --- .github/workflows/validate_esphome.yml | 2 +- .github/workflows/validate_esphome_beta.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/validate_esphome.yml b/.github/workflows/validate_esphome.yml index b458f57..9aa4fb7 100644 --- a/.github/workflows/validate_esphome.yml +++ b/.github/workflows/validate_esphome.yml @@ -41,7 +41,7 @@ jobs: yaml-file: ".test/esphome_ard_basic.yaml" build_bluetooth_proxy_4: - name: Bluetooth Proxy (IDF v4) + name: Bluetooth Proxy (IDF) needs: build_basic runs-on: ubuntu-latest steps: diff --git a/.github/workflows/validate_esphome_beta.yml b/.github/workflows/validate_esphome_beta.yml index 9635d75..43d5f7e 100644 --- a/.github/workflows/validate_esphome_beta.yml +++ b/.github/workflows/validate_esphome_beta.yml @@ -60,7 +60,7 @@ jobs: version: beta build_bluetooth_proxy_4: - name: Bluetooth Proxy (IDF v4) + name: Bluetooth Proxy (IDF) needs: build_basic runs-on: ubuntu-latest steps: From e9890c937e302102a80870b1a5be17566d95510d Mon Sep 17 00:00:00 2001 From: Edward Firmo <94725493+edwardtfn@users.noreply.github.com> Date: Thu, 19 Dec 2024 23:39:32 +0100 Subject: [PATCH 16/36] CodeRabbitAI suggestions --- ESPHome/TX-Ultimate-Easy-ESPHome_core.yaml | 138 +++--------------- .../TX-Ultimate-Easy-ESPHome_core_api.yaml | 7 +- ...Ultimate-Easy-ESPHome_core_hw_buttons.yaml | 63 ++++---- ...TX-Ultimate-Easy-ESPHome_core_hw_leds.yaml | 73 ++++++++- ...-Ultimate-Easy-ESPHome_core_hw_relays.yaml | 49 +++++++ ...X-Ultimate-Easy-ESPHome_core_hw_touch.yaml | 25 +++- ...timate-Easy-ESPHome_core_hw_vibration.yaml | 22 ++- 7 files changed, 222 insertions(+), 155 deletions(-) diff --git a/ESPHome/TX-Ultimate-Easy-ESPHome_core.yaml b/ESPHome/TX-Ultimate-Easy-ESPHome_core.yaml index 32c8d4e..f407e5c 100644 --- a/ESPHome/TX-Ultimate-Easy-ESPHome_core.yaml +++ b/ESPHome/TX-Ultimate-Easy-ESPHome_core.yaml @@ -56,129 +56,15 @@ esphome: on_boot: - priority: 700 then: - - wait_until: - condition: - - lambda: return sl_tx_model_format->active_index().has_value(); - - lambda: return sl_tx_model_gang->active_index().has_value(); - - lambda: |- - const bool us_model = sl_tx_model_format->active_index().has_value() and - sl_tx_model_format->active_index().value() == 1; - const uint8_t num_gangs = (sl_tx_model_gang->active_index().has_value()) ? - (sl_tx_model_gang->active_index().value() + 1) : 0; - bs_button_1->publish_state(false); - bs_button_1->set_internal(num_gangs < 1); - sl_button_1_action->set_internal(num_gangs < 1); - bs_button_2->publish_state(false); - bs_button_2->set_internal(num_gangs < 2); - sl_button_2_action->set_internal(num_gangs < 2); - bs_button_3->publish_state(false); - bs_button_3->set_internal(num_gangs < 3); - sl_button_3_action->set_internal(num_gangs < 3); - bs_button_4->publish_state(false); - bs_button_4->set_internal(num_gangs < 4); - sl_button_4_action->set_internal(num_gangs < 4); - bs_multi_touch->publish_state(false); - bs_swipe_down->publish_state(false); - bs_swipe_down->set_internal(!us_model); - bs_swipe_left->publish_state(false); - bs_swipe_left->set_internal(us_model); - bs_swipe_right->publish_state(false); - bs_swipe_right->set_internal(us_model); - bs_swipe_up->publish_state(false); - bs_swipe_up->set_internal(!us_model); - light_28->set_internal(!us_model); - light_29->set_internal(!us_model); - light_30->set_internal(!us_model); - light_31->set_internal(!us_model); - light_eu->set_internal(us_model); - light_eu_bottom->set_internal(us_model); - light_eu_left->set_internal(us_model); - light_eu_right->set_internal(us_model); - light_eu_top->set_internal(us_model); - light_us->set_internal(!us_model); - light_us_bottom->set_internal(!us_model); - light_us_left->set_internal(!us_model); - light_us_right->set_internal(!us_model); - light_us_top->set_internal(!us_model); - sl_relay_1_mode->set_internal(num_gangs < 1); - sl_relay_1_light_mode_eu->set_internal(us_model or num_gangs < 1); - sl_relay_1_light_mode_us->set_internal(!us_model or num_gangs < 1); - sl_relay_2_mode->set_internal(num_gangs < 2); - sl_relay_2_light_mode_eu->set_internal(us_model or num_gangs < 2); - sl_relay_2_light_mode_us->set_internal(!us_model or num_gangs < 2); - sl_relay_3_mode->set_internal(num_gangs < 3); - sl_relay_3_light_mode_eu->set_internal(us_model or num_gangs < 3); - sl_relay_3_light_mode_us->set_internal(!us_model or num_gangs < 3); - sl_relay_4_mode->set_internal(num_gangs < 4); - sl_relay_4_light_mode_eu->set_internal(us_model or num_gangs < 4); - sl_relay_4_light_mode_us->set_internal(!us_model or num_gangs < 4); - auto relay_mode_index = sl_relay_1_mode->active_index(); - if (relay_mode_index.has_value()) { - ligth_output_1->set_internal(false or relay_mode_index.value() != 1); - sw_relay_1->set_internal(false or relay_mode_index.value() != 0); - } - relay_mode_index = sl_relay_2_mode->active_index(); - if (relay_mode_index.has_value()) { - ligth_output_2->set_internal(num_gangs < 2 or relay_mode_index.value() != 1); - sw_relay_2->set_internal(num_gangs < 2 or relay_mode_index.value() != 0); - } - relay_mode_index = sl_relay_3_mode->active_index(); - if (relay_mode_index.has_value()) { - ligth_output_3->set_internal(num_gangs < 3 or relay_mode_index.value() != 1); - sw_relay_3->set_internal(num_gangs < 3 or relay_mode_index.value() != 0); - } - relay_mode_index = sl_relay_4_mode->active_index(); - if (relay_mode_index.has_value()) { - ligth_output_4->set_internal(num_gangs < 4 or relay_mode_index.value() != 1); - sw_relay_4->set_internal(num_gangs < 4 or relay_mode_index.value() != 0); - } - switch (num_gangs) { - case 1: // 1 Gang - if (us_model) { - id(gb_lights_1) = { light_us_rl_1_1_left }; - id(gb_lights_2) = { light_us_rl_1_1_right }; - } else { - id(gb_lights_1) = { light_eu_rl_1_1_bottom }; - id(gb_lights_2) = { light_eu_rl_1_1_top }; - } - break; - case 2: // 2 Gang - if (us_model) { - id(gb_lights_1) = { light_us_rl_1_2_left, light_us_rl_2_2_left }; - id(gb_lights_2) = { light_us_rl_1_2_right, light_us_rl_2_2_right }; - } else { - id(gb_lights_1) = { light_eu_rl_1_2_bottom, light_eu_rl_2_2_bottom }; - id(gb_lights_2) = { light_eu_rl_1_2_top, light_eu_rl_2_2_top }; - } - break; - case 3: // 3 Gang - if (us_model) { - id(gb_lights_1) = { light_us_rl_1_3_left, light_us_rl_2_3_left, light_us_rl_3_3_left }; - id(gb_lights_2) = { light_us_rl_1_3_right, light_us_rl_2_3_right, light_us_rl_3_3_right }; - } else { - id(gb_lights_1) = { light_eu_rl_1_3_bottom, light_eu_rl_2_3_bottom, light_eu_rl_3_3_bottom }; - id(gb_lights_2) = { light_eu_rl_1_3_top, light_eu_rl_2_3_top, light_eu_rl_3_3_top }; - } - break; - case 4: // 3 Gang - if (us_model) { - id(gb_lights_1) = { light_us_rl_1_4_left, light_us_rl_2_4_left, light_us_rl_3_4_left, light_us_rl_4_4_left }; - id(gb_lights_2) = { light_us_rl_1_4_right, light_us_rl_2_4_right, light_us_rl_3_4_right, light_us_rl_4_4_right }; - } else { - id(gb_lights_1) = { light_eu_rl_1_4_bottom, light_eu_rl_2_4_bottom, light_eu_rl_3_4_bottom, light_eu_rl_4_4_bottom }; - id(gb_lights_2) = { light_eu_rl_1_4_top, light_eu_rl_2_4_top, light_eu_rl_3_4_top, light_eu_rl_4_4_top }; - } - break; - } + - script.execute: boot_initialize - priority: 600 # This is where most sensors are set up. then: - - lambda: |- - tx_fw_version->publish_state("${version}"); - tx_device_name->publish_state("${name}"); + - script.execute: boot_sequence + - priority: -100 # At this priority, pretty much everything should already be initialized. then: - - lambda: send_event_to_ha->execute("boot", "done"); + - script.execute: boot_done improv_serial: id: serial_improv @@ -191,9 +77,25 @@ ota: psram: script: + - id: boot_done + mode: restart + then: + - lambda: send_event_to_ha->execute("boot", "done"); + - id: boot_initialize mode: restart then: # There's nothing here so far + # Extended by: + # - HW Buttons + # - HW Relays + # - HW Touch + + - id: boot_sequence + mode: restart + then: + - lambda: |- + tx_fw_version->publish_state("${version}"); + tx_device_name->publish_state("${name}"); select: - id: sl_tx_model_format diff --git a/ESPHome/TX-Ultimate-Easy-ESPHome_core_api.yaml b/ESPHome/TX-Ultimate-Easy-ESPHome_core_api.yaml index c326718..6cc49f6 100644 --- a/ESPHome/TX-Ultimate-Easy-ESPHome_core_api.yaml +++ b/ESPHome/TX-Ultimate-Easy-ESPHome_core_api.yaml @@ -21,8 +21,11 @@ api: then: - lambda: |- if (!isnan(val)) { - if (component == "latitude") sun_entity->set_latitude(val); - else if (component == "longitude") sun_entity->set_longitude(val); + if (component == "latitude" && val >= -90 && val <= 90) { + sun_entity->set_latitude(val); + } else if (component == "longitude" && val >= -180 && val <= 180) { + sun_entity->set_longitude(val); + } } script: diff --git a/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_buttons.yaml b/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_buttons.yaml index 7b3e76e..e83804f 100644 --- a/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_buttons.yaml +++ b/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_buttons.yaml @@ -121,6 +121,32 @@ binary_sensor: event: long_click script: + - id: !extend boot_initialize + then: + - script.execute: boot_initialize_buttons + + - id: boot_initialize_buttons + mode: restart + then: + - wait_until: + condition: + - lambda: return sl_tx_model_gang->active_index().has_value(); + - lambda: |- + const uint8_t num_gangs = (sl_tx_model_gang->active_index().has_value()) ? + (sl_tx_model_gang->active_index().value() + 1) : 0; + bs_button_1->publish_state(false); + bs_button_1->set_internal(num_gangs < 1); + sl_button_1_action->set_internal(num_gangs < 1); + bs_button_2->publish_state(false); + bs_button_2->set_internal(num_gangs < 2); + sl_button_2_action->set_internal(num_gangs < 2); + bs_button_3->publish_state(false); + bs_button_3->set_internal(num_gangs < 3); + sl_button_3_action->set_internal(num_gangs < 3); + bs_button_4->publish_state(false); + bs_button_4->set_internal(num_gangs < 4); + sl_button_4_action->set_internal(num_gangs < 4); + - id: button_action mode: parallel parameters: @@ -133,34 +159,15 @@ script: - id: buttons_release mode: restart then: - - if: - condition: - binary_sensor.is_on: bs_button_1 - then: - - binary_sensor.template.publish: - id: bs_button_1 - state: OFF # yamllint disable-line rule:truthy - - if: - condition: - binary_sensor.is_on: bs_button_2 - then: - - binary_sensor.template.publish: - id: bs_button_2 - state: OFF # yamllint disable-line rule:truthy - - if: - condition: - binary_sensor.is_on: bs_button_3 - then: - - binary_sensor.template.publish: - id: bs_button_3 - state: OFF # yamllint disable-line rule:truthy - - if: - condition: - binary_sensor.is_on: bs_button_4 - then: - - binary_sensor.template.publish: - id: bs_button_4 - state: OFF # yamllint disable-line rule:truthy + - lambda: |- + std::vector buttons = { + bs_button_1, bs_button_2, bs_button_3, bs_button_4 + }; + for (auto* button : buttons) { + if (button->state) { + button->publish_state(false); + } + } - id: !extend touch_on_multi_touch_release then: diff --git a/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_leds.yaml b/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_leds.yaml index 555b5ca..0d60d8e 100644 --- a/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_leds.yaml +++ b/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_leds.yaml @@ -23,22 +23,22 @@ globals: restore_value: false light: - - id: ligth_output_1 + - id: light_output_1 name: Light output 1 internal: true platform: binary output: output_relay_1 - - id: ligth_output_2 + - id: light_output_2 name: Light output 2 internal: true platform: binary output: output_relay_2 - - id: ligth_output_3 + - id: light_output_3 name: Light output 3 internal: true platform: binary output: output_relay_3 - - id: ligth_output_4 + - id: light_output_4 name: Light output 4 internal: true platform: binary @@ -748,6 +748,71 @@ light: from: 7 to: 7 +script: + - id: !extend boot_initialize + then: + - wait_until: + condition: + - lambda: return sl_tx_model_format->active_index().has_value(); + - lambda: return sl_tx_model_gang->active_index().has_value(); + - lambda: |- + const bool is_model_us = sl_tx_model_format->active_index().has_value() and + sl_tx_model_format->active_index().value() == 1; + const uint8_t num_gangs = (sl_tx_model_gang->active_index().has_value()) ? + (sl_tx_model_gang->active_index().value() + 1) : 0; + light_28->set_internal(!is_model_us); + light_29->set_internal(!is_model_us); + light_30->set_internal(!is_model_us); + light_31->set_internal(!is_model_us); + light_eu->set_internal(is_model_us); + light_eu_bottom->set_internal(is_model_us); + light_eu_left->set_internal(is_model_us); + light_eu_right->set_internal(is_model_us); + light_eu_top->set_internal(is_model_us); + light_us->set_internal(!is_model_us); + light_us_bottom->set_internal(!is_model_us); + light_us_left->set_internal(!is_model_us); + light_us_right->set_internal(!is_model_us); + light_us_top->set_internal(!is_model_us); + switch (num_gangs) { + case 1: // 1 Gang + if (is_model_us) { + id(gb_lights_1) = { light_us_rl_1_1_left }; + id(gb_lights_2) = { light_us_rl_1_1_right }; + } else { + id(gb_lights_1) = { light_eu_rl_1_1_bottom }; + id(gb_lights_2) = { light_eu_rl_1_1_top }; + } + break; + case 2: // 2 Gang + if (is_model_us) { + id(gb_lights_1) = { light_us_rl_1_2_left, light_us_rl_2_2_left }; + id(gb_lights_2) = { light_us_rl_1_2_right, light_us_rl_2_2_right }; + } else { + id(gb_lights_1) = { light_eu_rl_1_2_bottom, light_eu_rl_2_2_bottom }; + id(gb_lights_2) = { light_eu_rl_1_2_top, light_eu_rl_2_2_top }; + } + break; + case 3: // 3 Gang + if (is_model_us) { + id(gb_lights_1) = { light_us_rl_1_3_left, light_us_rl_2_3_left, light_us_rl_3_3_left }; + id(gb_lights_2) = { light_us_rl_1_3_right, light_us_rl_2_3_right, light_us_rl_3_3_right }; + } else { + id(gb_lights_1) = { light_eu_rl_1_3_bottom, light_eu_rl_2_3_bottom, light_eu_rl_3_3_bottom }; + id(gb_lights_2) = { light_eu_rl_1_3_top, light_eu_rl_2_3_top, light_eu_rl_3_3_top }; + } + break; + case 4: // 3 Gang + if (is_model_us) { + id(gb_lights_1) = { light_us_rl_1_4_left, light_us_rl_2_4_left, light_us_rl_3_4_left, light_us_rl_4_4_left }; + id(gb_lights_2) = { light_us_rl_1_4_right, light_us_rl_2_4_right, light_us_rl_3_4_right, light_us_rl_4_4_right }; + } else { + id(gb_lights_1) = { light_eu_rl_1_4_bottom, light_eu_rl_2_4_bottom, light_eu_rl_3_4_bottom, light_eu_rl_4_4_bottom }; + id(gb_lights_2) = { light_eu_rl_1_4_top, light_eu_rl_2_4_top, light_eu_rl_3_4_top, light_eu_rl_4_4_top }; + } + break; + } + select: # EU relay light mode template - &relay_light_mode_eu diff --git a/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_relays.yaml b/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_relays.yaml index 04cd406..dd3279c 100644 --- a/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_relays.yaml +++ b/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_relays.yaml @@ -78,6 +78,55 @@ output: pin: GPIO23 script: + - id: !extend boot_initialize + then: + - script.execute: boot_initialize_relays + + - id: boot_initialize_relays + mode: restart + then: + - wait_until: + condition: + - lambda: return sl_tx_model_format->active_index().has_value(); + - lambda: return sl_tx_model_gang->active_index().has_value(); + - lambda: |- + const bool is_model_us = sl_tx_model_format->active_index().has_value() and + sl_tx_model_format->active_index().value() == 1; + const uint8_t num_gangs = (sl_tx_model_gang->active_index().has_value()) ? + (sl_tx_model_gang->active_index().value() + 1) : 0; + sl_relay_1_mode->set_internal(num_gangs < 1); + sl_relay_1_light_mode_eu->set_internal(is_model_us or num_gangs < 1); + sl_relay_1_light_mode_us->set_internal(!is_model_us or num_gangs < 1); + sl_relay_2_mode->set_internal(num_gangs < 2); + sl_relay_2_light_mode_eu->set_internal(is_model_us or num_gangs < 2); + sl_relay_2_light_mode_us->set_internal(!is_model_us or num_gangs < 2); + sl_relay_3_mode->set_internal(num_gangs < 3); + sl_relay_3_light_mode_eu->set_internal(is_model_us or num_gangs < 3); + sl_relay_3_light_mode_us->set_internal(!is_model_us or num_gangs < 3); + sl_relay_4_mode->set_internal(num_gangs < 4); + sl_relay_4_light_mode_eu->set_internal(is_model_us or num_gangs < 4); + sl_relay_4_light_mode_us->set_internal(!is_model_us or num_gangs < 4); + auto relay_mode_index = sl_relay_1_mode->active_index(); + if (relay_mode_index.has_value()) { + light_output_1->set_internal(false or relay_mode_index.value() != 1); + sw_relay_1->set_internal(false or relay_mode_index.value() != 0); + } + relay_mode_index = sl_relay_2_mode->active_index(); + if (relay_mode_index.has_value()) { + light_output_2->set_internal(num_gangs < 2 or relay_mode_index.value() != 1); + sw_relay_2->set_internal(num_gangs < 2 or relay_mode_index.value() != 0); + } + relay_mode_index = sl_relay_3_mode->active_index(); + if (relay_mode_index.has_value()) { + light_output_3->set_internal(num_gangs < 3 or relay_mode_index.value() != 1); + sw_relay_3->set_internal(num_gangs < 3 or relay_mode_index.value() != 0); + } + relay_mode_index = sl_relay_4_mode->active_index(); + if (relay_mode_index.has_value()) { + light_output_4->set_internal(num_gangs < 4 or relay_mode_index.value() != 1); + sw_relay_4->set_internal(num_gangs < 4 or relay_mode_index.value() != 0); + } + - id: show_relay_status mode: restart then: diff --git a/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_touch.yaml b/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_touch.yaml index dc5dcc4..958b0c8 100644 --- a/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_touch.yaml +++ b/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_touch.yaml @@ -58,7 +58,7 @@ binary_sensor: - lambda: send_event_to_ha->execute("swipe", "down"); external_components: - - source: github://edwardtfn/TX-Ultimate-Easy@dev # Change this before releasing + - source: github://edwardtfn/TX-Ultimate-Easy@main components: - tx_ultimate_easy @@ -79,6 +79,29 @@ number: restore_value: true script: + - id: !extend boot_initialize + then: + - script.execute: boot_initialize_touch + + - id: boot_initialize_touch + mode: restart + then: + - wait_until: + condition: + - lambda: return sl_tx_model_format->active_index().has_value(); + - lambda: |- + const bool is_model_us = sl_tx_model_format->active_index().has_value() and + sl_tx_model_format->active_index().value() == 1; + bs_multi_touch->publish_state(false); + bs_swipe_down->publish_state(false); + bs_swipe_down->set_internal(!is_model_us); + bs_swipe_left->publish_state(false); + bs_swipe_left->set_internal(is_model_us); + bs_swipe_right->publish_state(false); + bs_swipe_right->set_internal(is_model_us); + bs_swipe_up->publish_state(false); + bs_swipe_up->set_internal(!is_model_us); + - id: touch_on_multi_touch_release mode: restart then: diff --git a/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_vibration.yaml b/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_vibration.yaml index 2d1689c..570eaf2 100644 --- a/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_vibration.yaml +++ b/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_vibration.yaml @@ -11,6 +11,9 @@ ##### - For normal system use, modifications to this file are NOT required. ##### #################################################################################################### --- +substitutions: + vibration_max_duration: 5s + binary_sensor: - id: bs_vibrating name: Vibrating @@ -45,6 +48,11 @@ number: optimistic: true restore_value: true +ota: + on_state_change: + then: + - switch.turn_off: sw_vibration_motor + script: - id: !extend touch_on_multi_touch_release then: @@ -112,9 +120,19 @@ switch: internal: true on_turn_on: then: - - lambda: bs_vibrating->publish_state(true); + - binary_sensor.template.publish: + id: bs_vibrating + state: ON # yamllint disable-line rule:truthy + - delay: ${vibration_max_duration} + - if: + condition: + switch.is_on: sw_vibration_motor + then: + - switch.turn_off: sw_vibration_motor on_turn_off: then: - - lambda: bs_vibrating->publish_state(false); + - binary_sensor.template.publish: + id: bs_vibrating + state: OFF # yamllint disable-line rule:truthy ... From 62e4e3d511b02d2be523b14d3c1acf8c9d192bf3 Mon Sep 17 00:00:00 2001 From: Edward Firmo <94725493+edwardtfn@users.noreply.github.com> Date: Thu, 19 Dec 2024 23:52:21 +0100 Subject: [PATCH 17/36] More CodeRabbitAI suggestions --- ESPHome/TX-Ultimate-Easy-ESPHome_core.yaml | 1 + ESPHome/TX-Ultimate-Easy-ESPHome_core_api.yaml | 3 +++ ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_buttons.yaml | 4 ++++ ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_leds.yaml | 4 ++++ ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_relays.yaml | 4 ++++ 5 files changed, 16 insertions(+) diff --git a/ESPHome/TX-Ultimate-Easy-ESPHome_core.yaml b/ESPHome/TX-Ultimate-Easy-ESPHome_core.yaml index f407e5c..566bdd3 100644 --- a/ESPHome/TX-Ultimate-Easy-ESPHome_core.yaml +++ b/ESPHome/TX-Ultimate-Easy-ESPHome_core.yaml @@ -70,6 +70,7 @@ improv_serial: id: serial_improv logger: + level: INFO ota: platform: esphome diff --git a/ESPHome/TX-Ultimate-Easy-ESPHome_core_api.yaml b/ESPHome/TX-Ultimate-Easy-ESPHome_core_api.yaml index 6cc49f6..e99a892 100644 --- a/ESPHome/TX-Ultimate-Easy-ESPHome_core_api.yaml +++ b/ESPHome/TX-Ultimate-Easy-ESPHome_core_api.yaml @@ -20,6 +20,9 @@ api: val: float then: - lambda: |- + ESP_LOGD("core_api", "Set float:"); + ESP_LOGD("core_api", " Component: %s", component.c_str()); + ESP_LOGD("core_api", " Value: %f", val); if (!isnan(val)) { if (component == "latitude" && val >= -90 && val <= 90) { sun_entity->set_latitude(val); diff --git a/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_buttons.yaml b/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_buttons.yaml index e83804f..30667b2 100644 --- a/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_buttons.yaml +++ b/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_buttons.yaml @@ -134,6 +134,10 @@ script: - lambda: |- const uint8_t num_gangs = (sl_tx_model_gang->active_index().has_value()) ? (sl_tx_model_gang->active_index().value() + 1) : 0; + if (num_gangs < 1 || num_gangs > 4) { + ESP_LOGE("hw_buttons", "Invalid number of gangs: %" PRIu8, num_gangs); + return; + } bs_button_1->publish_state(false); bs_button_1->set_internal(num_gangs < 1); sl_button_1_action->set_internal(num_gangs < 1); diff --git a/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_leds.yaml b/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_leds.yaml index 0d60d8e..e025ac8 100644 --- a/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_leds.yaml +++ b/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_leds.yaml @@ -760,6 +760,10 @@ script: sl_tx_model_format->active_index().value() == 1; const uint8_t num_gangs = (sl_tx_model_gang->active_index().has_value()) ? (sl_tx_model_gang->active_index().value() + 1) : 0; + if (num_gangs < 1 || num_gangs > 4) { + ESP_LOGE("hw_leds", "Invalid number of gangs: %" PRIu8, num_gangs); + return; + } light_28->set_internal(!is_model_us); light_29->set_internal(!is_model_us); light_30->set_internal(!is_model_us); diff --git a/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_relays.yaml b/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_relays.yaml index dd3279c..0fe9c83 100644 --- a/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_relays.yaml +++ b/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_relays.yaml @@ -94,6 +94,10 @@ script: sl_tx_model_format->active_index().value() == 1; const uint8_t num_gangs = (sl_tx_model_gang->active_index().has_value()) ? (sl_tx_model_gang->active_index().value() + 1) : 0; + if (num_gangs < 1 || num_gangs > 4) { + ESP_LOGE("hw_relays", "Invalid number of gangs: %" PRIu8, num_gangs); + return; + } sl_relay_1_mode->set_internal(num_gangs < 1); sl_relay_1_light_mode_eu->set_internal(is_model_us or num_gangs < 1); sl_relay_1_light_mode_us->set_internal(!is_model_us or num_gangs < 1); From c62e7a689cbcf007858e3cb673b3c761da308ad5 Mon Sep 17 00:00:00 2001 From: Edward Firmo <94725493+edwardtfn@users.noreply.github.com> Date: Fri, 20 Dec 2024 00:21:39 +0100 Subject: [PATCH 18/36] Use version as reference for component --- ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_touch.yaml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_touch.yaml b/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_touch.yaml index 958b0c8..04aac9b 100644 --- a/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_touch.yaml +++ b/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_touch.yaml @@ -58,7 +58,11 @@ binary_sensor: - lambda: send_event_to_ha->execute("swipe", "down"); external_components: - - source: github://edwardtfn/TX-Ultimate-Easy@main + - source: + type: git + url: https://github.com/edwardtfn/TX-Ultimate-Easy + ref: ${version} + refresh: 1h components: - tx_ultimate_easy From 59da9bcb96c221bfdd2bd9b7979ebf764a403772 Mon Sep 17 00:00:00 2001 From: Edward Firmo <94725493+edwardtfn@users.noreply.github.com> Date: Fri, 20 Dec 2024 02:08:49 +0100 Subject: [PATCH 19/36] Wait for initialization to complete before update relay status That was crashing that method right after boot. - Solves #28 --- ESPHome/TX-Ultimate-Easy-ESPHome_core.yaml | 1 - ...Ultimate-Easy-ESPHome_core_hw_buttons.yaml | 2 +- ...TX-Ultimate-Easy-ESPHome_core_hw_leds.yaml | 2 +- ...-Ultimate-Easy-ESPHome_core_hw_relays.yaml | 33 ++++++++++++++++--- 4 files changed, 30 insertions(+), 8 deletions(-) diff --git a/ESPHome/TX-Ultimate-Easy-ESPHome_core.yaml b/ESPHome/TX-Ultimate-Easy-ESPHome_core.yaml index 566bdd3..0c164c0 100644 --- a/ESPHome/TX-Ultimate-Easy-ESPHome_core.yaml +++ b/ESPHome/TX-Ultimate-Easy-ESPHome_core.yaml @@ -129,7 +129,6 @@ select: disabled_by_default: false icon: mdi:dip-switch - sensor: - id: sun_elevation name: Sun Elevation diff --git a/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_buttons.yaml b/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_buttons.yaml index 30667b2..f8cd34f 100644 --- a/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_buttons.yaml +++ b/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_buttons.yaml @@ -135,7 +135,7 @@ script: const uint8_t num_gangs = (sl_tx_model_gang->active_index().has_value()) ? (sl_tx_model_gang->active_index().value() + 1) : 0; if (num_gangs < 1 || num_gangs > 4) { - ESP_LOGE("hw_buttons", "Invalid number of gangs: %" PRIu8, num_gangs); + ESP_LOGE("core_hw_buttons", "Invalid number of gangs: %" PRIu8, num_gangs); return; } bs_button_1->publish_state(false); diff --git a/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_leds.yaml b/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_leds.yaml index e025ac8..3892843 100644 --- a/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_leds.yaml +++ b/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_leds.yaml @@ -761,7 +761,7 @@ script: const uint8_t num_gangs = (sl_tx_model_gang->active_index().has_value()) ? (sl_tx_model_gang->active_index().value() + 1) : 0; if (num_gangs < 1 || num_gangs > 4) { - ESP_LOGE("hw_leds", "Invalid number of gangs: %" PRIu8, num_gangs); + ESP_LOGE("core_hw_leds", "Invalid number of gangs: %" PRIu8, num_gangs); return; } light_28->set_internal(!is_model_us); diff --git a/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_relays.yaml b/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_relays.yaml index 0fe9c83..3b3f01d 100644 --- a/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_relays.yaml +++ b/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_relays.yaml @@ -60,6 +60,12 @@ binary_sensor: !bs_swipe_right->state) sw_relay_4->toggle(); +globals: + - id: boot_initialization_relays + type: bool + restore_value: false + initial_value: 'false' + output: - id: output_relay_1 platform: gpio @@ -95,7 +101,7 @@ script: const uint8_t num_gangs = (sl_tx_model_gang->active_index().has_value()) ? (sl_tx_model_gang->active_index().value() + 1) : 0; if (num_gangs < 1 || num_gangs > 4) { - ESP_LOGE("hw_relays", "Invalid number of gangs: %" PRIu8, num_gangs); + ESP_LOGE("core_hw_relays", "Invalid number of gangs: %" PRIu8, num_gangs); return; } sl_relay_1_mode->set_internal(num_gangs < 1); @@ -130,13 +136,22 @@ script: light_output_4->set_internal(num_gangs < 4 or relay_mode_index.value() != 1); sw_relay_4->set_internal(num_gangs < 4 or relay_mode_index.value() != 0); } + id(boot_initialization_relays) = true; - id: show_relay_status mode: restart then: + - script.wait: boot_initialize_relays + - wait_until: + condition: + - lambda: return sl_tx_model_format->active_index().has_value(); + - lambda: return id(boot_initialization_relays); - lambda: |- auto model_format = sl_tx_model_format->active_index(); - if (!model_format.has_value()) return; // Early return if no model format + if (!model_format.has_value()) { + ESP_LOGE("core_hw_relays", "Model (Format) not defined"); + return; + } std::vector relay_modes; const bool is_eu_model = model_format.value() == 0; @@ -153,8 +168,16 @@ script: // Get switch states const std::vector switches = {sw_relay_1, sw_relay_2, sw_relay_3, sw_relay_4}; + // Check if light vectors are initialized + if (id(gb_lights_1).empty() || id(gb_lights_2).empty()) { + ESP_LOGE("core_hw_relays", "Light vector not initialized"); + return; + } + // Update lights based on relay states - for (size_t i = 0; i < relay_modes.size(); ++i) { + for (size_t i = 0; i < relay_modes.size() && i < id(gb_lights_1).size(); ++i) { + if (!relay_modes[i] || !switches[i]) continue; + auto light_index = relay_modes[i]->active_index(); if (!light_index.has_value()) continue; @@ -162,7 +185,7 @@ script: const bool switch_state = switches[i]->state; // Update first light group (bottom/left) - if (light_idx == 1 || light_idx == 3) { + if ((light_idx == 1 || light_idx == 3) && i < id(gb_lights_1).size() && id(gb_lights_1)[i]) { if (switch_state) id(gb_lights_1)[i]->turn_on(); else @@ -170,7 +193,7 @@ script: } // Update second light group (top/right) - if (light_idx == 2 || light_idx == 3) { + if ((light_idx == 2 || light_idx == 3) && i < id(gb_lights_2).size() && id(gb_lights_2)[i]) { if (switch_state) id(gb_lights_2)[i]->turn_on(); else From cc5858be8bad803be1bf77f9ad7862a6678619f2 Mon Sep 17 00:00:00 2001 From: Edward Firmo <94725493+edwardtfn@users.noreply.github.com> Date: Fri, 20 Dec 2024 02:10:33 +0100 Subject: [PATCH 20/36] Lint --- ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_relays.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_relays.yaml b/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_relays.yaml index 3b3f01d..ead05a5 100644 --- a/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_relays.yaml +++ b/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_relays.yaml @@ -177,7 +177,7 @@ script: // Update lights based on relay states for (size_t i = 0; i < relay_modes.size() && i < id(gb_lights_1).size(); ++i) { if (!relay_modes[i] || !switches[i]) continue; - + auto light_index = relay_modes[i]->active_index(); if (!light_index.has_value()) continue; From b1dbda4efe5279fec7a5f6cfe8776953ff8d6ecc Mon Sep 17 00:00:00 2001 From: Edward Firmo <94725493+edwardtfn@users.noreply.github.com> Date: Fri, 20 Dec 2024 02:31:12 +0100 Subject: [PATCH 21/36] Remove references to Blueprint in the README Solves #30 --- ESPHome/TX-Ultimate-Easy-ESPHome_core.yaml | 2 +- README.md | 5 +---- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/ESPHome/TX-Ultimate-Easy-ESPHome_core.yaml b/ESPHome/TX-Ultimate-Easy-ESPHome_core.yaml index 0c164c0..7e65564 100644 --- a/ESPHome/TX-Ultimate-Easy-ESPHome_core.yaml +++ b/ESPHome/TX-Ultimate-Easy-ESPHome_core.yaml @@ -70,7 +70,7 @@ improv_serial: id: serial_improv logger: - level: INFO + level: DEBUG ota: platform: esphome diff --git a/README.md b/README.md index 64ef6f6..9378089 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # TX Ultimate Easy -|  ![TX Ultimate Easy Logo](Assets/Logo.webp) | Welcome to TX Ultimate Easy! This project aims to provide custom firmware for Sonoff TX Ultimate devices based on ESPHome, making it easy for even the least tech-savvy users to configure and use. Our goal is to have all the configurations manageable directly through the Home Assistant UI or via blueprints, eliminating the need to edit YAML files manually. | +|  ![TX Ultimate Easy Logo](Assets/Logo.webp) | Welcome to TX Ultimate Easy! This project aims to provide custom firmware for Sonoff TX Ultimate devices based on ESPHome, making it easy for even the least tech-savvy users to configure and use. Our goal is to have all the configurations manageable directly through the Home Assistant UI, eliminating the need to edit YAML files manually. | | --- | :-- | ## Features @@ -27,9 +27,6 @@ To be written. - **Via Home Assistant UI:** All device settings can be managed through the Home Assistant interface. No need to edit YAML files directly. -- **Using Blueprints:** - Import and use blueprints to quickly configure your device for common use cases. - ## Documentation To be written. From 0cc17b715fae82110681252a85a4c79ed2926e71 Mon Sep 17 00:00:00 2001 From: Edward Firmo <94725493+edwardtfn@users.noreply.github.com> Date: Fri, 20 Dec 2024 02:35:16 +0100 Subject: [PATCH 22/36] Lint --- README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 9378089..46491be 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,9 @@ # TX Ultimate Easy + |  ![TX Ultimate Easy Logo](Assets/Logo.webp) | Welcome to TX Ultimate Easy! This project aims to provide custom firmware for Sonoff TX Ultimate devices based on ESPHome, making it easy for even the least tech-savvy users to configure and use. Our goal is to have all the configurations manageable directly through the Home Assistant UI, eliminating the need to edit YAML files manually. | | --- | :-- | + ## Features @@ -52,5 +54,6 @@ If you find this project helpful, consider supporting us through Buy Me a Coffee [![Buy Me a Coffee](https://www.buymeacoffee.com/assets/img/custom_images/yellow_img.png)](https://www.buymeacoffee.com/edwardfirmo) - + TX Ultimate Easy Logo + From b1b1a40d5e4747af9ec88565165e373296494d3e Mon Sep 17 00:00:00 2001 From: Edward Firmo <94725493+edwardtfn@users.noreply.github.com> Date: Fri, 20 Dec 2024 18:07:17 +0100 Subject: [PATCH 23/36] New implementation of `show_relay_status` Solves #28 I believe this also solves #21 --- ESPHome/TX-Ultimate-Easy-ESPHome_core.yaml | 24 +++-- ...TX-Ultimate-Easy-ESPHome_core_hw_leds.yaml | 87 +++++++++++++-- ...-Ultimate-Easy-ESPHome_core_hw_relays.yaml | 102 ++++++++++-------- 3 files changed, 149 insertions(+), 64 deletions(-) diff --git a/ESPHome/TX-Ultimate-Easy-ESPHome_core.yaml b/ESPHome/TX-Ultimate-Easy-ESPHome_core.yaml index 7e65564..2a88338 100644 --- a/ESPHome/TX-Ultimate-Easy-ESPHome_core.yaml +++ b/ESPHome/TX-Ultimate-Easy-ESPHome_core.yaml @@ -21,6 +21,14 @@ substitutions: version: '0.0.4' + TX_MODEL_FORMAT_EU_TEXT: "EU (Square, T5-xC-86)" + TX_MODEL_FORMAT_US_TEXT: "US (Rectangle, T5-xC-120)" + + TX_MODEL_1_GANG_TEXT: "1 Gang" + TX_MODEL_2_GANG_TEXT: "2 Gang" + TX_MODEL_3_GANG_TEXT: "3 Gang" + TX_MODEL_4_GANG_TEXT: "4 Gang" + packages: # yamllint disable rule:colons core_api: !include TX-Ultimate-Easy-ESPHome_core_api.yaml @@ -103,9 +111,9 @@ select: name: Model (Format) platform: template options: - - "EU (Square, T5-xC-86)" - - "US (Rectangle, T5-xC-120)" - initial_option: "EU (Square, T5-xC-86)" + - "${TX_MODEL_FORMAT_EU_TEXT}" + - "${TX_MODEL_FORMAT_US_TEXT}" + initial_option: "${TX_MODEL_FORMAT_EU_TEXT}" optimistic: true restore_value: true internal: false @@ -117,11 +125,11 @@ select: name: Model (Gang) platform: template options: - - "1 Gang" - - "2 Gang" - - "3 Gang" - - "4 Gang" - initial_option: "1 Gang" + - "${TX_MODEL_1_GANG_TEXT}" + - "${TX_MODEL_2_GANG_TEXT}" + - "${TX_MODEL_3_GANG_TEXT}" + - "${TX_MODEL_4_GANG_TEXT}" + initial_option: "${TX_MODEL_1_GANG_TEXT}" optimistic: true restore_value: true internal: false diff --git a/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_leds.yaml b/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_leds.yaml index 3892843..3f2fac0 100644 --- a/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_leds.yaml +++ b/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_leds.yaml @@ -14,6 +14,17 @@ substitutions: default_transition_length: 500ms + LIGHT_MODE_BOTH_TEXT: "Both" + LIGHT_MODE_DISABLED_TEXT: "Disabled" + LIGHT_MODE_LEFT_TEXT: "Left" + LIGHT_MODE_RIGHT_TEXT: "Right" + LIGHT_MODE_BOTTOM_TEXT: "Bottom" + LIGHT_MODE_TOP_TEXT: "Top" + + LIGHT_TRANSITION_TURN_ON: '0' # Transition time in msec + LIGHT_TRANSITION_TURN_OFF: '0' # Transition time in msec + LIGHT_BRIGHTNESS_TURN_ON: '0' # Brightness (1 to 100%, 0 to not set it) + globals: - id: gb_lights_1 type: std::vector @@ -817,6 +828,62 @@ script: break; } + - id: light_set_state + mode: parallel + parameters: + light_group: uint8_t + light_index: uint8_t + state: bool + then: + - lambda: |- + static const uint32_t LIGHT_TRANSITION_TURN_ON = ${LIGHT_TRANSITION_TURN_ON}; + static const uint32_t LIGHT_TRANSITION_TURN_OFF = ${LIGHT_TRANSITION_TURN_OFF}; + static const uint8_t LIGHT_BRIGHTNESS_TURN_ON = ${LIGHT_BRIGHTNESS_TURN_ON}; + + ESP_LOGI("core_hw_leds.light_set_state", "Setting light group %d, index %d to state %s", + light_group, light_index, state ? "ON" : "OFF"); + + switch (light_group) { + case 1: + if (light_index >= id(gb_lights_1).size()) { + ESP_LOGE("light_set_state", "Invalid light_index %d for group 1", light_index); + return; + } + if (state and !id(gb_lights_1)[light_index]->current_values.is_on()) { + auto call = id(gb_lights_1)[light_index]->turn_on(); + if (LIGHT_TRANSITION_TURN_ON > 0) + call.set_transition_length(LIGHT_TRANSITION_TURN_ON); // in ms + if (LIGHT_BRIGHTNESS_TURN_ON > 0 and LIGHT_BRIGHTNESS_TURN_ON <= 100) + call.set_brightness(LIGHT_TRANSITION_TURN_ON / 100.0f); + call.perform(); + } else if (!state and id(gb_lights_1)[light_index]->current_values.is_on()) { + auto call = id(gb_lights_1)[light_index]->turn_off(); + if (LIGHT_TRANSITION_TURN_OFF > 0) + call.set_transition_length(LIGHT_TRANSITION_TURN_OFF); // in ms + call.perform(); + } + break; + case 2: + if (light_index >= id(gb_lights_2).size()) { + ESP_LOGE("light_set_state", "Invalid light_index %d for group 2", light_index); + return; + } + if (state and !id(gb_lights_2)[light_index]->current_values.is_on()) { + auto call = id(gb_lights_2)[light_index]->turn_on(); + if (LIGHT_TRANSITION_TURN_ON > 0) + call.set_transition_length(LIGHT_TRANSITION_TURN_ON); // in ms + if (LIGHT_BRIGHTNESS_TURN_ON > 0 and LIGHT_BRIGHTNESS_TURN_ON <= 100) + call.set_brightness(LIGHT_TRANSITION_TURN_ON / 100.0f); + call.perform(); + } else if (!state and id(gb_lights_2)[light_index]->current_values.is_on()) { + auto call = id(gb_lights_2)[light_index]->turn_off(); + if (LIGHT_TRANSITION_TURN_OFF > 0) + call.set_transition_length(LIGHT_TRANSITION_TURN_OFF); // in ms + call.perform(); + } + break; + } + select: # EU relay light mode template - &relay_light_mode_eu @@ -824,11 +891,11 @@ select: name: Relay 1 light mode platform: template options: - - "Disabled" - - "Bottom" - - "Top" - - "Both" - initial_option: "Bottom" + - "${LIGHT_MODE_DISABLED_TEXT}" + - "${LIGHT_MODE_BOTTOM_TEXT}" + - "${LIGHT_MODE_TOP_TEXT}" + - "${LIGHT_MODE_BOTH_TEXT}" + initial_option: "${LIGHT_MODE_BOTTOM_TEXT}" optimistic: true restore_value: true internal: true @@ -854,11 +921,11 @@ select: name: Relay 1 light mode platform: template options: - - "Disabled" - - "Left" - - "Right" - - "Both" - initial_option: "Right" + - "${LIGHT_MODE_DISABLED_TEXT}" + - "${LIGHT_MODE_LEFT_TEXT}" + - "${LIGHT_MODE_RIGHT_TEXT}" + - "${LIGHT_MODE_BOTH_TEXT}" + initial_option: "${LIGHT_MODE_RIGHT_TEXT}" optimistic: true restore_value: true internal: true diff --git a/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_relays.yaml b/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_relays.yaml index ead05a5..88a9d9d 100644 --- a/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_relays.yaml +++ b/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_relays.yaml @@ -144,60 +144,70 @@ script: - script.wait: boot_initialize_relays - wait_until: condition: - - lambda: return sl_tx_model_format->active_index().has_value(); - lambda: return id(boot_initialization_relays); - lambda: |- - auto model_format = sl_tx_model_format->active_index(); - if (!model_format.has_value()) { - ESP_LOGE("core_hw_relays", "Model (Format) not defined"); + const bool is_model_us = sl_tx_model_format->active_index().has_value() and + sl_tx_model_format->active_index().value() == 1; + const uint8_t num_gangs = (sl_tx_model_gang->active_index().has_value()) ? + (sl_tx_model_gang->active_index().value() + 1) : 0; + + if (num_gangs < 1 || num_gangs > 4) { + ESP_LOGE("core_hw_relays", "Invalid number of gangs: %" PRIu8, num_gangs); return; } - std::vector relay_modes; - const bool is_eu_model = model_format.value() == 0; + for (uint8_t i = 0; i < num_gangs; i++) { + bool relay_state = false; + std::string light_mode; + const std::string light_mode_group_1 = is_model_us + ? "${LIGHT_MODE_LEFT_TEXT}" + : "${LIGHT_MODE_BOTTOM_TEXT}"; + const std::string light_mode_group_2 = is_model_us + ? "${LIGHT_MODE_RIGHT_TEXT}" + : "${LIGHT_MODE_TOP_TEXT}"; - // Select appropriate light mode selectors based on model - if (is_eu_model) { - relay_modes = {sl_relay_1_light_mode_eu, sl_relay_2_light_mode_eu, - sl_relay_3_light_mode_eu, sl_relay_4_light_mode_eu}; - } else { - relay_modes = {sl_relay_1_light_mode_us, sl_relay_2_light_mode_us, - sl_relay_3_light_mode_us, sl_relay_4_light_mode_us}; - } - - // Get switch states - const std::vector switches = {sw_relay_1, sw_relay_2, sw_relay_3, sw_relay_4}; - - // Check if light vectors are initialized - if (id(gb_lights_1).empty() || id(gb_lights_2).empty()) { - ESP_LOGE("core_hw_relays", "Light vector not initialized"); - return; - } - - // Update lights based on relay states - for (size_t i = 0; i < relay_modes.size() && i < id(gb_lights_1).size(); ++i) { - if (!relay_modes[i] || !switches[i]) continue; - - auto light_index = relay_modes[i]->active_index(); - if (!light_index.has_value()) continue; - - const uint8_t light_idx = light_index.value(); - const bool switch_state = switches[i]->state; - - // Update first light group (bottom/left) - if ((light_idx == 1 || light_idx == 3) && i < id(gb_lights_1).size() && id(gb_lights_1)[i]) { - if (switch_state) - id(gb_lights_1)[i]->turn_on(); - else - id(gb_lights_1)[i]->turn_off(); + // Determine relay state and light mode + switch (i) { + case 0: + relay_state = id(sw_relay_1).state; + light_mode = is_model_us + ? id(sl_relay_1_light_mode_us)->state + : id(sl_relay_1_light_mode_eu)->state; + break; + case 1: + relay_state = id(sw_relay_2).state; + light_mode = is_model_us + ? id(sl_relay_2_light_mode_us)->state + : id(sl_relay_2_light_mode_eu)->state; + break; + case 2: + relay_state = id(sw_relay_3).state; + light_mode = is_model_us + ? id(sl_relay_3_light_mode_us)->state + : id(sl_relay_3_light_mode_eu)->state; + break; + case 3: + relay_state = id(sw_relay_4).state; + light_mode = is_model_us + ? id(sl_relay_4_light_mode_us)->state + : id(sl_relay_4_light_mode_eu)->state; + break; } - // Update second light group (top/right) - if ((light_idx == 2 || light_idx == 3) && i < id(gb_lights_2).size() && id(gb_lights_2)[i]) { - if (switch_state) - id(gb_lights_2)[i]->turn_on(); - else - id(gb_lights_2)[i]->turn_off(); + ESP_LOGV("core_hw_relays", "Relay %" PRIu8 " is %s", i + 1, relay_state ? "ON" : "OFF"); + ESP_LOGV("core_hw_relays", "Light Mode for Relay %" PRIu8 ": %s", i + 1, light_mode.c_str()); + + // Use light_set_state for light updates + if (relay_state) { + if (light_mode == light_mode_group_1 || light_mode == "${LIGHT_MODE_BOTH_TEXT}") { + light_set_state->execute(1, i, true); // Left/bottom light + } + if (light_mode == light_mode_group_2 || light_mode == "${LIGHT_MODE_BOTH_TEXT}") { + light_set_state->execute(2, i, true); // Right/top light + } + } else { + light_set_state->execute(1, i, false); // Turn off left/bottom light + light_set_state->execute(2, i, false); // Turn off right/top light } } From ffe0d565763bb4b034c0febfaab018aec1cffd2d Mon Sep 17 00:00:00 2001 From: Edward Firmo <94725493+edwardtfn@users.noreply.github.com> Date: Fri, 20 Dec 2024 18:13:02 +0100 Subject: [PATCH 24/36] Lint --- ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_leds.yaml | 14 +++++++++----- .../TX-Ultimate-Easy-ESPHome_core_hw_relays.yaml | 13 +++++++------ 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_leds.yaml b/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_leds.yaml index 3f2fac0..93bbf5e 100644 --- a/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_leds.yaml +++ b/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_leds.yaml @@ -819,11 +819,15 @@ script: break; case 4: // 3 Gang if (is_model_us) { - id(gb_lights_1) = { light_us_rl_1_4_left, light_us_rl_2_4_left, light_us_rl_3_4_left, light_us_rl_4_4_left }; - id(gb_lights_2) = { light_us_rl_1_4_right, light_us_rl_2_4_right, light_us_rl_3_4_right, light_us_rl_4_4_right }; + id(gb_lights_1) = { light_us_rl_1_4_left, light_us_rl_2_4_left, + light_us_rl_3_4_left, light_us_rl_4_4_left }; + id(gb_lights_2) = { light_us_rl_1_4_right, light_us_rl_2_4_right, + light_us_rl_3_4_right, light_us_rl_4_4_right }; } else { - id(gb_lights_1) = { light_eu_rl_1_4_bottom, light_eu_rl_2_4_bottom, light_eu_rl_3_4_bottom, light_eu_rl_4_4_bottom }; - id(gb_lights_2) = { light_eu_rl_1_4_top, light_eu_rl_2_4_top, light_eu_rl_3_4_top, light_eu_rl_4_4_top }; + id(gb_lights_1) = { light_eu_rl_1_4_bottom, light_eu_rl_2_4_bottom, + light_eu_rl_3_4_bottom, light_eu_rl_4_4_bottom }; + id(gb_lights_2) = { light_eu_rl_1_4_top, light_eu_rl_2_4_top, + light_eu_rl_3_4_top, light_eu_rl_4_4_top }; } break; } @@ -840,7 +844,7 @@ script: static const uint32_t LIGHT_TRANSITION_TURN_OFF = ${LIGHT_TRANSITION_TURN_OFF}; static const uint8_t LIGHT_BRIGHTNESS_TURN_ON = ${LIGHT_BRIGHTNESS_TURN_ON}; - ESP_LOGI("core_hw_leds.light_set_state", "Setting light group %d, index %d to state %s", + ESP_LOGI("core_hw_leds.light_set_state", "Setting light group %d, index %d to state %s", light_group, light_index, state ? "ON" : "OFF"); switch (light_group) { diff --git a/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_relays.yaml b/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_relays.yaml index 88a9d9d..b2289c5 100644 --- a/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_relays.yaml +++ b/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_relays.yaml @@ -148,8 +148,9 @@ script: - lambda: |- const bool is_model_us = sl_tx_model_format->active_index().has_value() and sl_tx_model_format->active_index().value() == 1; - const uint8_t num_gangs = (sl_tx_model_gang->active_index().has_value()) ? - (sl_tx_model_gang->active_index().value() + 1) : 0; + const uint8_t num_gangs = (sl_tx_model_gang->active_index().has_value()) + ? (sl_tx_model_gang->active_index().value() + 1) + : 0; if (num_gangs < 1 || num_gangs > 4) { ESP_LOGE("core_hw_relays", "Invalid number of gangs: %" PRIu8, num_gangs); @@ -171,25 +172,25 @@ script: case 0: relay_state = id(sw_relay_1).state; light_mode = is_model_us - ? id(sl_relay_1_light_mode_us)->state + ? id(sl_relay_1_light_mode_us)->state : id(sl_relay_1_light_mode_eu)->state; break; case 1: relay_state = id(sw_relay_2).state; light_mode = is_model_us - ? id(sl_relay_2_light_mode_us)->state + ? id(sl_relay_2_light_mode_us)->state : id(sl_relay_2_light_mode_eu)->state; break; case 2: relay_state = id(sw_relay_3).state; light_mode = is_model_us - ? id(sl_relay_3_light_mode_us)->state + ? id(sl_relay_3_light_mode_us)->state : id(sl_relay_3_light_mode_eu)->state; break; case 3: relay_state = id(sw_relay_4).state; light_mode = is_model_us - ? id(sl_relay_4_light_mode_us)->state + ? id(sl_relay_4_light_mode_us)->state : id(sl_relay_4_light_mode_eu)->state; break; } From da83c0749bfe7bee2f13b8ebcfdf5b393ff3559d Mon Sep 17 00:00:00 2001 From: Edward Firmo <94725493+edwardtfn@users.noreply.github.com> Date: Fri, 20 Dec 2024 18:14:29 +0100 Subject: [PATCH 25/36] Lint --- ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_leds.yaml | 2 +- ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_relays.yaml | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_leds.yaml b/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_leds.yaml index 93bbf5e..b419743 100644 --- a/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_leds.yaml +++ b/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_leds.yaml @@ -18,7 +18,7 @@ substitutions: LIGHT_MODE_DISABLED_TEXT: "Disabled" LIGHT_MODE_LEFT_TEXT: "Left" LIGHT_MODE_RIGHT_TEXT: "Right" - LIGHT_MODE_BOTTOM_TEXT: "Bottom" + LIGHT_MODE_BOTTOM_TEXT: "Bottom" LIGHT_MODE_TOP_TEXT: "Top" LIGHT_TRANSITION_TURN_ON: '0' # Transition time in msec diff --git a/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_relays.yaml b/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_relays.yaml index b2289c5..884f8ef 100644 --- a/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_relays.yaml +++ b/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_relays.yaml @@ -171,25 +171,25 @@ script: switch (i) { case 0: relay_state = id(sw_relay_1).state; - light_mode = is_model_us + light_mode = is_model_us ? id(sl_relay_1_light_mode_us)->state : id(sl_relay_1_light_mode_eu)->state; break; case 1: relay_state = id(sw_relay_2).state; - light_mode = is_model_us + light_mode = is_model_us ? id(sl_relay_2_light_mode_us)->state : id(sl_relay_2_light_mode_eu)->state; break; case 2: relay_state = id(sw_relay_3).state; - light_mode = is_model_us + light_mode = is_model_us ? id(sl_relay_3_light_mode_us)->state : id(sl_relay_3_light_mode_eu)->state; break; case 3: relay_state = id(sw_relay_4).state; - light_mode = is_model_us + light_mode = is_model_us ? id(sl_relay_4_light_mode_us)->state : id(sl_relay_4_light_mode_eu)->state; break; From e0a5ea1cc815e32354c69fe84904cff9ae77c4f4 Mon Sep 17 00:00:00 2001 From: Edward Firmo <94725493+edwardtfn@users.noreply.github.com> Date: Fri, 20 Dec 2024 20:39:19 +0100 Subject: [PATCH 26/36] Do not toggle if other action is on place Helps with #18 --- ...Ultimate-Easy-ESPHome_core_hw_buttons.yaml | 26 +++++--- ...-Ultimate-Easy-ESPHome_core_hw_relays.yaml | 64 +++++++++---------- 2 files changed, 50 insertions(+), 40 deletions(-) diff --git a/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_buttons.yaml b/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_buttons.yaml index f8cd34f..2e8a8a0 100644 --- a/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_buttons.yaml +++ b/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_buttons.yaml @@ -14,6 +14,12 @@ substitutions: invalid_cooldown: 100ms + BUTTON_ACTION_NONE_TEXT: "None" + BUTTON_1_ACTION_TEXT: "Relay 1 (toggle)" + BUTTON_2_ACTION_TEXT: "Relay 2 (toggle)" + BUTTON_3_ACTION_TEXT: "Relay 3 (toggle)" + BUTTON_4_ACTION_TEXT: "Relay 4 (toggle)" + binary_sensor: - id: bs_button_1 name: Button 1 @@ -232,8 +238,9 @@ select: name: Button 1 action platform: template options: - - "None" - - "Relay 1 (toggle)" + - "${BUTTON_ACTION_NONE_TEXT}" + - "${BUTTON_1_ACTION_TEXT}" + initial_option: "${BUTTON_1_ACTION_TEXT}" optimistic: true restore_value: true internal: true @@ -245,23 +252,26 @@ select: name: Button 2 action platform: template options: - - "None" - - "Relay 2 (toggle)" + - "${BUTTON_ACTION_NONE_TEXT}" + - "${BUTTON_2_ACTION_TEXT}" + initial_option: "${BUTTON_2_ACTION_TEXT}" <<: *button_select_action_base - id: sl_button_3_action name: Button 3 action platform: template options: - - "None" - - "Relay 3 (toggle)" + - "${BUTTON_ACTION_NONE_TEXT}" + - "${BUTTON_3_ACTION_TEXT}" + initial_option: "${BUTTON_3_ACTION_TEXT}" <<: *button_select_action_base - id: sl_button_4_action name: Button 4 action platform: template options: - - "None" - - "Relay 4 (toggle)" + - "${BUTTON_ACTION_NONE_TEXT}" + - "${BUTTON_4_ACTION_TEXT}" + initial_option: "${BUTTON_4_ACTION_TEXT}" <<: *button_select_action_base ... diff --git a/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_relays.yaml b/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_relays.yaml index 884f8ef..e096d2a 100644 --- a/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_relays.yaml +++ b/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_relays.yaml @@ -15,50 +15,50 @@ binary_sensor: - id: !extend bs_button_1 on_click: then: - - lambda: |- - if (sl_button_1_action->active_index().has_value() and - sl_button_1_action->active_index().value() == 1 and - !bs_multi_touch->state and - !bs_swipe_left->state and - !bs_swipe_down->state and - !bs_swipe_right->state) - sw_relay_1->toggle(); + - if: + condition: + - lambda: return sl_button_1_action->active_index().has_value(); + - lambda: return sl_button_1_action->active_index().value() == 1; + - and: &button_click_no_other_click + - lambda: return not bs_multi_touch->state; + - lambda: return not bs_swipe_left->state; + - lambda: return not bs_swipe_down->state; + - lambda: return not bs_swipe_right->state; + then: + - switch.toggle: sw_relay_1 - id: !extend bs_button_2 on_click: then: - - lambda: |- - if (sl_button_2_action->active_index().has_value() and - sl_button_2_action->active_index().value() == 1 and - !bs_multi_touch->state and - !bs_swipe_left->state and - !bs_swipe_down->state and - !bs_swipe_right->state) - sw_relay_2->toggle(); + - if: + condition: + - lambda: return sl_button_2_action->active_index().has_value(); + - lambda: return sl_button_2_action->active_index().value() == 1; + - and: *button_click_no_other_click + then: + - switch.toggle: sw_relay_2 - id: !extend bs_button_3 on_click: then: - - lambda: |- - if (sl_button_3_action->active_index().has_value() and - sl_button_3_action->active_index().value() == 1 and - !bs_multi_touch->state and - !bs_swipe_left->state and - !bs_swipe_down->state and - !bs_swipe_right->state) - sw_relay_3->toggle(); + - if: + condition: + - lambda: return sl_button_3_action->active_index().has_value(); + - lambda: return sl_button_3_action->active_index().value() == 1; + - and: *button_click_no_other_click + then: + - switch.toggle: sw_relay_3 - id: !extend bs_button_4 on_click: then: - - lambda: |- - if (sl_button_4_action->active_index().has_value() and - sl_button_4_action->active_index().value() == 1 and - !bs_multi_touch->state and - !bs_swipe_left->state and - !bs_swipe_down->state and - !bs_swipe_right->state) - sw_relay_4->toggle(); + - if: + condition: + - lambda: return sl_button_4_action->active_index().has_value(); + - lambda: return sl_button_4_action->active_index().value() == 1; + - and: *button_click_no_other_click + then: + - switch.toggle: sw_relay_4 globals: - id: boot_initialization_relays From e1b8469aa57b16c1394156379ecb2d7f83c6f5df Mon Sep 17 00:00:00 2001 From: Edward Firmo <94725493+edwardtfn@users.noreply.github.com> Date: Fri, 20 Dec 2024 20:51:52 +0100 Subject: [PATCH 27/36] Remove sun platform It isn't in use yet --- ESPHome/TX-Ultimate-Easy-ESPHome_core.yaml | 28 ------------------- .../TX-Ultimate-Easy-ESPHome_core_api.yaml | 18 ------------ 2 files changed, 46 deletions(-) diff --git a/ESPHome/TX-Ultimate-Easy-ESPHome_core.yaml b/ESPHome/TX-Ultimate-Easy-ESPHome_core.yaml index 2a88338..e42bc50 100644 --- a/ESPHome/TX-Ultimate-Easy-ESPHome_core.yaml +++ b/ESPHome/TX-Ultimate-Easy-ESPHome_core.yaml @@ -137,34 +137,6 @@ select: disabled_by_default: false icon: mdi:dip-switch -sensor: - - id: sun_elevation - name: Sun Elevation - platform: sun - type: elevation - internal: true - - - id: zone_home_latitude - platform: homeassistant - entity_id: ${zone_home} - attribute: latitude - internal: false - on_value: - - lambda: if (!isnan(x)) sun_entity->set_latitude(x); - - - id: zone_home_longitude - platform: homeassistant - entity_id: ${zone_home} - attribute: longitude - internal: false - on_value: - - lambda: if (!isnan(x)) sun_entity->set_longitude(x); - -sun: - id: sun_entity - latitude: ${latitude} - longitude: ${longitude} - text_sensor: - id: tx_fw_version name: Firmware version diff --git a/ESPHome/TX-Ultimate-Easy-ESPHome_core_api.yaml b/ESPHome/TX-Ultimate-Easy-ESPHome_core_api.yaml index e99a892..c9fa871 100644 --- a/ESPHome/TX-Ultimate-Easy-ESPHome_core_api.yaml +++ b/ESPHome/TX-Ultimate-Easy-ESPHome_core_api.yaml @@ -13,23 +13,6 @@ --- api: id: api_server - actions: - - action: set_float - variables: - component: string - val: float - then: - - lambda: |- - ESP_LOGD("core_api", "Set float:"); - ESP_LOGD("core_api", " Component: %s", component.c_str()); - ESP_LOGD("core_api", " Value: %f", val); - if (!isnan(val)) { - if (component == "latitude" && val >= -90 && val <= 90) { - sun_entity->set_latitude(val); - } else if (component == "longitude" && val >= -180 && val <= 180) { - sun_entity->set_longitude(val); - } - } script: - id: !extend button_action @@ -54,5 +37,4 @@ script: {"component", component}, {"event", event}, }); - ... From 55cde35d312552b66485627aa9c9b515d3bb0ac0 Mon Sep 17 00:00:00 2001 From: Edward Firmo <94725493+edwardtfn@users.noreply.github.com> Date: Fri, 20 Dec 2024 21:00:24 +0100 Subject: [PATCH 28/36] Publish device name only at boot and api connection --- ESPHome/TX-Ultimate-Easy-ESPHome_core.yaml | 6 ++++++ ESPHome/TX-Ultimate-Easy-ESPHome_core_api.yaml | 3 +++ 2 files changed, 9 insertions(+) diff --git a/ESPHome/TX-Ultimate-Easy-ESPHome_core.yaml b/ESPHome/TX-Ultimate-Easy-ESPHome_core.yaml index e42bc50..7f253bc 100644 --- a/ESPHome/TX-Ultimate-Easy-ESPHome_core.yaml +++ b/ESPHome/TX-Ultimate-Easy-ESPHome_core.yaml @@ -100,6 +100,11 @@ script: # - HW Touch - id: boot_sequence + mode: restart + then: + - script.execute: publish_device_info + + - id: publish_device_info mode: restart then: - lambda: |- @@ -155,6 +160,7 @@ text_sensor: entity_category: diagnostic internal: false disabled_by_default: false + update_interval: never lambda: |- return {"${name}"}; filters: diff --git a/ESPHome/TX-Ultimate-Easy-ESPHome_core_api.yaml b/ESPHome/TX-Ultimate-Easy-ESPHome_core_api.yaml index c9fa871..43322bc 100644 --- a/ESPHome/TX-Ultimate-Easy-ESPHome_core_api.yaml +++ b/ESPHome/TX-Ultimate-Easy-ESPHome_core_api.yaml @@ -13,6 +13,9 @@ --- api: id: api_server + on_client_connected: + then: + - script.execute: publish_device_info script: - id: !extend button_action From 8f4a2a94029ae43605ee52b1626456a8bd8feb15 Mon Sep 17 00:00:00 2001 From: Edward Firmo <94725493+edwardtfn@users.noreply.github.com> Date: Fri, 20 Dec 2024 21:23:28 +0100 Subject: [PATCH 29/36] Device name from App --- ESPHome/TX-Ultimate-Easy-ESPHome_core.yaml | 13 ++++++++++--- ESPHome/TX-Ultimate-Easy-ESPHome_core_api.yaml | 16 +++++++--------- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/ESPHome/TX-Ultimate-Easy-ESPHome_core.yaml b/ESPHome/TX-Ultimate-Easy-ESPHome_core.yaml index 7f253bc..715d98b 100644 --- a/ESPHome/TX-Ultimate-Easy-ESPHome_core.yaml +++ b/ESPHome/TX-Ultimate-Easy-ESPHome_core.yaml @@ -89,11 +89,18 @@ script: - id: boot_done mode: restart then: - - lambda: send_event_to_ha->execute("boot", "done"); + - script.execute: + id: send_event_to_ha + component: boot + event: done - id: boot_initialize mode: restart - then: # There's nothing here so far + then: + - script.execute: + id: send_event_to_ha + component: boot + event: start # Extended by: # - HW Buttons # - HW Relays @@ -109,7 +116,7 @@ script: then: - lambda: |- tx_fw_version->publish_state("${version}"); - tx_device_name->publish_state("${name}"); + tx_device_name->publish_state(App.get_name().c_str()); select: - id: sl_tx_model_format diff --git a/ESPHome/TX-Ultimate-Easy-ESPHome_core_api.yaml b/ESPHome/TX-Ultimate-Easy-ESPHome_core_api.yaml index 43322bc..ff4bb80 100644 --- a/ESPHome/TX-Ultimate-Easy-ESPHome_core_api.yaml +++ b/ESPHome/TX-Ultimate-Easy-ESPHome_core_api.yaml @@ -31,13 +31,11 @@ script: component: string event: string then: - - lambda: |- - esphome::api::CustomAPIDevice ha_event; - ha_event.fire_homeassistant_event("esphome.tx_ultimate_easy", - { - {"device_name", tx_device_name->state.c_str()}, - {"firmware", "${version}"}, - {"component", component}, - {"event", event}, - }); + - homeassistant.event: + event: esphome.tx_ultimate_easy + data: + device_name: !lambda return tx_device_name->state.c_str(); + firmware: ${version} + component: !lambda return component.c_str(); + event: !lambda return event.c_str(); ... From d0b8ba55baaf4a7f4d659cc23ddf5b8a0eff873f Mon Sep 17 00:00:00 2001 From: Edward Firmo <94725493+edwardtfn@users.noreply.github.com> Date: Fri, 20 Dec 2024 22:32:59 +0100 Subject: [PATCH 30/36] Clean-up logs The less the more --- ESPHome/TX-Ultimate-Easy-ESPHome_core.yaml | 2 +- ...TX-Ultimate-Easy-ESPHome_core_hw_leds.yaml | 20 +++++++++++++++---- ...X-Ultimate-Easy-ESPHome_core_hw_touch.yaml | 3 ++- 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/ESPHome/TX-Ultimate-Easy-ESPHome_core.yaml b/ESPHome/TX-Ultimate-Easy-ESPHome_core.yaml index 715d98b..1375536 100644 --- a/ESPHome/TX-Ultimate-Easy-ESPHome_core.yaml +++ b/ESPHome/TX-Ultimate-Easy-ESPHome_core.yaml @@ -78,7 +78,7 @@ improv_serial: id: serial_improv logger: - level: DEBUG + level: INFO ota: platform: esphome diff --git a/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_leds.yaml b/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_leds.yaml index b419743..573b88b 100644 --- a/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_leds.yaml +++ b/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_leds.yaml @@ -844,16 +844,21 @@ script: static const uint32_t LIGHT_TRANSITION_TURN_OFF = ${LIGHT_TRANSITION_TURN_OFF}; static const uint8_t LIGHT_BRIGHTNESS_TURN_ON = ${LIGHT_BRIGHTNESS_TURN_ON}; - ESP_LOGI("core_hw_leds.light_set_state", "Setting light group %d, index %d to state %s", - light_group, light_index, state ? "ON" : "OFF"); + const bool is_model_us = sl_tx_model_format->active_index().has_value() and + sl_tx_model_format->active_index().value() == 1; + const std::string light_mode_group_1 = is_model_us ? "${LIGHT_MODE_LEFT_TEXT}" : "${LIGHT_MODE_BOTTOM_TEXT}"; + const std::string light_mode_group_2 = is_model_us ? "${LIGHT_MODE_RIGHT_TEXT}" : "${LIGHT_MODE_TOP_TEXT}"; switch (light_group) { case 1: if (light_index >= id(gb_lights_1).size()) { - ESP_LOGE("light_set_state", "Invalid light_index %d for group 1", light_index); + ESP_LOGE("core_hw_leds", "Invalid set with %s light for Relay %" PRIu8, + light_mode_group_1.c_str(), light_index); return; } if (state and !id(gb_lights_1)[light_index]->current_values.is_on()) { + ESP_LOGI("core_hw_leds", "Turn-on %s light for Relay %" PRIu8, + light_mode_group_1.c_str(), light_index); auto call = id(gb_lights_1)[light_index]->turn_on(); if (LIGHT_TRANSITION_TURN_ON > 0) call.set_transition_length(LIGHT_TRANSITION_TURN_ON); // in ms @@ -861,6 +866,8 @@ script: call.set_brightness(LIGHT_TRANSITION_TURN_ON / 100.0f); call.perform(); } else if (!state and id(gb_lights_1)[light_index]->current_values.is_on()) { + ESP_LOGI("core_hw_leds", "Turn-off %s light for Relay %" PRIu8, + light_mode_group_1.c_str(), light_index); auto call = id(gb_lights_1)[light_index]->turn_off(); if (LIGHT_TRANSITION_TURN_OFF > 0) call.set_transition_length(LIGHT_TRANSITION_TURN_OFF); // in ms @@ -869,10 +876,13 @@ script: break; case 2: if (light_index >= id(gb_lights_2).size()) { - ESP_LOGE("light_set_state", "Invalid light_index %d for group 2", light_index); + ESP_LOGE("core_hw_leds", "Invalid set with %s light for Relay %" PRIu8, + light_mode_group_2.c_str(), light_index); return; } if (state and !id(gb_lights_2)[light_index]->current_values.is_on()) { + ESP_LOGI("core_hw_leds", "Turn-on %s light for Relay %" PRIu8, + light_mode_group_2.c_str(), light_index); auto call = id(gb_lights_2)[light_index]->turn_on(); if (LIGHT_TRANSITION_TURN_ON > 0) call.set_transition_length(LIGHT_TRANSITION_TURN_ON); // in ms @@ -880,6 +890,8 @@ script: call.set_brightness(LIGHT_TRANSITION_TURN_ON / 100.0f); call.perform(); } else if (!state and id(gb_lights_2)[light_index]->current_values.is_on()) { + ESP_LOGI("core_hw_leds", "Turn-off %s light for Relay %" PRIu8, + light_mode_group_2.c_str(), light_index); auto call = id(gb_lights_2)[light_index]->turn_off(); if (LIGHT_TRANSITION_TURN_OFF > 0) call.set_transition_length(LIGHT_TRANSITION_TURN_OFF); // in ms diff --git a/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_touch.yaml b/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_touch.yaml index 04aac9b..08c6490 100644 --- a/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_touch.yaml +++ b/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_touch.yaml @@ -208,7 +208,8 @@ tx_ultimate_easy: - script.execute: touch_on_multi_touch_release on_press: - - lambda: ESP_LOGI("tx_ultimate_easy", "Pressed"); + - lambda: |- + ESP_LOGI("tx_ultimate_easy", "Pressed at position %" PRIu8, static_cast(touch.x)); - script.execute: id: touch_on_press touch_x: !lambda return static_cast(touch.x); From 82b6d8cb2530652634179a3f177afaaaa688ea30 Mon Sep 17 00:00:00 2001 From: Edward Firmo <94725493+edwardtfn@users.noreply.github.com> Date: Fri, 20 Dec 2024 22:38:05 +0100 Subject: [PATCH 31/36] Lint --- ESPHome/TX-Ultimate-Easy-ESPHome_core.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ESPHome/TX-Ultimate-Easy-ESPHome_core.yaml b/ESPHome/TX-Ultimate-Easy-ESPHome_core.yaml index 1375536..727af88 100644 --- a/ESPHome/TX-Ultimate-Easy-ESPHome_core.yaml +++ b/ESPHome/TX-Ultimate-Easy-ESPHome_core.yaml @@ -97,14 +97,14 @@ script: - id: boot_initialize mode: restart then: + # Extended by: + # - HW Buttons + # - HW Relays + # - HW Touch - script.execute: id: send_event_to_ha component: boot event: start - # Extended by: - # - HW Buttons - # - HW Relays - # - HW Touch - id: boot_sequence mode: restart From 6f4d8ff61198a03f8063b4fa8a58eeade8956f33 Mon Sep 17 00:00:00 2001 From: Edward Firmo <94725493+edwardtfn@users.noreply.github.com> Date: Fri, 20 Dec 2024 22:58:06 +0100 Subject: [PATCH 32/36] Update README.md --- README.md | 148 ++++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 115 insertions(+), 33 deletions(-) diff --git a/README.md b/README.md index 46491be..350c1ed 100644 --- a/README.md +++ b/README.md @@ -1,58 +1,140 @@ # TX Ultimate Easy +[![GitHub Release][releases-shield]][releases] +[![GitHub Activity][commits-shield]][commits] +[![License][license-shield]](LICENSE) +[![GitHub Last Commit][last-commit-shield]][commits] +[![ESPHome][esphome-shield]][esphome] +[![Discord][discord-shield]][discord] +[![Buy me an ice-cream][buymeacoffee-shield]][buymeacoffee] + -|  ![TX Ultimate Easy Logo](Assets/Logo.webp) | Welcome to TX Ultimate Easy! This project aims to provide custom firmware for Sonoff TX Ultimate devices based on ESPHome, making it easy for even the least tech-savvy users to configure and use. Our goal is to have all the configurations manageable directly through the Home Assistant UI, eliminating the need to edit YAML files manually. | +|  ![TX Ultimate Easy Logo](Assets/Logo.webp) | TX Ultimate Easy provides custom ESPHome firmware for Sonoff TX Ultimate devices. Our project focuses on user-friendly configuration through the Home Assistant UI, eliminating the need for manual YAML editing. Whether you're new to home automation or an experienced user, TX Ultimate Easy makes it simple to manage your device. | | --- | :-- | -## Features +[releases-shield]: https://img.shields.io/github/v/release/edwardtfn/TX-Ultimate-Easy +[releases]: https://github.com/edwardtfn/TX-Ultimate-Easy/releases +[commits-shield]: https://img.shields.io/github/commit-activity/y/edwardtfn/TX-Ultimate-Easy +[commits]: https://github.com/edwardtfn/TX-Ultimate-Easy/commits/main +[license-shield]: https://img.shields.io/github/license/edwardtfn/TX-Ultimate-Easy +[last-commit-shield]: https://img.shields.io/github/last-commit/edwardtfn/TX-Ultimate-Easy +[esphome-shield]: https://img.shields.io/badge/powered%20by-ESPHome-blue +[esphome]: https://esphome.io/ +[discord-shield]: https://img.shields.io/discord/1195037138681913374?logo=discord +[discord]: https://discord.gg/Db6WJWzWuf +[buymeacoffee-shield]: https://img.shields.io/static/v1?label=Buy%20me%20an%20ice%20cream&message=❄&color=blue +[buymeacoffee]: https://www.buymeacoffee.com/edwardfirmo -- **Simple Setup:** Configure your Sonoff TX Ultimate through Home Assistant UI. -- **No YAML Editing:** All settings are adjustable without touching YAML files after the initial setup. -- **User-Friendly:** Designed for users of all technical levels. -- **Customizable:** Flexibility to adapt the firmware to your needs. -- **Seamless Integration:** Works flawlessly with Home Assistant. +## Integration with Home Assistant -## Getting Started +TX Ultimate Easy exposes your device's components (sensors, touch panel, relays, etc.) to Home Assistant, allowing you to: -### Prerequisites +- Monitor sensor states and values +- Control device components through the Home Assistant UI +- Use device triggers and states in your Home Assistant automations and scripts +- Configure device behavior through Home Assistant's service calls -- Sonoff TX Ultimate device -- Home Assistant installed -- ESPHome add-on installed in Home Assistant +All automation capabilities are handled through Home Assistant's native automation system - this project focuses on providing reliable device integration rather than implementing its own automation tools. -### Installation -To be written. +## Key Features -### Configuration +- **Home Assistant UI Configuration**: Manage all device settings directly through the Home Assistant interface +- **Zero YAML Knowledge Required**: After initial setup, no manual YAML editing needed +- **Flexible Light Control**: Customize LED behavior and effects +- **Touch Panel Support**: Full support for touch gestures and multi-touch capabilities +- **Advanced Automations**: Create complex automations using Home Assistant's powerful automation engine +- **BLE Proxy Support**: Optional Bluetooth Low Energy proxy functionality +- **Audio Feedback**: Built-in speaker support for audible feedback +- **Haptic Feedback**: Vibration motor support for tactile feedback -- **Via Home Assistant UI:** - All device settings can be managed through the Home Assistant interface. No need to edit YAML files directly. +## Hardware Support -## Documentation -To be written. +- Compatible with all Sonoff TX Ultimate variants: + - EU format (Square, T5-xC-86) + - US format (Rectangle, T5-xC-120) + - 1/2/3/4 gang versions + +## Prerequisites + +Before getting started, ensure you have: + +1. A Sonoff TX Ultimate device +2. Home Assistant installation +3. ESPHome add-on installed in Home Assistant +4. Basic knowledge of Home Assistant + +## Installation + +Detailed installation instructions coming soon. The process will include: + +1. Initial ESPHome setup +2. Device flashing +3. Home Assistant integration +4. Basic configuration + +## Usage + +After installation, you can: + +1. Configure your device through Home Assistant UI +2. Customize touch behaviors +3. Set up LED patterns and effects +4. Create automations +5. Enable optional features like BLE proxy + +## Configuration Options + +TX Ultimate Easy offers extensive configuration options: + +- Touch panel sensitivity and gestures +- LED colors, patterns, and behaviors +- Relay modes and functions +- Audio and haptic feedback settings +- Network and connectivity options ## Contributing -We welcome contributions from the community. If you have ideas for new features, improvements, or bug fixes, please open an issue or submit a pull request. +We welcome contributions from the community! Here's how you can help: + +1. Fork the repository +2. Create a feature branch from `dev` +3. Make your changes +4. Submit a pull request targeting the `dev` branch + +Please ensure your code follows our standards: +- Passes all lint checks (YAML, C++, Markdown) +- Includes appropriate documentation +- Follows existing code style + +All pull requests should be made against the `dev` branch. We don't accept pull requests directly to `main` as it's reserved for stable releases. + +## Support and Community + +Need help? Here are your options: + +- **Bug Reports & Feature Requests**: Use [GitHub Issues](https://github.com/edwardtfn/TX-Ultimate-Easy/issues) for all bug reports and feature requests +- **Community Chat**: Join our [Discord Server](https://discord.gg/Db6WJWzWuf) for discussions and community interaction +- **Support the Project**: Consider supporting through Buy Me a Coffee + +Note: For proper tracking and resolution, all bug reports and feature requests must be submitted through GitHub Issues, not Discord. The Issues page can be found at: [Issues · edwardtfn/TX-Ultimate-Easy](https://github.com/edwardtfn/TX-Ultimate-Easy/issues) + +[![Buy Me a Coffee](https://www.buymeacoffee.com/assets/img/custom_images/yellow_img.png)](https://www.buymeacoffee.com/edwardfirmo) + +## Acknowledgments + +This project builds upon the work of several amazing projects and contributors: + +- [SmartHome yourself - SONOFF TX Ultimate for ESPHome](https://github.com/SmartHome-yourself/sonoff-tx-ultimate-for-esphome) +- [Un loco y su tecnología - Sonoff TX Ultimate with ESPHome](https://www.youtube.com/watch?v=58v8oqSQgXQ) + +Special thanks to all contributors and community members who help make this project better. ## License This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details. -## Acknowledgments - -This project is highly inspired by these other projects: -- [SmartHome yourself - SONOFF TX Ultimate for ESPHome (Custom Component)](https://github.com/SmartHome-yourself/sonoff-tx-ultimate-for-esphome) -- [Un loco y su tecnología - Sonoff TX Ultimate with ESPHome | Absolute power](https://www.youtube.com/watch?v=58v8oqSQgXQ) - -Thanks a lot for sharing all your discoveries and ideas. - -## Support - -If you find this project helpful, consider supporting us through Buy Me a Coffee: - -[![Buy Me a Coffee](https://www.buymeacoffee.com/assets/img/custom_images/yellow_img.png)](https://www.buymeacoffee.com/edwardfirmo) +--- TX Ultimate Easy Logo From c01f8a462314c6a4666072e7f5a25a69994462b8 Mon Sep 17 00:00:00 2001 From: Edward Firmo <94725493+edwardtfn@users.noreply.github.com> Date: Fri, 20 Dec 2024 23:08:55 +0100 Subject: [PATCH 33/36] FIx Discord badge --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 350c1ed..9f536e7 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ [last-commit-shield]: https://img.shields.io/github/last-commit/edwardtfn/TX-Ultimate-Easy [esphome-shield]: https://img.shields.io/badge/powered%20by-ESPHome-blue [esphome]: https://esphome.io/ -[discord-shield]: https://img.shields.io/discord/1195037138681913374?logo=discord +[discord-shield]: https://img.shields.io/badge/Discord-chat-blue?logo=discord [discord]: https://discord.gg/Db6WJWzWuf [buymeacoffee-shield]: https://img.shields.io/static/v1?label=Buy%20me%20an%20ice%20cream&message=❄&color=blue [buymeacoffee]: https://www.buymeacoffee.com/edwardfirmo From 9646d5292a41ef8eb52523d7ed1fd60f5b4a8dca Mon Sep 17 00:00:00 2001 From: Edward Firmo <94725493+edwardtfn@users.noreply.github.com> Date: Fri, 20 Dec 2024 23:13:49 +0100 Subject: [PATCH 34/36] Fix Discord server again --- README.md | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 9f536e7..a03ca3a 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,7 @@ # TX Ultimate Easy -[![GitHub Release][releases-shield]][releases] [![GitHub Activity][commits-shield]][commits] -[![License][license-shield]](LICENSE) +[![License][license-shield]][license] [![GitHub Last Commit][last-commit-shield]][commits] [![ESPHome][esphome-shield]][esphome] [![Discord][discord-shield]][discord] @@ -13,15 +12,14 @@ | --- | :-- | -[releases-shield]: https://img.shields.io/github/v/release/edwardtfn/TX-Ultimate-Easy -[releases]: https://github.com/edwardtfn/TX-Ultimate-Easy/releases [commits-shield]: https://img.shields.io/github/commit-activity/y/edwardtfn/TX-Ultimate-Easy [commits]: https://github.com/edwardtfn/TX-Ultimate-Easy/commits/main [license-shield]: https://img.shields.io/github/license/edwardtfn/TX-Ultimate-Easy +[license]: LICENSE [last-commit-shield]: https://img.shields.io/github/last-commit/edwardtfn/TX-Ultimate-Easy [esphome-shield]: https://img.shields.io/badge/powered%20by-ESPHome-blue [esphome]: https://esphome.io/ -[discord-shield]: https://img.shields.io/badge/Discord-chat-blue?logo=discord +[discord-shield]: https://img.shields.io/discord/1243652421692031016?logo=discord [discord]: https://discord.gg/Db6WJWzWuf [buymeacoffee-shield]: https://img.shields.io/static/v1?label=Buy%20me%20an%20ice%20cream&message=❄&color=blue [buymeacoffee]: https://www.buymeacoffee.com/edwardfirmo From 9fbc4993391518f5129d6fabca0ad732b24bd0b4 Mon Sep 17 00:00:00 2001 From: Edward Firmo <94725493+edwardtfn@users.noreply.github.com> Date: Fri, 20 Dec 2024 23:27:21 +0100 Subject: [PATCH 35/36] Open links in another tab --- README.md | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index a03ca3a..a184ba5 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,13 @@ # TX Ultimate Easy -[![GitHub Activity][commits-shield]][commits] -[![License][license-shield]][license] -[![GitHub Last Commit][last-commit-shield]][commits] -[![ESPHome][esphome-shield]][esphome] -[![Discord][discord-shield]][discord] -[![Buy me an ice-cream][buymeacoffee-shield]][buymeacoffee] + +![GitHub Activity][commits-shield] +![License][license-shield] +![GitHub Last Commit][last-commit-shield] +![ESPHome][esphome-shield] +![Discord][discord-shield] +![Buy me an ice-cream][buymeacoffee-shield] + |  ![TX Ultimate Easy Logo](Assets/Logo.webp) | TX Ultimate Easy provides custom ESPHome firmware for Sonoff TX Ultimate devices. Our project focuses on user-friendly configuration through the Home Assistant UI, eliminating the need for manual YAML editing. Whether you're new to home automation or an experienced user, TX Ultimate Easy makes it simple to manage your device. | From 9bf6eff7d6cb894ce824bcb66b2742350647d0f3 Mon Sep 17 00:00:00 2001 From: Edward Firmo <94725493+edwardtfn@users.noreply.github.com> Date: Fri, 20 Dec 2024 23:59:59 +0100 Subject: [PATCH 36/36] CodeRabbitAI --- ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_leds.yaml | 4 ++-- ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_vibration.yaml | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_leds.yaml b/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_leds.yaml index 573b88b..22374f6 100644 --- a/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_leds.yaml +++ b/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_leds.yaml @@ -863,7 +863,7 @@ script: if (LIGHT_TRANSITION_TURN_ON > 0) call.set_transition_length(LIGHT_TRANSITION_TURN_ON); // in ms if (LIGHT_BRIGHTNESS_TURN_ON > 0 and LIGHT_BRIGHTNESS_TURN_ON <= 100) - call.set_brightness(LIGHT_TRANSITION_TURN_ON / 100.0f); + call.set_brightness(LIGHT_BRIGHTNESS_TURN_ON / 100.0f); call.perform(); } else if (!state and id(gb_lights_1)[light_index]->current_values.is_on()) { ESP_LOGI("core_hw_leds", "Turn-off %s light for Relay %" PRIu8, @@ -887,7 +887,7 @@ script: if (LIGHT_TRANSITION_TURN_ON > 0) call.set_transition_length(LIGHT_TRANSITION_TURN_ON); // in ms if (LIGHT_BRIGHTNESS_TURN_ON > 0 and LIGHT_BRIGHTNESS_TURN_ON <= 100) - call.set_brightness(LIGHT_TRANSITION_TURN_ON / 100.0f); + call.set_brightness(LIGHT_BRIGHTNESS_TURN_ON / 100.0f); call.perform(); } else if (!state and id(gb_lights_2)[light_index]->current_values.is_on()) { ESP_LOGI("core_hw_leds", "Turn-off %s light for Relay %" PRIu8, diff --git a/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_vibration.yaml b/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_vibration.yaml index 570eaf2..67655c1 100644 --- a/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_vibration.yaml +++ b/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_vibration.yaml @@ -12,7 +12,7 @@ #################################################################################################### --- substitutions: - vibration_max_duration: 5s + vibration_max_duration: 2s binary_sensor: - id: bs_vibrating @@ -37,7 +37,6 @@ number: name: Vibrate duration icon: mdi:vibrate unit_of_measurement: ms - # mode: box internal: false entity_category: config platform: template