diff --git a/esphome/components/bedjet/climate/bedjet_climate.cpp b/esphome/components/bedjet/climate/bedjet_climate.cpp index a17407f08f..88ed902a11 100644 --- a/esphome/components/bedjet/climate/bedjet_climate.cpp +++ b/esphome/components/bedjet/climate/bedjet_climate.cpp @@ -61,6 +61,15 @@ void BedJetClimate::dump_config() { } void BedJetClimate::setup() { + // Set custom modes once during setup — stored on Climate base class, wired via get_traits() + this->set_supported_custom_fan_modes(BEDJET_FAN_STEP_NAMES); + this->set_supported_custom_presets({ + this->heating_mode_ == HEAT_MODE_EXTENDED ? "LTD HT" : "EXT HT", + "M1", + "M2", + "M3", + }); + // restore set points auto restore = this->restore_state_(); if (restore.has_value()) { diff --git a/esphome/components/bedjet/climate/bedjet_climate.h b/esphome/components/bedjet/climate/bedjet_climate.h index 1d2f28b7cd..d12c2a8255 100644 --- a/esphome/components/bedjet/climate/bedjet_climate.h +++ b/esphome/components/bedjet/climate/bedjet_climate.h @@ -48,16 +48,8 @@ class BedJetClimate : public climate::Climate, public BedJetClient, public Polli // Climate doesn't have a "TURBO" mode, but we can use the BOOST preset instead. climate::CLIMATE_PRESET_BOOST, }); - // Custom fan modes and presets are stored on Climate base class and wired via get_traits() - // It would be better if we had a slider for the fan modes. - this->set_supported_custom_fan_modes(BEDJET_FAN_STEP_NAMES); - // String literals are stored in rodata and valid for program lifetime - this->set_supported_custom_presets({ - this->heating_mode_ == HEAT_MODE_EXTENDED ? "LTD HT" : "EXT HT", - "M1", - "M2", - "M3", - }); + // Custom fan modes and presets are set once in setup(), stored on Climate base class, + // and wired automatically via get_traits() traits.set_visual_min_temperature(19.0); traits.set_visual_max_temperature(43.0); traits.set_visual_temperature_step(1.0); diff --git a/esphome/components/midea/air_conditioner.cpp b/esphome/components/midea/air_conditioner.cpp index 235698128a..77bec5c7a2 100644 --- a/esphome/components/midea/air_conditioner.cpp +++ b/esphome/components/midea/air_conditioner.cpp @@ -24,6 +24,12 @@ 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 + if (this->base_.getAutoconfStatus() == dudanov::midea::AUTOCONF_OK && + this->base_.getCapabilities().supportFrostProtectionPreset() && !this->frost_protection_set_) { + this->set_supported_custom_presets({Constants::FREEZE_PROTECTION}); + this->frost_protection_set_ = true; + } bool need_publish = false; update_property(this->target_temperature, this->base_.getTargetTemp(), need_publish); update_property(this->current_temperature, this->base_.getIndoorTemp(), need_publish); @@ -99,8 +105,6 @@ ClimateTraits AirConditioner::traits() { traits.add_supported_fan_mode(ClimateFanMode::CLIMATE_FAN_HIGH); if (this->base_.getAutoconfStatus() == dudanov::midea::AUTOCONF_OK) { Converters::to_climate_traits(traits, this->base_.getCapabilities()); - if (this->base_.getCapabilities().supportFrostProtectionPreset()) - this->set_supported_custom_presets({Constants::FREEZE_PROTECTION}); } if (!traits.get_supported_modes().empty()) traits.add_supported_mode(ClimateMode::CLIMATE_MODE_OFF); diff --git a/esphome/components/midea/air_conditioner.h b/esphome/components/midea/air_conditioner.h index da24834686..8dbc71b422 100644 --- a/esphome/components/midea/air_conditioner.h +++ b/esphome/components/midea/air_conditioner.h @@ -55,6 +55,7 @@ class AirConditioner : public ApplianceBase, ClimateModeMask supported_modes_{}; ClimateSwingModeMask supported_swing_modes_{}; ClimatePresetMask supported_presets_{}; + bool frost_protection_set_{false}; Sensor *outdoor_sensor_{nullptr}; Sensor *humidity_sensor_{nullptr}; Sensor *power_sensor_{nullptr}; diff --git a/tests/integration/fixtures/external_components/legacy_climate_component/climate/legacy_climate.h b/tests/integration/fixtures/external_components/legacy_climate_component/climate/legacy_climate.h index 67b83e5137..670134899a 100644 --- a/tests/integration/fixtures/external_components/legacy_climate_component/climate/legacy_climate.h +++ b/tests/integration/fixtures/external_components/legacy_climate_component/climate/legacy_climate.h @@ -44,10 +44,10 @@ class LegacyClimate : public climate::Climate, public Component { if (call.get_target_temperature().has_value()) { this->target_temperature = *call.get_target_temperature(); } - if (call.get_custom_fan_mode() != nullptr) { + if (call.has_custom_fan_mode()) { this->set_custom_fan_mode_(call.get_custom_fan_mode()); } - if (call.get_custom_preset() != nullptr) { + if (call.has_custom_preset()) { this->set_custom_preset_(call.get_custom_preset()); } this->publish_state();