From 7f4fca63ed78f1cdcbf7e70f08a73e0cb9d7c353 Mon Sep 17 00:00:00 2001 From: Jeremy Cook <8317651+jm-cook@users.noreply.github.com> Date: Thu, 29 Aug 2024 07:49:05 +0200 Subject: [PATCH] SmartThings edge driver for heatit thermostats does not require cooling setpoint (#123188) * remove cooling setpoint requirement for thermostats. Air conditioning remains unchanged * remove cooling setpoint requirement for thermostats. Air conditioning remains unchanged * versions should not be set on core integrations. * Added tests for minimal smartthings thermostat with no cooling. * Added tests for minimal smartthings thermostat with no cooling. * Formatted tests with ruff format --- .../components/smartthings/climate.py | 1 - tests/components/smartthings/test_climate.py | 42 +++++++++++++++++++ 2 files changed, 42 insertions(+), 1 deletion(-) diff --git a/homeassistant/components/smartthings/climate.py b/homeassistant/components/smartthings/climate.py index c3929ababc1..0598e549f24 100644 --- a/homeassistant/components/smartthings/climate.py +++ b/homeassistant/components/smartthings/climate.py @@ -143,7 +143,6 @@ def get_capabilities(capabilities: Sequence[str]) -> Sequence[str] | None: # Or must have all of these thermostat capabilities thermostat_capabilities = [ Capability.temperature_measurement, - Capability.thermostat_cooling_setpoint, Capability.thermostat_heating_setpoint, Capability.thermostat_mode, ] diff --git a/tests/components/smartthings/test_climate.py b/tests/components/smartthings/test_climate.py index e4b8cb6d373..d39ee2d6bed 100644 --- a/tests/components/smartthings/test_climate.py +++ b/tests/components/smartthings/test_climate.py @@ -88,6 +88,26 @@ def basic_thermostat_fixture(device_factory): return device +@pytest.fixture(name="minimal_thermostat") +def minimal_thermostat_fixture(device_factory): + """Fixture returns a minimal thermostat without cooling.""" + device = device_factory( + "Minimal Thermostat", + capabilities=[ + Capability.temperature_measurement, + Capability.thermostat_heating_setpoint, + Capability.thermostat_mode, + ], + status={ + Attribute.heating_setpoint: 68, + Attribute.thermostat_mode: "off", + Attribute.supported_thermostat_modes: ["off", "heat"], + }, + ) + device.status.attributes[Attribute.temperature] = Status(70, "F", None) + return device + + @pytest.fixture(name="thermostat") def thermostat_fixture(device_factory): """Fixture returns a fully-featured thermostat.""" @@ -310,6 +330,28 @@ async def test_basic_thermostat_entity_state( assert state.attributes[ATTR_CURRENT_TEMPERATURE] == 21.1 # celsius +async def test_minimal_thermostat_entity_state( + hass: HomeAssistant, minimal_thermostat +) -> None: + """Tests the state attributes properly match the thermostat type.""" + await setup_platform(hass, CLIMATE_DOMAIN, devices=[minimal_thermostat]) + state = hass.states.get("climate.minimal_thermostat") + assert state.state == HVACMode.OFF + assert ( + state.attributes[ATTR_SUPPORTED_FEATURES] + == ClimateEntityFeature.TARGET_TEMPERATURE_RANGE + | ClimateEntityFeature.TARGET_TEMPERATURE + | ClimateEntityFeature.TURN_OFF + | ClimateEntityFeature.TURN_ON + ) + assert ATTR_HVAC_ACTION not in state.attributes + assert sorted(state.attributes[ATTR_HVAC_MODES]) == [ + HVACMode.HEAT, + HVACMode.OFF, + ] + assert state.attributes[ATTR_CURRENT_TEMPERATURE] == 21.1 # celsius + + async def test_thermostat_entity_state(hass: HomeAssistant, thermostat) -> None: """Tests the state attributes properly match the thermostat type.""" await setup_platform(hass, CLIMATE_DOMAIN, devices=[thermostat])