Fix PID climate breaks when restoring old modes (#2086)

This commit is contained in:
Otto Winter 2021-07-28 21:23:41 +02:00 committed by Otto winter
parent 3ffa59f0cd
commit 29f0508dc2
No known key found for this signature in database
GPG key ID: 48ED2DDB96D7682C
2 changed files with 2 additions and 12 deletions

View file

@ -37,7 +37,7 @@ void PIDClimate::control(const climate::ClimateCall &call) {
// If switching to off mode, set output immediately // If switching to off mode, set output immediately
if (this->mode == climate::CLIMATE_MODE_OFF) if (this->mode == climate::CLIMATE_MODE_OFF)
this->handle_non_auto_mode_(); this->write_output_(0.0f);
this->publish_state(); this->publish_state();
} }
@ -98,15 +98,6 @@ void PIDClimate::write_output_(float value) {
} }
this->pid_computed_callback_.call(); this->pid_computed_callback_.call();
} }
void PIDClimate::handle_non_auto_mode_() {
// in non-auto mode, switch directly to appropriate action
// - OFF mode -> Output at 0%
if (this->mode == climate::CLIMATE_MODE_OFF) {
this->write_output_(0.0);
} else {
assert(false);
}
}
void PIDClimate::update_pid_() { void PIDClimate::update_pid_() {
float value; float value;
if (isnan(this->current_temperature) || isnan(this->target_temperature)) { if (isnan(this->current_temperature) || isnan(this->target_temperature)) {
@ -135,7 +126,7 @@ void PIDClimate::update_pid_() {
} }
if (this->mode == climate::CLIMATE_MODE_OFF) { if (this->mode == climate::CLIMATE_MODE_OFF) {
this->handle_non_auto_mode_(); this->write_output_(0.0);
} else { } else {
this->write_output_(value); this->write_output_(value);
} }

View file

@ -56,7 +56,6 @@ class PIDClimate : public climate::Climate, public Component {
bool supports_heat_() const { return this->heat_output_ != nullptr; } bool supports_heat_() const { return this->heat_output_ != nullptr; }
void write_output_(float value); void write_output_(float value);
void handle_non_auto_mode_();
/// The sensor used for getting the current temperature /// The sensor used for getting the current temperature
sensor::Sensor *sensor_; sensor::Sensor *sensor_;