mirror of
https://github.com/home-assistant/core.git
synced 2025-07-25 14:17:45 +00:00
Add supported features property in Sensibo (#134479)
This commit is contained in:
parent
ee025198e8
commit
97aa93f92b
@ -206,12 +206,12 @@ class SensiboClimate(SensiboDeviceBaseEntity, ClimateEntity):
|
|||||||
if self.device_data.temp_unit == "C"
|
if self.device_data.temp_unit == "C"
|
||||||
else UnitOfTemperature.FAHRENHEIT
|
else UnitOfTemperature.FAHRENHEIT
|
||||||
)
|
)
|
||||||
self._attr_supported_features = self.get_features()
|
|
||||||
|
|
||||||
def get_features(self) -> ClimateEntityFeature:
|
@property
|
||||||
"""Get supported features."""
|
def supported_features(self) -> ClimateEntityFeature:
|
||||||
|
"""Return the list of supported features."""
|
||||||
features = ClimateEntityFeature.TURN_OFF | ClimateEntityFeature.TURN_ON
|
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:
|
if key in FIELD_TO_FLAG:
|
||||||
features |= FIELD_TO_FLAG[key]
|
features |= FIELD_TO_FLAG[key]
|
||||||
return features
|
return features
|
||||||
@ -297,12 +297,6 @@ class SensiboClimate(SensiboDeviceBaseEntity, ClimateEntity):
|
|||||||
|
|
||||||
async def async_set_temperature(self, **kwargs: Any) -> None:
|
async def async_set_temperature(self, **kwargs: Any) -> None:
|
||||||
"""Set new target temperature."""
|
"""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]
|
temperature: float = kwargs[ATTR_TEMPERATURE]
|
||||||
if temperature == self.target_temperature:
|
if temperature == self.target_temperature:
|
||||||
return
|
return
|
||||||
@ -317,11 +311,6 @@ class SensiboClimate(SensiboDeviceBaseEntity, ClimateEntity):
|
|||||||
|
|
||||||
async def async_set_fan_mode(self, fan_mode: str) -> None:
|
async def async_set_fan_mode(self, fan_mode: str) -> None:
|
||||||
"""Set new target fan mode."""
|
"""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:
|
if fan_mode not in AVAILABLE_FAN_MODES:
|
||||||
raise HomeAssistantError(
|
raise HomeAssistantError(
|
||||||
translation_domain=DOMAIN,
|
translation_domain=DOMAIN,
|
||||||
@ -367,11 +356,6 @@ class SensiboClimate(SensiboDeviceBaseEntity, ClimateEntity):
|
|||||||
|
|
||||||
async def async_set_swing_mode(self, swing_mode: str) -> None:
|
async def async_set_swing_mode(self, swing_mode: str) -> None:
|
||||||
"""Set new target swing operation."""
|
"""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:
|
if swing_mode not in AVAILABLE_SWING_MODES:
|
||||||
raise HomeAssistantError(
|
raise HomeAssistantError(
|
||||||
translation_domain=DOMAIN,
|
translation_domain=DOMAIN,
|
||||||
|
@ -535,18 +535,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"exceptions": {
|
"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": {
|
"fan_mode_not_supported": {
|
||||||
"message": "Climate fan mode {fan_mode} is not supported by the integration, please open an issue"
|
"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": {
|
"swing_not_supported": {
|
||||||
"message": "Climate swing mode {swing_mode} is not supported by the integration, please open an issue"
|
"message": "Climate swing mode {swing_mode} is not supported by the integration, please open an issue"
|
||||||
},
|
},
|
||||||
|
@ -194,7 +194,7 @@
|
|||||||
'original_name': None,
|
'original_name': None,
|
||||||
'platform': 'sensibo',
|
'platform': 'sensibo',
|
||||||
'previous_unique_id': None,
|
'previous_unique_id': None,
|
||||||
'supported_features': <ClimateEntityFeature: 393>,
|
'supported_features': <ClimateEntityFeature: 392>,
|
||||||
'translation_key': 'climate_device',
|
'translation_key': 'climate_device',
|
||||||
'unique_id': 'AAZZAAZZ',
|
'unique_id': 'AAZZAAZZ',
|
||||||
'unit_of_measurement': None,
|
'unit_of_measurement': None,
|
||||||
@ -216,9 +216,8 @@
|
|||||||
]),
|
]),
|
||||||
'max_temp': 1,
|
'max_temp': 1,
|
||||||
'min_temp': 0,
|
'min_temp': 0,
|
||||||
'supported_features': <ClimateEntityFeature: 393>,
|
'supported_features': <ClimateEntityFeature: 392>,
|
||||||
'target_temp_step': 1,
|
'target_temp_step': 1,
|
||||||
'temperature': None,
|
|
||||||
}),
|
}),
|
||||||
'context': <ANY>,
|
'context': <ANY>,
|
||||||
'entity_id': 'climate.kitchen',
|
'entity_id': 'climate.kitchen',
|
||||||
|
@ -177,7 +177,7 @@ async def test_climate_fan(
|
|||||||
async_fire_time_changed(hass)
|
async_fire_time_changed(hass)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
with pytest.raises(HomeAssistantError):
|
with pytest.raises(HomeAssistantError, match="service_not_supported"):
|
||||||
await hass.services.async_call(
|
await hass.services.async_call(
|
||||||
CLIMATE_DOMAIN,
|
CLIMATE_DOMAIN,
|
||||||
SERVICE_SET_FAN_MODE,
|
SERVICE_SET_FAN_MODE,
|
||||||
@ -186,7 +186,7 @@ async def test_climate_fan(
|
|||||||
)
|
)
|
||||||
|
|
||||||
state = hass.states.get("climate.hallway")
|
state = hass.states.get("climate.hallway")
|
||||||
assert state.attributes["fan_mode"] == "low"
|
assert "fan_mode" not in state.attributes
|
||||||
|
|
||||||
|
|
||||||
async def test_climate_swing(
|
async def test_climate_swing(
|
||||||
@ -262,7 +262,7 @@ async def test_climate_swing(
|
|||||||
async_fire_time_changed(hass)
|
async_fire_time_changed(hass)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
with pytest.raises(HomeAssistantError):
|
with pytest.raises(HomeAssistantError, match="service_not_supported"):
|
||||||
await hass.services.async_call(
|
await hass.services.async_call(
|
||||||
CLIMATE_DOMAIN,
|
CLIMATE_DOMAIN,
|
||||||
SERVICE_SET_SWING_MODE,
|
SERVICE_SET_SWING_MODE,
|
||||||
@ -271,7 +271,7 @@ async def test_climate_swing(
|
|||||||
)
|
)
|
||||||
|
|
||||||
state = hass.states.get("climate.hallway")
|
state = hass.states.get("climate.hallway")
|
||||||
assert state.attributes["swing_mode"] == "fixedtop"
|
assert "swing_mode" not in state.attributes
|
||||||
|
|
||||||
|
|
||||||
async def test_climate_temperatures(
|
async def test_climate_temperatures(
|
||||||
@ -387,7 +387,7 @@ async def test_climate_temperatures(
|
|||||||
async_fire_time_changed(hass)
|
async_fire_time_changed(hass)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
with pytest.raises(HomeAssistantError):
|
with pytest.raises(HomeAssistantError, match="service_not_supported"):
|
||||||
await hass.services.async_call(
|
await hass.services.async_call(
|
||||||
CLIMATE_DOMAIN,
|
CLIMATE_DOMAIN,
|
||||||
SERVICE_SET_TEMPERATURE,
|
SERVICE_SET_TEMPERATURE,
|
||||||
@ -396,7 +396,7 @@ async def test_climate_temperatures(
|
|||||||
)
|
)
|
||||||
|
|
||||||
state = hass.states.get("climate.hallway")
|
state = hass.states.get("climate.hallway")
|
||||||
assert state.attributes["temperature"] == 20
|
assert "temperature" not in state.attributes
|
||||||
|
|
||||||
|
|
||||||
async def test_climate_temperature_is_none(
|
async def test_climate_temperature_is_none(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user