mirror of
https://github.com/esphome/esphome.git
synced 2026-06-24 11:23:19 +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 {
|
||||
// Fallback to active state calc based on temp and hysteresis
|
||||
const float temp_diff = this->target_temperature - this->current_temperature;
|
||||
if (std::abs(temp_diff) > this->hysteresis_) {
|
||||
if (this->supports_heat_ && temp_diff > 0) {
|
||||
target_action = climate::CLIMATE_ACTION_HEATING;
|
||||
this->mode = climate::CLIMATE_MODE_HEAT;
|
||||
} else if (this->supports_cool_ && temp_diff < 0) {
|
||||
target_action = climate::CLIMATE_ACTION_COOLING;
|
||||
this->mode = climate::CLIMATE_MODE_COOL;
|
||||
}
|
||||
if ((this->supports_heat_ && temp_diff >= this->hysteresis_) ||
|
||||
(this->action == climate::CLIMATE_ACTION_HEATING && temp_diff > 0)) {
|
||||
target_action = climate::CLIMATE_ACTION_HEATING;
|
||||
this->mode = climate::CLIMATE_MODE_HEAT;
|
||||
} else if ((this->supports_cool_ && temp_diff <= -this->hysteresis_) ||
|
||||
(this->action == climate::CLIMATE_ACTION_COOLING && temp_diff < 0)) {
|
||||
target_action = climate::CLIMATE_ACTION_COOLING;
|
||||
this->mode = climate::CLIMATE_MODE_COOL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user