mirror of
https://github.com/esphome/esphome.git
synced 2024-12-22 13:34:54 +01:00
Bang bang climate new mode meanings (#1996)
This commit is contained in:
parent
cc9f0b3f47
commit
551e9c6111
1 changed files with 10 additions and 8 deletions
|
@ -21,7 +21,12 @@ void BangBangClimate::setup() {
|
|||
restore->to_call(this).perform();
|
||||
} else {
|
||||
// restore from defaults, change_away handles those for us
|
||||
this->mode = climate::CLIMATE_MODE_HEAT_COOL;
|
||||
if (supports_cool_ && supports_heat_)
|
||||
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->change_away_(false);
|
||||
}
|
||||
}
|
||||
|
@ -43,12 +48,13 @@ climate::ClimateTraits BangBangClimate::traits() {
|
|||
traits.set_supports_current_temperature(true);
|
||||
traits.set_supported_modes({
|
||||
climate::CLIMATE_MODE_OFF,
|
||||
climate::CLIMATE_MODE_HEAT_COOL,
|
||||
});
|
||||
if (supports_cool_)
|
||||
traits.add_supported_mode(climate::CLIMATE_MODE_COOL);
|
||||
if (supports_heat_)
|
||||
traits.add_supported_mode(climate::CLIMATE_MODE_HEAT);
|
||||
if (supports_cool_ && supports_heat_)
|
||||
traits.add_supported_mode(climate::CLIMATE_MODE_HEAT_COOL);
|
||||
traits.set_supports_two_point_target_temperature(true);
|
||||
if (supports_away_)
|
||||
traits.set_supported_presets({
|
||||
|
@ -59,12 +65,8 @@ climate::ClimateTraits BangBangClimate::traits() {
|
|||
return traits;
|
||||
}
|
||||
void BangBangClimate::compute_state_() {
|
||||
if (this->mode != climate::CLIMATE_MODE_HEAT_COOL) {
|
||||
// in non-auto mode, switch directly to appropriate action
|
||||
// - HEAT mode -> HEATING action
|
||||
// - COOL mode -> COOLING action
|
||||
// - OFF mode -> OFF action (not IDLE!)
|
||||
this->switch_to_action_(static_cast<climate::ClimateAction>(this->mode));
|
||||
if (this->mode == climate::CLIMATE_MODE_OFF) {
|
||||
this->switch_to_action_(climate::CLIMATE_ACTION_OFF);
|
||||
return;
|
||||
}
|
||||
if (isnan(this->current_temperature) || isnan(this->target_temperature_low) || isnan(this->target_temperature_high)) {
|
||||
|
|
Loading…
Reference in a new issue