mirror of
https://github.com/esphome/esphome.git
synced 2026-09-28 23:40:25 +00:00
[gree] Remove the traits() override now handled by climate_ir (#19484)
This commit is contained in:
@@ -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.
|
||||
|
||||
@@ -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_();
|
||||
|
||||
@@ -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"]
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user