update light logic
This commit is contained in:
@@ -94,26 +94,27 @@ 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 {
|
||||
// power on hood first
|
||||
if (this->speed==0 && !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) {
|
||||
// request light on and fan off, so power on hood first
|
||||
button_press(pin_power, true);
|
||||
} else if (this->power) {
|
||||
// press light button to toggle
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Components are required to dump their configuration using ESP_LOGCONFIG in
|
||||
@@ -240,6 +241,10 @@ void Hauslane::set_state(bool set_light, uint8_t set_speed) {
|
||||
this->send_fan_speed(set_speed);
|
||||
}
|
||||
}
|
||||
if (!this->power && (set_speed > 0 || set_light)) {
|
||||
// set power to on if light or fan are on
|
||||
this->power = true;
|
||||
}
|
||||
}
|
||||
|
||||
// custom component API commands
|
||||
|
||||
Reference in New Issue
Block a user