From 6343e6eb4ab83dc80a71b9abf5433a2889cd2d43 Mon Sep 17 00:00:00 2001 From: Edward Firmo <94725493+edwardtfn@users.noreply.github.com> Date: Mon, 23 Dec 2024 18:21:32 +0100 Subject: [PATCH 1/3] Restore light state on boot Trying to solve #47 --- ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_leds.yaml | 5 +++++ ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_relays.yaml | 1 + 2 files changed, 6 insertions(+) diff --git a/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_leds.yaml b/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_leds.yaml index a044bb5..90d8fb2 100644 --- a/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_leds.yaml +++ b/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_leds.yaml @@ -44,6 +44,7 @@ light: # method: esp32_rmt num_leds: 32 pin: GPIO13 + restore_mode: RESTORE_DEFAULT_OFF # Those lights are available based on the model selections - &light_partition_with_effects @@ -52,6 +53,7 @@ light: platform: partition default_transition_length: ${default_transition_length} internal: true + restore_mode: RESTORE_DEFAULT_OFF effects: - addressable_rainbow: name: "Rainbow" @@ -184,6 +186,8 @@ light: platform: partition disabled_by_default: true default_transition_length: ${default_transition_length} + restore_mode: RESTORE_DEFAULT_OFF + segments: - id: light_full from: 0 @@ -417,6 +421,7 @@ light: platform: partition internal: true default_transition_length: ${default_transition_length} + restore_mode: RESTORE_DEFAULT_OFF segments: - id: light_full from: 9 diff --git a/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_relays.yaml b/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_relays.yaml index dc1bce0..91ca3a1 100644 --- a/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_relays.yaml +++ b/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_relays.yaml @@ -29,6 +29,7 @@ light: output: output_relay_1 platform: binary internal: true + restore_mode: RESTORE_DEFAULT_OFF on_turn_on: then: - if: From 248f7e9cd8f4b4c9b1a791e9b229c698ee26eaf5 Mon Sep 17 00:00:00 2001 From: Edward Firmo <94725493+edwardtfn@users.noreply.github.com> Date: Mon, 23 Dec 2024 18:28:58 +0100 Subject: [PATCH 2/3] Use substitutions instead --- ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_leds.yaml | 14 +++++++++----- .../TX-Ultimate-Easy-ESPHome_core_hw_relays.yaml | 11 ++++++----- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_leds.yaml b/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_leds.yaml index 90d8fb2..cc5e0fc 100644 --- a/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_leds.yaml +++ b/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_leds.yaml @@ -25,6 +25,11 @@ substitutions: LIGHT_TRANSITION_TURN_OFF: '0' # Transition time in msec LIGHT_BRIGHTNESS_TURN_ON: '0' # Brightness (1 to 100%, 0 to not set it) + LIGHT_FULL_RESTORE_MODE: RESTORE_DEFAULT_OFF + LIGHT_SIDES_RESTORE_MODE: RESTORE_DEFAULT_OFF + LIGHT_INDIVIDUAL_RESTORE_MODE: RESTORE_DEFAULT_OFF + LIGHT_RELAYS_RESTORE_MODE: RESTORE_DEFAULT_OFF + globals: - id: gb_lights_1 type: std::vector @@ -44,7 +49,7 @@ light: # method: esp32_rmt num_leds: 32 pin: GPIO13 - restore_mode: RESTORE_DEFAULT_OFF + restore_mode: ${LIGHT_FULL_RESTORE_MODE} # Those lights are available based on the model selections - &light_partition_with_effects @@ -53,7 +58,7 @@ light: platform: partition default_transition_length: ${default_transition_length} internal: true - restore_mode: RESTORE_DEFAULT_OFF + restore_mode: ${LIGHT_SIDES_RESTORE_MODE} effects: - addressable_rainbow: name: "Rainbow" @@ -186,8 +191,7 @@ light: platform: partition disabled_by_default: true default_transition_length: ${default_transition_length} - restore_mode: RESTORE_DEFAULT_OFF - + restore_mode: ${LIGHT_FULL_RESTORE_MODE} segments: - id: light_full from: 0 @@ -421,7 +425,7 @@ light: platform: partition internal: true default_transition_length: ${default_transition_length} - restore_mode: RESTORE_DEFAULT_OFF + restore_mode: ${LIGHT_RELAYS_RESTORE_MODE} segments: - id: light_full from: 9 diff --git a/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_relays.yaml b/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_relays.yaml index 91ca3a1..d9a163e 100644 --- a/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_relays.yaml +++ b/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_relays.yaml @@ -15,6 +15,7 @@ substitutions: RELAY_MODE_TEXT_SWITCH: "Switch" RELAY_MODE_TEXT_LIGHT: "Light" RELAY_MODE_TEXT_NOT_USED: "Not in use" + RELAY_RESTORE_MODE: RESTORE_DEFAULT_OFF globals: - id: boot_initialization_relays @@ -29,7 +30,7 @@ light: output: output_relay_1 platform: binary internal: true - restore_mode: RESTORE_DEFAULT_OFF + restore_mode: ${RELAY_RESTORE_MODE} on_turn_on: then: - if: @@ -350,7 +351,7 @@ switch: name: Relay 1 output: output_relay_1 platform: output - restore_mode: RESTORE_DEFAULT_OFF + restore_mode: ${RELAY_RESTORE_MODE} internal: true on_turn_on: then: @@ -373,7 +374,7 @@ switch: name: Relay 2 output: output_relay_2 platform: output - restore_mode: RESTORE_DEFAULT_OFF + restore_mode: ${RELAY_RESTORE_MODE} internal: true on_turn_on: then: @@ -396,7 +397,7 @@ switch: name: Relay 3 output: output_relay_3 platform: output - restore_mode: RESTORE_DEFAULT_OFF + restore_mode: ${RELAY_RESTORE_MODE} internal: true on_turn_on: then: @@ -419,7 +420,7 @@ switch: name: Relay 4 output: output_relay_4 platform: output - restore_mode: RESTORE_DEFAULT_OFF + restore_mode: ${RELAY_RESTORE_MODE} internal: true on_turn_on: then: From 6230e31323628be07fce7fb33301cf5e4e7dc296 Mon Sep 17 00:00:00 2001 From: Edward Firmo <94725493+edwardtfn@users.noreply.github.com> Date: Mon, 23 Dec 2024 18:34:05 +0100 Subject: [PATCH 3/3] Fix inconsistent restore mode variable usage As suggested by CodeRabbitAI --- ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_leds.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_leds.yaml b/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_leds.yaml index cc5e0fc..3b20c0b 100644 --- a/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_leds.yaml +++ b/ESPHome/TX-Ultimate-Easy-ESPHome_core_hw_leds.yaml @@ -191,7 +191,7 @@ light: platform: partition disabled_by_default: true default_transition_length: ${default_transition_length} - restore_mode: ${LIGHT_FULL_RESTORE_MODE} + restore_mode: ${LIGHT_INDIVIDUAL_RESTORE_MODE} segments: - id: light_full from: 0