diff --git a/esphome/components/climate/climate_traits.h b/esphome/components/climate/climate_traits.h index d31de34e24..65cae3a077 100644 --- a/esphome/components/climate/climate_traits.h +++ b/esphome/components/climate/climate_traits.h @@ -147,9 +147,14 @@ class ClimateTraits { void add_supported_fan_mode(ClimateFanMode mode) { this->supported_fan_modes_.insert(mode); } bool supports_fan_mode(ClimateFanMode fan_mode) const { return this->supported_fan_modes_.count(fan_mode); } bool get_supports_fan_modes() const { - return !this->supported_fan_modes_.empty() || - (this->supported_custom_fan_modes_ && !this->supported_custom_fan_modes_->empty()) || - !this->compat_custom_fan_modes_.empty(); // Compat: remove in 2026.11.0 + if (!this->supported_fan_modes_.empty()) { + return true; + } + // Same precedence as get_supported_custom_fan_modes() getter + if (this->supported_custom_fan_modes_) { + return !this->supported_custom_fan_modes_->empty(); + } + return !this->compat_custom_fan_modes_.empty(); // Compat: remove in 2026.11.0 } const ClimateFanModeMask &get_supported_fan_modes() const { return this->supported_fan_modes_; } diff --git a/esphome/components/midea/air_conditioner.cpp b/esphome/components/midea/air_conditioner.cpp index 77bec5c7a2..2a9a5e9902 100644 --- a/esphome/components/midea/air_conditioner.cpp +++ b/esphome/components/midea/air_conditioner.cpp @@ -24,10 +24,22 @@ template void update_property(T &property, const T &value, bool &fla } void AirConditioner::on_status_change() { - // Set frost protection custom preset once when autoconf completes + // Add frost protection custom preset once when autoconf completes (merge, don't overwrite) if (this->base_.getAutoconfStatus() == dudanov::midea::AUTOCONF_OK && this->base_.getCapabilities().supportFrostProtectionPreset() && !this->frost_protection_set_) { - this->set_supported_custom_presets({Constants::FREEZE_PROTECTION}); + auto presets = this->get_traits().get_supported_custom_presets(); + bool found = false; + for (const char *p : presets) { + if (strcmp(p, Constants::FREEZE_PROTECTION) == 0) { + found = true; + break; + } + } + if (!found) { + std::vector merged(presets.begin(), presets.end()); + merged.push_back(Constants::FREEZE_PROTECTION); + this->set_supported_custom_presets(merged); + } this->frost_protection_set_ = true; } bool need_publish = false;