From 1df58e162f258a3e733703043f758cb3a980d34f Mon Sep 17 00:00:00 2001 From: Edward Firmo <94725493+edwardtfn@users.noreply.github.com> Date: Fri, 8 Aug 2025 07:37:52 +0200 Subject: [PATCH] Set `min_version` to ESPHome 2025.8.0 --- .../TX-Ultimate-Easy-ESPHome_core_common.yaml | 1 + ...TX-Ultimate-Easy-ESPHome_core_hw_leds.yaml | 20 ++++++++++++-- ...imate-Easy-ESPHome_standard_hw_relays.yaml | 26 +++++++++---------- .../tx_ultimate_easy_touch.cpp | 5 ++-- 4 files changed, 35 insertions(+), 17 deletions(-) diff --git a/ESPHome/TX-Ultimate-Easy-ESPHome_core_common.yaml b/ESPHome/TX-Ultimate-Easy-ESPHome_core_common.yaml index ace3829..ca66660 100644 --- a/ESPHome/TX-Ultimate-Easy-ESPHome_core_common.yaml +++ b/ESPHome/TX-Ultimate-Easy-ESPHome_core_common.yaml @@ -71,6 +71,7 @@ esphome: name: ${name} friendly_name: ${friendly_name} comment: TX Ultimate Easy + min_version: 2025.8.0-dev project: name: "edwardtfn.tx_ultimate_easy" version: ${version} diff --git a/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_leds.yaml b/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_leds.yaml index 95679e3..c5deead 100644 --- a/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_leds.yaml +++ b/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_leds.yaml @@ -29,8 +29,8 @@ substitutions: LIGHT_SIDES_RESTORE_MODE: RESTORE_DEFAULT_OFF LIGHT_INDIVIDUAL_RESTORE_MODE: RESTORE_DEFAULT_OFF - LIGHT_ATTRS_DEFAULT: '0x64FFFFFF' # brightness=100, RGB=255,255,255 - LIGHT_DUAL_ATTRS_DEFAULT: '0x64FFFFFF64FFFFFF' # Both lights: brightness=100, RGB=255,255,255 + LIGHT_ATTRS_DEFAULT: '0x64FFFFFF' # brightness=100, RGB=255,255,255 + LIGHT_DUAL_ATTRS_DEFAULT: '0x0064FFFFFF64FFFFFF' # Both lights: brightness=100, RGB=255,255,255 TAG_CORE_HW_LEDS: core.hw.leds @@ -562,6 +562,14 @@ script: attr_global_ptr: uint32_t* then: - lambda: |- + if (!light_ptr) { + ESP_LOGE("${TAG_CORE_HW_LEDS}", "Invalid light pointer"); + return; + } + if (!attr_global_ptr) { + ESP_LOGE("${TAG_CORE_HW_LEDS}", "Invalid attributes pointer"); + return; + } auto current = light_ptr->current_values; tx_ultimate_easy::LightAttributes attrs = { .brightness = uint8_t(current.get_brightness() * 100.0f), @@ -582,6 +590,14 @@ script: group_index: uint8_t # 1 or 2 (which group within the dual pack) then: - lambda: |- + if (!light_ptr) { + ESP_LOGE("${TAG_CORE_HW_LEDS}", "Invalid light pointer"); + return; + } + if (!attr_global_ptr) { + ESP_LOGE("${TAG_CORE_HW_LEDS}", "Invalid attributes pointer"); + return; + } auto current = light_ptr->current_values; tx_ultimate_easy::LightAttributes new_attrs = { .brightness = uint8_t(current.get_brightness() * 100.0f), diff --git a/ESPHome/TX-Ultimate-Easy-ESPHome_standard_hw_relays.yaml b/ESPHome/TX-Ultimate-Easy-ESPHome_standard_hw_relays.yaml index 1d24dc5..41b738d 100644 --- a/ESPHome/TX-Ultimate-Easy-ESPHome_standard_hw_relays.yaml +++ b/ESPHome/TX-Ultimate-Easy-ESPHome_standard_hw_relays.yaml @@ -16,7 +16,12 @@ substitutions: RELAY_MODE_TEXT_LIGHT: "Light" RELAY_MODE_TEXT_NOT_USED: "Not in use" - LIGHT_RELAYS_RESTORE_MODE: ALWAYS_OFF + # You shouldn't change the restore mode as there is a custom restoring engine based on globals. + # The reason of a custom engine is to address an issue where NVS space was exceeded causing saving/restoring issues + RELAYS_LIGHT_RESTORE_MODE: ALWAYS_OFF + RELAYS_LIGHT_PARTITION_RESTORE_MODE: ALWAYS_OFF + RELAYS_EXPOSE_LEDS_TO_HA_RESTORE_MODE: ALWAYS_OFF + RELAYS_SWITCH_RESTORE_MODE: ALWAYS_OFF TAG_STD_HW_RELAYS: std.hw.relays @@ -25,11 +30,6 @@ esphome: build_flags: - -D TX_ULTIMATE_EASY_STANDARD_HW_RELAYS -external_components: - - source: github://pr#10105 # To-do: remove after this PR is released - components: [switch] - refresh: 1h - globals: - &global_attr_dual_light id: attr_light_rl_1_1_both # 1-gang: relay 1, both groups @@ -113,7 +113,7 @@ light: output: output_relay_1 platform: binary internal: true - restore_mode: ${LIGHT_RELAYS_RESTORE_MODE} + restore_mode: ${RELAYS_LIGHT_RESTORE_MODE} on_turn_on: then: - if: @@ -194,7 +194,7 @@ light: internal: true disabled_by_default: false default_transition_length: ${default_transition_length} - restore_mode: ALWAYS_OFF + restore_mode: ${RELAYS_LIGHT_PARTITION_RESTORE_MODE} segments: - id: light_full from: 9 @@ -1522,7 +1522,7 @@ switch: - id: sw_expose_relays_leds_to_ha name: Expose Relay's LEDs to Home Assistant platform: template - restore_mode: ALWAYS_OFF + restore_mode: ${RELAYS_EXPOSE_LEDS_TO_HA_RESTORE_MODE} optimistic: true internal: false entity_category: config @@ -1545,7 +1545,7 @@ switch: name: Relay 1 output: output_relay_1 platform: output - restore_mode: ALWAYS_OFF + restore_mode: ${RELAYS_SWITCH_RESTORE_MODE} internal: true on_turn_on: then: @@ -1571,7 +1571,7 @@ switch: name: Relay 2 output: output_relay_2 platform: output - restore_mode: ALWAYS_OFF + restore_mode: ${RELAYS_SWITCH_RESTORE_MODE} internal: true on_turn_on: then: @@ -1597,7 +1597,7 @@ switch: name: Relay 3 output: output_relay_3 platform: output - restore_mode: ALWAYS_OFF + restore_mode: ${RELAYS_SWITCH_RESTORE_MODE} internal: true on_turn_on: then: @@ -1623,7 +1623,7 @@ switch: name: Relay 4 output: output_relay_4 platform: output - restore_mode: ALWAYS_OFF + restore_mode: ${RELAYS_SWITCH_RESTORE_MODE} internal: true on_turn_on: then: diff --git a/components/tx_ultimate_easy/tx_ultimate_easy_touch.cpp b/components/tx_ultimate_easy/tx_ultimate_easy_touch.cpp index 7a4ce70..7c1b4d3 100644 --- a/components/tx_ultimate_easy/tx_ultimate_easy_touch.cpp +++ b/components/tx_ultimate_easy/tx_ultimate_easy_touch.cpp @@ -74,8 +74,9 @@ namespace esphome { if (this->gang_count_ == 1) return 1; - // Calculate button number Change to round up instead of truncate (integer division) - const uint8_t width = (TOUCH_MAX_POSITION + gang_count_) / this->gang_count_; // Width of each button region + // Calculate button width (rounds up to ensure full coverage) + const uint8_t width = + (TOUCH_MAX_POSITION + this->gang_count_) / this->gang_count_; // Width of each button region if (width < 1) // Invalid width - and prevents division by zero return 0; const uint8_t button = std::min(