diff --git a/homeassistant/components/sensibo/climate.py b/homeassistant/components/sensibo/climate.py index db1f2f83691..315d452b92b 100644 --- a/homeassistant/components/sensibo/climate.py +++ b/homeassistant/components/sensibo/climate.py @@ -206,12 +206,12 @@ class SensiboClimate(SensiboDeviceBaseEntity, ClimateEntity): if self.device_data.temp_unit == "C" else UnitOfTemperature.FAHRENHEIT ) - self._attr_supported_features = self.get_features() - def get_features(self) -> ClimateEntityFeature: - """Get supported features.""" + @property + def supported_features(self) -> ClimateEntityFeature: + """Return the list of supported features.""" features = ClimateEntityFeature.TURN_OFF | ClimateEntityFeature.TURN_ON - for key in self.device_data.full_features: + for key in self.device_data.active_features: if key in FIELD_TO_FLAG: features |= FIELD_TO_FLAG[key] return features @@ -297,12 +297,6 @@ class SensiboClimate(SensiboDeviceBaseEntity, ClimateEntity): async def async_set_temperature(self, **kwargs: Any) -> None: """Set new target temperature.""" - if "targetTemperature" not in self.device_data.active_features: - raise HomeAssistantError( - translation_domain=DOMAIN, - translation_key="no_target_temperature_in_features", - ) - temperature: float = kwargs[ATTR_TEMPERATURE] if temperature == self.target_temperature: return @@ -317,11 +311,6 @@ class SensiboClimate(SensiboDeviceBaseEntity, ClimateEntity): async def async_set_fan_mode(self, fan_mode: str) -> None: """Set new target fan mode.""" - if "fanLevel" not in self.device_data.active_features: - raise HomeAssistantError( - translation_domain=DOMAIN, - translation_key="no_fan_level_in_features", - ) if fan_mode not in AVAILABLE_FAN_MODES: raise HomeAssistantError( translation_domain=DOMAIN, @@ -367,11 +356,6 @@ class SensiboClimate(SensiboDeviceBaseEntity, ClimateEntity): async def async_set_swing_mode(self, swing_mode: str) -> None: """Set new target swing operation.""" - if "swing" not in self.device_data.active_features: - raise HomeAssistantError( - translation_domain=DOMAIN, - translation_key="no_swing_in_features", - ) if swing_mode not in AVAILABLE_SWING_MODES: raise HomeAssistantError( translation_domain=DOMAIN, diff --git a/homeassistant/components/sensibo/strings.json b/homeassistant/components/sensibo/strings.json index ff6274535b9..4e26dbd37d3 100644 --- a/homeassistant/components/sensibo/strings.json +++ b/homeassistant/components/sensibo/strings.json @@ -535,18 +535,9 @@ } }, "exceptions": { - "no_target_temperature_in_features": { - "message": "Current mode doesn't support setting target temperature" - }, - "no_fan_level_in_features": { - "message": "Current mode doesn't support setting fan level" - }, "fan_mode_not_supported": { "message": "Climate fan mode {fan_mode} is not supported by the integration, please open an issue" }, - "no_swing_in_features": { - "message": "Current mode doesn't support setting swing" - }, "swing_not_supported": { "message": "Climate swing mode {swing_mode} is not supported by the integration, please open an issue" }, diff --git a/tests/components/sensibo/snapshots/test_climate.ambr b/tests/components/sensibo/snapshots/test_climate.ambr index e3b27332932..bc66503cf5e 100644 --- a/tests/components/sensibo/snapshots/test_climate.ambr +++ b/tests/components/sensibo/snapshots/test_climate.ambr @@ -194,7 +194,7 @@ 'original_name': None, 'platform': 'sensibo', 'previous_unique_id': None, - 'supported_features': , + 'supported_features': , 'translation_key': 'climate_device', 'unique_id': 'AAZZAAZZ', 'unit_of_measurement': None, @@ -216,9 +216,8 @@ ]), 'max_temp': 1, 'min_temp': 0, - 'supported_features': , + 'supported_features': , 'target_temp_step': 1, - 'temperature': None, }), 'context': , 'entity_id': 'climate.kitchen', diff --git a/tests/components/sensibo/test_climate.py b/tests/components/sensibo/test_climate.py index 028dd602226..6bcfee65635 100644 --- a/tests/components/sensibo/test_climate.py +++ b/tests/components/sensibo/test_climate.py @@ -177,7 +177,7 @@ async def test_climate_fan( async_fire_time_changed(hass) await hass.async_block_till_done() - with pytest.raises(HomeAssistantError): + with pytest.raises(HomeAssistantError, match="service_not_supported"): await hass.services.async_call( CLIMATE_DOMAIN, SERVICE_SET_FAN_MODE, @@ -186,7 +186,7 @@ async def test_climate_fan( ) state = hass.states.get("climate.hallway") - assert state.attributes["fan_mode"] == "low" + assert "fan_mode" not in state.attributes async def test_climate_swing( @@ -262,7 +262,7 @@ async def test_climate_swing( async_fire_time_changed(hass) await hass.async_block_till_done() - with pytest.raises(HomeAssistantError): + with pytest.raises(HomeAssistantError, match="service_not_supported"): await hass.services.async_call( CLIMATE_DOMAIN, SERVICE_SET_SWING_MODE, @@ -271,7 +271,7 @@ async def test_climate_swing( ) state = hass.states.get("climate.hallway") - assert state.attributes["swing_mode"] == "fixedtop" + assert "swing_mode" not in state.attributes async def test_climate_temperatures( @@ -387,7 +387,7 @@ async def test_climate_temperatures( async_fire_time_changed(hass) await hass.async_block_till_done() - with pytest.raises(HomeAssistantError): + with pytest.raises(HomeAssistantError, match="service_not_supported"): await hass.services.async_call( CLIMATE_DOMAIN, SERVICE_SET_TEMPERATURE, @@ -396,7 +396,7 @@ async def test_climate_temperatures( ) state = hass.states.get("climate.hallway") - assert state.attributes["temperature"] == 20 + assert "temperature" not in state.attributes async def test_climate_temperature_is_none(