mirror of
https://github.com/esphome/esphome.git
synced 2025-01-03 11:21:43 +01:00
Climate modes COOL and HEAT are auto modes (#1994)
This commit is contained in:
parent
7ae611256a
commit
cdbc146e5d
1 changed files with 11 additions and 9 deletions
|
@ -20,7 +20,12 @@ void PIDClimate::setup() {
|
||||||
restore->to_call(this).perform();
|
restore->to_call(this).perform();
|
||||||
} else {
|
} else {
|
||||||
// restore from defaults, change_away handles those for us
|
// restore from defaults, change_away handles those for us
|
||||||
|
if (supports_heat_() && supports_cool_())
|
||||||
this->mode = climate::CLIMATE_MODE_HEAT_COOL;
|
this->mode = climate::CLIMATE_MODE_HEAT_COOL;
|
||||||
|
else if (supports_cool_())
|
||||||
|
this->mode = climate::CLIMATE_MODE_COOL;
|
||||||
|
else if (supports_heat_())
|
||||||
|
this->mode = climate::CLIMATE_MODE_HEAT;
|
||||||
this->target_temperature = this->default_target_temperature_;
|
this->target_temperature = this->default_target_temperature_;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -41,11 +46,13 @@ climate::ClimateTraits PIDClimate::traits() {
|
||||||
traits.set_supports_current_temperature(true);
|
traits.set_supports_current_temperature(true);
|
||||||
traits.set_supports_two_point_target_temperature(false);
|
traits.set_supports_two_point_target_temperature(false);
|
||||||
|
|
||||||
traits.set_supported_modes({climate::CLIMATE_MODE_OFF, climate::CLIMATE_MODE_HEAT_COOL});
|
traits.set_supported_modes({climate::CLIMATE_MODE_OFF});
|
||||||
if (supports_cool_())
|
if (supports_cool_())
|
||||||
traits.add_supported_mode(climate::CLIMATE_MODE_COOL);
|
traits.add_supported_mode(climate::CLIMATE_MODE_COOL);
|
||||||
if (supports_heat_())
|
if (supports_heat_())
|
||||||
traits.add_supported_mode(climate::CLIMATE_MODE_HEAT);
|
traits.add_supported_mode(climate::CLIMATE_MODE_HEAT);
|
||||||
|
if (supports_heat_() && supports_cool_())
|
||||||
|
traits.add_supported_mode(climate::CLIMATE_MODE_HEAT_COOL);
|
||||||
|
|
||||||
traits.set_supports_action(true);
|
traits.set_supports_action(true);
|
||||||
return traits;
|
return traits;
|
||||||
|
@ -93,13 +100,8 @@ void PIDClimate::write_output_(float value) {
|
||||||
}
|
}
|
||||||
void PIDClimate::handle_non_auto_mode_() {
|
void PIDClimate::handle_non_auto_mode_() {
|
||||||
// in non-auto mode, switch directly to appropriate action
|
// in non-auto mode, switch directly to appropriate action
|
||||||
// - HEAT mode / COOL mode -> Output at ±100%
|
|
||||||
// - OFF mode -> Output at 0%
|
// - OFF mode -> Output at 0%
|
||||||
if (this->mode == climate::CLIMATE_MODE_HEAT) {
|
if (this->mode == climate::CLIMATE_MODE_OFF) {
|
||||||
this->write_output_(1.0);
|
|
||||||
} else if (this->mode == climate::CLIMATE_MODE_COOL) {
|
|
||||||
this->write_output_(-1.0);
|
|
||||||
} else if (this->mode == climate::CLIMATE_MODE_OFF) {
|
|
||||||
this->write_output_(0.0);
|
this->write_output_(0.0);
|
||||||
} else {
|
} else {
|
||||||
assert(false);
|
assert(false);
|
||||||
|
@ -132,7 +134,7 @@ void PIDClimate::update_pid_() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this->mode != climate::CLIMATE_MODE_HEAT_COOL) {
|
if (this->mode == climate::CLIMATE_MODE_OFF) {
|
||||||
this->handle_non_auto_mode_();
|
this->handle_non_auto_mode_();
|
||||||
} else {
|
} else {
|
||||||
this->write_output_(value);
|
this->write_output_(value);
|
||||||
|
|
Loading…
Reference in a new issue