mirror of
https://github.com/esphome/esphome.git
synced 2026-09-30 00:10:22 +00:00
[climate_ir] Only advertise HEAT_COOL when heat and cool are both supported (#19483)
This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
from tests.testing_helpers import ComponentManifestOverride
|
||||
|
||||
|
||||
def override_manifest(manifest: ComponentManifestOverride) -> None:
|
||||
# ClimateIR derives from climate::Climate without declaring it as a dependency.
|
||||
manifest.dependencies = manifest.dependencies + ["climate"]
|
||||
@@ -0,0 +1,56 @@
|
||||
#include <gtest/gtest.h>
|
||||
#include "esphome/components/climate_ir/climate_ir.h"
|
||||
|
||||
namespace esphome::climate_ir::testing {
|
||||
|
||||
class TestClimateIR : public ClimateIR {
|
||||
public:
|
||||
TestClimateIR() : ClimateIR(16.0f, 30.0f) {}
|
||||
|
||||
using ClimateIR::traits;
|
||||
|
||||
protected:
|
||||
void transmit_state() override {}
|
||||
};
|
||||
|
||||
// The HEAT_COOL default is covered in tests/component_tests/climate_ir.
|
||||
|
||||
TEST(ClimateIRTest, HeatCoolAdvertisedWhenSupported) {
|
||||
TestClimateIR climate;
|
||||
climate.set_supports_heat(true);
|
||||
climate.set_supports_cool(true);
|
||||
climate.set_supports_heat_cool(true);
|
||||
EXPECT_TRUE(climate.traits().supports_mode(climate::CLIMATE_MODE_HEAT_COOL));
|
||||
}
|
||||
|
||||
TEST(ClimateIRTest, HeatCoolNotAdvertisedWhenUnsupported) {
|
||||
TestClimateIR climate;
|
||||
climate.set_supports_heat(true);
|
||||
climate.set_supports_cool(true);
|
||||
climate.set_supports_heat_cool(false);
|
||||
EXPECT_FALSE(climate.traits().supports_mode(climate::CLIMATE_MODE_HEAT_COOL));
|
||||
}
|
||||
|
||||
TEST(ClimateIRTest, HeatCoolAdvertisedForCoolOnlyDeviceThatSupportsIt) {
|
||||
TestClimateIR climate;
|
||||
climate.set_supports_heat(false);
|
||||
climate.set_supports_cool(true);
|
||||
climate.set_supports_heat_cool(true);
|
||||
auto traits = climate.traits();
|
||||
EXPECT_TRUE(traits.supports_mode(climate::CLIMATE_MODE_HEAT_COOL));
|
||||
EXPECT_FALSE(traits.supports_mode(climate::CLIMATE_MODE_HEAT));
|
||||
}
|
||||
|
||||
TEST(ClimateIRTest, HeatAndCoolModesFollowTheirOwnFlags) {
|
||||
TestClimateIR climate;
|
||||
climate.set_supports_heat(false);
|
||||
climate.set_supports_cool(true);
|
||||
climate.set_supports_heat_cool(false);
|
||||
auto traits = climate.traits();
|
||||
EXPECT_TRUE(traits.supports_mode(climate::CLIMATE_MODE_COOL));
|
||||
EXPECT_FALSE(traits.supports_mode(climate::CLIMATE_MODE_HEAT));
|
||||
EXPECT_FALSE(traits.supports_mode(climate::CLIMATE_MODE_HEAT_COOL));
|
||||
EXPECT_TRUE(traits.supports_mode(climate::CLIMATE_MODE_OFF));
|
||||
}
|
||||
|
||||
} // namespace esphome::climate_ir::testing
|
||||
@@ -0,0 +1,10 @@
|
||||
packages:
|
||||
remote_transmitter: !include ../../test_build_components/common/remote_transmitter/esp32-idf.yaml
|
||||
|
||||
climate:
|
||||
- platform: gree
|
||||
name: GREE
|
||||
transmitter_id: xmitr
|
||||
model: YAN
|
||||
supports_heat: false
|
||||
supports_heat_cool: true
|
||||
@@ -0,0 +1,9 @@
|
||||
packages:
|
||||
remote_transmitter: !include ../../test_build_components/common/remote_transmitter/esp32-idf.yaml
|
||||
|
||||
climate:
|
||||
- platform: gree
|
||||
name: GREE
|
||||
transmitter_id: xmitr
|
||||
model: YAN
|
||||
supports_cool: false
|
||||
@@ -0,0 +1,9 @@
|
||||
packages:
|
||||
remote_transmitter: !include ../../test_build_components/common/remote_transmitter/esp32-idf.yaml
|
||||
|
||||
climate:
|
||||
- platform: gree
|
||||
name: GREE
|
||||
transmitter_id: xmitr
|
||||
model: YAN
|
||||
supports_heat_cool: false
|
||||
@@ -0,0 +1,9 @@
|
||||
packages:
|
||||
remote_transmitter: !include ../../test_build_components/common/remote_transmitter/esp32-idf.yaml
|
||||
|
||||
climate:
|
||||
- platform: gree
|
||||
name: GREE
|
||||
transmitter_id: xmitr
|
||||
model: YAN
|
||||
supports_heat: false
|
||||
Reference in New Issue
Block a user