Skip to content

Commit

Permalink
Fix PID climate breaks when restoring old modes (esphome#2086)
Browse files Browse the repository at this point in the history
  • Loading branch information
OttoWinter committed Aug 4, 2021
1 parent 3ffa59f commit 29f0508
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 12 deletions.
13 changes: 2 additions & 11 deletions esphome/components/pid/pid_climate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ void PIDClimate::control(const climate::ClimateCall &call) {

// If switching to off mode, set output immediately
if (this->mode == climate::CLIMATE_MODE_OFF)
this->handle_non_auto_mode_();
this->write_output_(0.0f);

this->publish_state();
}
Expand Down Expand Up @@ -98,15 +98,6 @@ void PIDClimate::write_output_(float value) {
}
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_() {
float value;
if (isnan(this->current_temperature) || isnan(this->target_temperature)) {
Expand Down Expand Up @@ -135,7 +126,7 @@ void PIDClimate::update_pid_() {
}

if (this->mode == climate::CLIMATE_MODE_OFF) {
this->handle_non_auto_mode_();
this->write_output_(0.0);
} else {
this->write_output_(value);
}
Expand Down
1 change: 0 additions & 1 deletion esphome/components/pid/pid_climate.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ class PIDClimate : public climate::Climate, public Component {
bool supports_heat_() const { return this->heat_output_ != nullptr; }

void write_output_(float value);
void handle_non_auto_mode_();

/// The sensor used for getting the current temperature
sensor::Sensor *sensor_;
Expand Down

0 comments on commit 29f0508

Please sign in to comment.