mirror of
https://github.com/esphome/esphome.git
synced 2025-11-01 23:51:47 +00:00
simplify
This commit is contained in:
@@ -628,7 +628,7 @@ bool Climate::set_custom_fan_mode_(const char *mode) {
|
|||||||
}
|
}
|
||||||
// Mode not found in supported custom modes, clear it if currently set
|
// Mode not found in supported custom modes, clear it if currently set
|
||||||
if (this->has_custom_fan_mode()) {
|
if (this->has_custom_fan_mode()) {
|
||||||
this->custom_fan_mode_ = nullptr;
|
this->clear_custom_fan_mode_();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@@ -648,7 +648,7 @@ bool Climate::set_custom_preset_(const char *preset) {
|
|||||||
}
|
}
|
||||||
// Preset not found in supported custom presets, clear it if currently set
|
// Preset not found in supported custom presets, clear it if currently set
|
||||||
if (this->has_custom_preset()) {
|
if (this->has_custom_preset()) {
|
||||||
this->custom_preset_ = nullptr;
|
this->clear_custom_preset_();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -28,14 +28,14 @@ class DemoClimate : public climate::Climate, public Component {
|
|||||||
this->mode = climate::CLIMATE_MODE_AUTO;
|
this->mode = climate::CLIMATE_MODE_AUTO;
|
||||||
this->action = climate::CLIMATE_ACTION_COOLING;
|
this->action = climate::CLIMATE_ACTION_COOLING;
|
||||||
this->fan_mode = climate::CLIMATE_FAN_HIGH;
|
this->fan_mode = climate::CLIMATE_FAN_HIGH;
|
||||||
this->custom_preset = {"My Preset"};
|
this->set_custom_preset_("My Preset");
|
||||||
break;
|
break;
|
||||||
case DemoClimateType::TYPE_3:
|
case DemoClimateType::TYPE_3:
|
||||||
this->current_temperature = 21.5;
|
this->current_temperature = 21.5;
|
||||||
this->target_temperature_low = 21.0;
|
this->target_temperature_low = 21.0;
|
||||||
this->target_temperature_high = 22.5;
|
this->target_temperature_high = 22.5;
|
||||||
this->mode = climate::CLIMATE_MODE_HEAT_COOL;
|
this->mode = climate::CLIMATE_MODE_HEAT_COOL;
|
||||||
this->custom_fan_mode = {"Auto Low"};
|
this->set_custom_fan_mode_("Auto Low");
|
||||||
this->swing_mode = climate::CLIMATE_SWING_HORIZONTAL;
|
this->swing_mode = climate::CLIMATE_SWING_HORIZONTAL;
|
||||||
this->preset = climate::CLIMATE_PRESET_AWAY;
|
this->preset = climate::CLIMATE_PRESET_AWAY;
|
||||||
break;
|
break;
|
||||||
@@ -58,23 +58,19 @@ class DemoClimate : public climate::Climate, public Component {
|
|||||||
this->target_temperature_high = *call.get_target_temperature_high();
|
this->target_temperature_high = *call.get_target_temperature_high();
|
||||||
}
|
}
|
||||||
if (call.get_fan_mode().has_value()) {
|
if (call.get_fan_mode().has_value()) {
|
||||||
this->fan_mode = *call.get_fan_mode();
|
this->set_fan_mode_(*call.get_fan_mode());
|
||||||
this->custom_fan_mode.reset();
|
|
||||||
}
|
}
|
||||||
if (call.get_swing_mode().has_value()) {
|
if (call.get_swing_mode().has_value()) {
|
||||||
this->swing_mode = *call.get_swing_mode();
|
this->swing_mode = *call.get_swing_mode();
|
||||||
}
|
}
|
||||||
if (call.get_custom_fan_mode().has_value()) {
|
if (call.get_custom_fan_mode().has_value()) {
|
||||||
this->custom_fan_mode = *call.get_custom_fan_mode();
|
this->set_custom_fan_mode_(call.get_custom_fan_mode()->c_str());
|
||||||
this->fan_mode.reset();
|
|
||||||
}
|
}
|
||||||
if (call.get_preset().has_value()) {
|
if (call.get_preset().has_value()) {
|
||||||
this->preset = *call.get_preset();
|
this->set_preset_(*call.get_preset());
|
||||||
this->custom_preset.reset();
|
|
||||||
}
|
}
|
||||||
if (call.get_custom_preset().has_value()) {
|
if (call.get_custom_preset().has_value()) {
|
||||||
this->custom_preset = *call.get_custom_preset();
|
this->set_custom_preset_(call.get_custom_preset()->c_str());
|
||||||
this->preset.reset();
|
|
||||||
}
|
}
|
||||||
this->publish_state();
|
this->publish_state();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user