diff --git a/homeassistant/components/sensibo/climate.py b/homeassistant/components/sensibo/climate.py index e8017e7d849..0963a4f927e 100644 --- a/homeassistant/components/sensibo/climate.py +++ b/homeassistant/components/sensibo/climate.py @@ -157,7 +157,7 @@ class SensiboClimate(CoordinatorEntity, ClimateEntity): def get_features(self) -> int: """Get supported features.""" features = 0 - for key in self.coordinator.data[self.unique_id]["features"]: + for key in self.coordinator.data[self.unique_id]["full_features"]: if key in FIELD_TO_FLAG: features |= FIELD_TO_FLAG[key] return features @@ -240,6 +240,14 @@ class SensiboClimate(CoordinatorEntity, ClimateEntity): async def async_set_temperature(self, **kwargs) -> None: """Set new target temperature.""" + if ( + "targetTemperature" + not in self.coordinator.data[self.unique_id]["active_features"] + ): + raise HomeAssistantError( + "Current mode doesn't support setting Target Temperature" + ) + if (temperature := kwargs.get(ATTR_TEMPERATURE)) is None: return @@ -261,6 +269,9 @@ class SensiboClimate(CoordinatorEntity, ClimateEntity): async def async_set_fan_mode(self, fan_mode: str) -> None: """Set new target fan mode.""" + if "fanLevel" not in self.coordinator.data[self.unique_id]["active_features"]: + raise HomeAssistantError("Current mode doesn't support setting Fanlevel") + await self._async_set_ac_state_property("fanLevel", fan_mode) async def async_set_hvac_mode(self, hvac_mode: str) -> None: @@ -277,6 +288,9 @@ class SensiboClimate(CoordinatorEntity, ClimateEntity): async def async_set_swing_mode(self, swing_mode: str) -> None: """Set new target swing operation.""" + if "swing" not in self.coordinator.data[self.unique_id]["active_features"]: + raise HomeAssistantError("Current mode doesn't support setting Swing") + await self._async_set_ac_state_property("swing", swing_mode) async def async_turn_on(self) -> None: diff --git a/homeassistant/components/sensibo/coordinator.py b/homeassistant/components/sensibo/coordinator.py index 9509be88266..41c44e741e9 100644 --- a/homeassistant/components/sensibo/coordinator.py +++ b/homeassistant/components/sensibo/coordinator.py @@ -72,7 +72,17 @@ class SensiboDataUpdateCoordinator(DataUpdateCoordinator): ) if temperatures_list: temperature_step = temperatures_list[1] - temperatures_list[0] - features = list(ac_states) + + active_features = list(ac_states) + full_features = set() + for mode in capabilities["modes"]: + if "temperatures" in capabilities["modes"][mode]: + full_features.add("targetTemperature") + if "swing" in capabilities["modes"][mode]: + full_features.add("swing") + if "fanLevels" in capabilities["modes"][mode]: + full_features.add("fanLevel") + state = hvac_mode if hvac_mode else "off" fw_ver = dev["firmwareVersion"] @@ -100,7 +110,8 @@ class SensiboDataUpdateCoordinator(DataUpdateCoordinator): "temp_unit": temperature_unit_key, "temp_list": temperatures_list, "temp_step": temperature_step, - "features": features, + "active_features": active_features, + "full_features": full_features, "state": state, "fw_ver": fw_ver, "fw_type": fw_type,