sync target light and fan states to current state if changed by buttons to prevent unexpected automated changes
This commit is contained in:
@@ -225,6 +225,10 @@ void Hauslane::set_state(bool set_light, uint8_t set_speed) {
|
|||||||
// save current state of light in memory
|
// save current state of light in memory
|
||||||
ESP_LOGD(TAG, "Received light state: %d", set_light);
|
ESP_LOGD(TAG, "Received light state: %d", set_light);
|
||||||
this->light_cur = 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
|
// send light state to API if it is active
|
||||||
if (this->send_light_state) {
|
if (this->send_light_state) {
|
||||||
ESP_LOGD(TAG, "Sending new 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
|
// save current state of fan in memory
|
||||||
ESP_LOGD(TAG, "Received fan speed: %d", set_speed);
|
ESP_LOGD(TAG, "Received fan speed: %d", set_speed);
|
||||||
this->speed = 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
|
// send fan state to API if it is active
|
||||||
if (this->send_fan_speed) {
|
if (this->send_fan_speed) {
|
||||||
ESP_LOGD(TAG,"Sending new fan speed.");
|
ESP_LOGD(TAG,"Sending new fan speed.");
|
||||||
|
|||||||
Reference in New Issue
Block a user