diff --git a/homeassistant/components/sensibo/climate.py b/homeassistant/components/sensibo/climate.py index db1f2f836911f989a3cc36e1c00a8559334ef9b4..315d452b92b6cf15961e8a2b049696a046421e9e 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 ff6274535b9251ddc04b10b048472ac0d45762f5..4e26dbd37d385cb7497007077988e15d6962e1ee 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 e3b273329323c04ea2f593c092fa1ff814ec87de..bc66503cf5ee0b7f8e2cadd2644cdd6c53e25025 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': <ClimateEntityFeature: 393>, + 'supported_features': <ClimateEntityFeature: 392>, 'translation_key': 'climate_device', 'unique_id': 'AAZZAAZZ', 'unit_of_measurement': None, @@ -216,9 +216,8 @@ ]), 'max_temp': 1, 'min_temp': 0, - 'supported_features': <ClimateEntityFeature: 393>, + 'supported_features': <ClimateEntityFeature: 392>, 'target_temp_step': 1, - 'temperature': None, }), 'context': <ANY>, 'entity_id': 'climate.kitchen', diff --git a/tests/components/sensibo/test_climate.py b/tests/components/sensibo/test_climate.py index 028dd6022269ec91855c6e9aef28ad746ac2bbe7..6bcfee656359e79904de5e2815304f3998b6ef54 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(