Skip to content

Commit 228038a

Browse files
committed
Fix relay indicator LED state inconsistency
Use global relay state variables (relay_X_state) instead of switch state when transitioning light modes from disabled. This ensures consistent state management across all code paths and prevents indicator LEDs from showing incorrect states or swapping between relays.
1 parent cb8c267 commit 228038a

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

ESPHome/TX-Ultimate-Easy-ESPHome_hw_relays.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -767,7 +767,7 @@ select:
767767
// Transitioning FROM Disabled - update lights based on relay state
768768
ESP_LOGI("${TAG_HW_RELAYS}",
769769
"Relay 1 light mode changed from ${LIGHT_MODE_DISABLED_TEXT} - updating lights");
770-
bool relay_state = id(sw_relay_1).state;
770+
bool relay_state = id(relay_1_state);
771771
if (current_mode == "${LIGHT_MODE_BOTTOM_OR_LEFT_TEXT}" || current_mode == "${LIGHT_MODE_BOTH_TEXT}") {
772772
id(light_set_state)->execute(1, 0, relay_state);
773773
}
@@ -825,7 +825,7 @@ select:
825825
// Transitioning FROM Disabled - update lights based on relay state
826826
ESP_LOGI("${TAG_HW_RELAYS}",
827827
"Relay 2 light mode changed from ${LIGHT_MODE_DISABLED_TEXT} - updating lights");
828-
bool relay_state = id(sw_relay_2).state;
828+
bool relay_state = id(relay_2_state);
829829
if (current_mode == "${LIGHT_MODE_BOTTOM_OR_LEFT_TEXT}" || current_mode == "${LIGHT_MODE_BOTH_TEXT}") {
830830
id(light_set_state)->execute(1, 1, relay_state);
831831
}
@@ -883,7 +883,7 @@ select:
883883
// Transitioning FROM Disabled - update lights based on relay state
884884
ESP_LOGI("${TAG_HW_RELAYS}",
885885
"Relay 3 light mode changed from ${LIGHT_MODE_DISABLED_TEXT} - updating lights");
886-
bool relay_state = id(sw_relay_3).state;
886+
bool relay_state = id(relay_3_state);
887887
if (current_mode == "${LIGHT_MODE_BOTTOM_OR_LEFT_TEXT}" || current_mode == "${LIGHT_MODE_BOTH_TEXT}") {
888888
id(light_set_state)->execute(1, 2, relay_state);
889889
}
@@ -939,7 +939,7 @@ select:
939939
} else if (previous_mode == "${LIGHT_MODE_DISABLED_TEXT}" && current_mode != "${LIGHT_MODE_DISABLED_TEXT}") {
940940
// Transitioning FROM Disabled - update lights based on relay state
941941
ESP_LOGI("${TAG_HW_RELAYS}", "Relay 4 light mode changed from ${LIGHT_MODE_DISABLED_TEXT} - updating lights");
942-
bool relay_state = id(sw_relay_4).state;
942+
bool relay_state = id(relay_4_state);
943943
if (current_mode == "${LIGHT_MODE_BOTTOM_OR_LEFT_TEXT}" || current_mode == "${LIGHT_MODE_BOTH_TEXT}") {
944944
id(light_set_state)->execute(1, 3, relay_state);
945945
}

0 commit comments

Comments
 (0)