mirror of
https://github.com/esphome/esphome.git
synced 2024-12-19 16:07:47 +01:00
Fix PID climate breaks when restoring old modes (#2086)
This commit is contained in:
parent
3ffa59f0cd
commit
29f0508dc2
@ -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);
|
||||||
}
|
}
|
||||||
|
@ -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_;
|
||||||
|
Loading…
Reference in New Issue
Block a user