From d6d37f1e27692326abc080f2e08833eb51b692ba Mon Sep 17 00:00:00 2001 From: kenji Date: Mon, 7 Jul 2025 08:27:49 -0400 Subject: [PATCH] sync target light and fan states to current state if changed by buttons to prevent unexpected automated changes --- components/hauslane/hauslane.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/components/hauslane/hauslane.cpp b/components/hauslane/hauslane.cpp index 082af72..6f44562 100644 --- a/components/hauslane/hauslane.cpp +++ b/components/hauslane/hauslane.cpp @@ -225,6 +225,10 @@ void Hauslane::set_state(bool set_light, uint8_t set_speed) { // save current state of light in memory ESP_LOGD(TAG, "Received light state: %d", set_light); this->light_cur = set_light; + if (!this->meet_target) { + // sync target light state if changed by button press + this->light_target = set_light; + } // send light state to API if it is active if (this->send_light_state) { ESP_LOGD(TAG, "Sending new light state."); @@ -235,6 +239,10 @@ void Hauslane::set_state(bool set_light, uint8_t set_speed) { // save current state of fan in memory ESP_LOGD(TAG, "Received fan speed: %d", set_speed); this->speed = set_speed; + if (!this->meet_target) { + // sync target fan state if changed by button press + this->speed_target = set_speed; + } // send fan state to API if it is active if (this->send_fan_speed) { ESP_LOGD(TAG,"Sending new fan speed.");