From b724ae9e0e4993d20b55df7e9056c03259206954 Mon Sep 17 00:00:00 2001 From: Sergey Dudanov Date: Tue, 14 Feb 2023 04:34:50 +0400 Subject: [PATCH] Fix setting wrong traits on midea climate component (#4425) * Fix issue3914 * Remove also default presets and modes * Fix traits after autoconf --- esphome/components/midea/air_conditioner.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/esphome/components/midea/air_conditioner.cpp b/esphome/components/midea/air_conditioner.cpp index 1ad5ade53d..b5bf43b64f 100644 --- a/esphome/components/midea/air_conditioner.cpp +++ b/esphome/components/midea/air_conditioner.cpp @@ -84,18 +84,18 @@ ClimateTraits AirConditioner::traits() { traits.set_supported_custom_presets(this->supported_custom_presets_); traits.set_supported_custom_fan_modes(this->supported_custom_fan_modes_); /* + MINIMAL SET OF CAPABILITIES */ - traits.add_supported_mode(ClimateMode::CLIMATE_MODE_OFF); - traits.add_supported_mode(ClimateMode::CLIMATE_MODE_FAN_ONLY); traits.add_supported_fan_mode(ClimateFanMode::CLIMATE_FAN_AUTO); traits.add_supported_fan_mode(ClimateFanMode::CLIMATE_FAN_LOW); traits.add_supported_fan_mode(ClimateFanMode::CLIMATE_FAN_MEDIUM); traits.add_supported_fan_mode(ClimateFanMode::CLIMATE_FAN_HIGH); - traits.add_supported_swing_mode(ClimateSwingMode::CLIMATE_SWING_OFF); - traits.add_supported_swing_mode(ClimateSwingMode::CLIMATE_SWING_VERTICAL); - traits.add_supported_preset(ClimatePreset::CLIMATE_PRESET_NONE); - traits.add_supported_preset(ClimatePreset::CLIMATE_PRESET_SLEEP); if (this->base_.getAutoconfStatus() == dudanov::midea::AUTOCONF_OK) Converters::to_climate_traits(traits, this->base_.getCapabilities()); + if (!traits.get_supported_modes().empty()) + traits.add_supported_mode(ClimateMode::CLIMATE_MODE_OFF); + if (!traits.get_supported_swing_modes().empty()) + traits.add_supported_swing_mode(ClimateSwingMode::CLIMATE_SWING_OFF); + if (!traits.get_supported_presets().empty()) + traits.add_supported_preset(ClimatePreset::CLIMATE_PRESET_NONE); return traits; }