From 32eeaa091da473d36044eb9f30b330b9deced4e2 Mon Sep 17 00:00:00 2001 From: kenji Date: Wed, 2 Jul 2025 19:34:24 -0400 Subject: [PATCH] update light logic --- components/hauslane/hauslane.cpp | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/components/hauslane/hauslane.cpp b/components/hauslane/hauslane.cpp index 40a1e8e..4e57da6 100644 --- a/components/hauslane/hauslane.cpp +++ b/components/hauslane/hauslane.cpp @@ -94,23 +94,24 @@ void Hauslane::loop() { button_press(pin_down, true); } } else if (this->light_cur != this->light_target) { - if (this->power) { - // press light button - button_press(pin_light, true); - } else { + if (this->power && !this->light_target) { + // request light turn off and fan is off, so simply hit power button + button_press(pin_power, true); + } else if (!this->power && this->light_target) { // power on hood first button_press(pin_power, true); + } else if (this->power) { + // press light button + button_press(pin_light, true); } } else { // target already met, so reset flag this->meet_target=false; } - } else if (this->speed==0 && !this->light_cur) { + } else if (this->speed==0 && !this->light_cur && this->power) { // reset power flag - if(this->power) { - this->power=false; - ESP_LOGD(TAG, "Hood power: %d", this->power); - } + this->power=false; + ESP_LOGD(TAG, "Hood power: %d", this->power); } } }