[gree] Remove the traits() override now handled by climate_ir (#19484)

This commit is contained in:
Leonardo Rivera
2026-09-23 16:29:23 +01:00
committed by GitHub
parent 26abc1325e
commit 93df1e1259
4 changed files with 30 additions and 12 deletions
-11
View File
@@ -5,17 +5,6 @@ namespace esphome::gree {
static const char *const TAG = "gree.climate";
climate::ClimateTraits GreeClimate::traits() {
auto t = climate_ir::ClimateIR::traits();
// ClimateIR unconditionally includes HEAT_COOL in the base mode set; remove it when heat is not supported.
if (!this->supports_heat_) {
auto modes = t.get_supported_modes();
modes.erase(climate::CLIMATE_MODE_HEAT_COOL);
t.set_supported_modes(modes);
}
return t;
}
void GreeClimate::set_model(Model model) {
if (model == GREE_YAN) {
// YAN only has a vertical vane; the horizontal swing IR bytes are not defined for this model.
-1
View File
@@ -94,7 +94,6 @@ class GreeClimate final : public climate_ir::ClimateIR {
protected:
// Transmit via IR the state of this climate controller.
void transmit_state() override;
climate::ClimateTraits traits() override;
uint8_t operation_mode_();
uint8_t fan_speed_();
+6
View File
@@ -0,0 +1,6 @@
from tests.testing_helpers import ComponentManifestOverride
def override_manifest(manifest: ComponentManifestOverride) -> None:
# AUTO_LOAD sits on the climate platform, which the unit test build does not load.
manifest.dependencies = manifest.dependencies + ["climate_ir", "climate"]
+24
View File
@@ -0,0 +1,24 @@
#include <gtest/gtest.h>
#include "esphome/components/gree/gree.h"
namespace esphome::gree::testing {
TEST(GreeClimateTest, HeatCoolHiddenWithoutHeatByDefault) {
GreeClimate climate;
climate.set_supports_heat(false);
climate.set_supports_cool(true);
climate.set_supports_heat_cool(false);
EXPECT_FALSE(climate.get_traits().supports_mode(climate::CLIMATE_MODE_HEAT_COOL));
}
TEST(GreeClimateTest, HeatCoolOverrideAdvertisedWithoutHeat) {
GreeClimate climate;
climate.set_supports_heat(false);
climate.set_supports_cool(true);
climate.set_supports_heat_cool(true);
auto traits = climate.get_traits();
EXPECT_TRUE(traits.supports_mode(climate::CLIMATE_MODE_HEAT_COOL));
EXPECT_FALSE(traits.supports_mode(climate::CLIMATE_MODE_HEAT));
}
} // namespace esphome::gree::testing