mirror of
https://github.com/esphome/esphome.git
synced 2026-06-24 13:45:15 +00:00
[tuya] Fixed hysteresis bug for Tuya climate (#16832)
Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com>
This commit is contained in:
@@ -513,14 +513,14 @@ void TuyaClimate::compute_state_() {
|
|||||||
} else {
|
} else {
|
||||||
// Fallback to active state calc based on temp and hysteresis
|
// Fallback to active state calc based on temp and hysteresis
|
||||||
const float temp_diff = this->target_temperature - this->current_temperature;
|
const float temp_diff = this->target_temperature - this->current_temperature;
|
||||||
if (std::abs(temp_diff) > this->hysteresis_) {
|
if ((this->supports_heat_ && temp_diff >= this->hysteresis_) ||
|
||||||
if (this->supports_heat_ && temp_diff > 0) {
|
(this->action == climate::CLIMATE_ACTION_HEATING && temp_diff > 0)) {
|
||||||
target_action = climate::CLIMATE_ACTION_HEATING;
|
target_action = climate::CLIMATE_ACTION_HEATING;
|
||||||
this->mode = climate::CLIMATE_MODE_HEAT;
|
this->mode = climate::CLIMATE_MODE_HEAT;
|
||||||
} else if (this->supports_cool_ && temp_diff < 0) {
|
} else if ((this->supports_cool_ && temp_diff <= -this->hysteresis_) ||
|
||||||
target_action = climate::CLIMATE_ACTION_COOLING;
|
(this->action == climate::CLIMATE_ACTION_COOLING && temp_diff < 0)) {
|
||||||
this->mode = climate::CLIMATE_MODE_COOL;
|
target_action = climate::CLIMATE_ACTION_COOLING;
|
||||||
}
|
this->mode = climate::CLIMATE_MODE_COOL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user