mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 03:07:37 +00:00
Cleanup KNX supported_features for climate, cover and fan (#52218)
This commit is contained in:
parent
9e50bd0b30
commit
d4211c4a66
@ -172,12 +172,14 @@ class KNXClimate(KnxEntity, ClimateEntity):
|
|||||||
"""Representation of a KNX climate device."""
|
"""Representation of a KNX climate device."""
|
||||||
|
|
||||||
_device: XknxClimate
|
_device: XknxClimate
|
||||||
_attr_supported_features = SUPPORT_TARGET_TEMPERATURE | SUPPORT_PRESET_MODE
|
|
||||||
_attr_temperature_unit = TEMP_CELSIUS
|
_attr_temperature_unit = TEMP_CELSIUS
|
||||||
|
|
||||||
def __init__(self, xknx: XKNX, config: ConfigType) -> None:
|
def __init__(self, xknx: XKNX, config: ConfigType) -> None:
|
||||||
"""Initialize of a KNX climate device."""
|
"""Initialize of a KNX climate device."""
|
||||||
super().__init__(_create_climate(xknx, config))
|
super().__init__(_create_climate(xknx, config))
|
||||||
|
self._attr_supported_features = SUPPORT_TARGET_TEMPERATURE
|
||||||
|
if self.preset_modes:
|
||||||
|
self._attr_supported_features |= SUPPORT_PRESET_MODE
|
||||||
self._attr_target_temperature_step = self._device.temperature_step
|
self._attr_target_temperature_step = self._device.temperature_step
|
||||||
self._attr_unique_id = (
|
self._attr_unique_id = (
|
||||||
f"{self._device.temperature.group_address_state}_"
|
f"{self._device.temperature.group_address_state}_"
|
||||||
|
@ -112,6 +112,17 @@ class KNXCover(KnxEntity, CoverEntity):
|
|||||||
self._attr_device_class = config.get(CONF_DEVICE_CLASS) or (
|
self._attr_device_class = config.get(CONF_DEVICE_CLASS) or (
|
||||||
DEVICE_CLASS_BLIND if self._device.supports_angle else None
|
DEVICE_CLASS_BLIND if self._device.supports_angle else None
|
||||||
)
|
)
|
||||||
|
self._attr_supported_features = (
|
||||||
|
SUPPORT_CLOSE | SUPPORT_OPEN | SUPPORT_SET_POSITION
|
||||||
|
)
|
||||||
|
if self._device.supports_stop:
|
||||||
|
self._attr_supported_features |= SUPPORT_STOP | SUPPORT_STOP_TILT
|
||||||
|
if self._device.supports_angle:
|
||||||
|
self._attr_supported_features |= SUPPORT_SET_TILT_POSITION
|
||||||
|
if self._device.step.writable:
|
||||||
|
self._attr_supported_features |= (
|
||||||
|
SUPPORT_CLOSE_TILT | SUPPORT_OPEN_TILT | SUPPORT_STOP_TILT
|
||||||
|
)
|
||||||
self._attr_unique_id = (
|
self._attr_unique_id = (
|
||||||
f"{self._device.updown.group_address}_"
|
f"{self._device.updown.group_address}_"
|
||||||
f"{self._device.position_target.group_address}"
|
f"{self._device.position_target.group_address}"
|
||||||
@ -124,21 +135,6 @@ class KNXCover(KnxEntity, CoverEntity):
|
|||||||
if self._device.is_traveling():
|
if self._device.is_traveling():
|
||||||
self.start_auto_updater()
|
self.start_auto_updater()
|
||||||
|
|
||||||
@property
|
|
||||||
def supported_features(self) -> int:
|
|
||||||
"""Flag supported features."""
|
|
||||||
supported_features = SUPPORT_OPEN | SUPPORT_CLOSE | SUPPORT_SET_POSITION
|
|
||||||
if self._device.supports_stop:
|
|
||||||
supported_features |= SUPPORT_STOP
|
|
||||||
if self._device.supports_angle:
|
|
||||||
supported_features |= (
|
|
||||||
SUPPORT_SET_TILT_POSITION
|
|
||||||
| SUPPORT_OPEN_TILT
|
|
||||||
| SUPPORT_CLOSE_TILT
|
|
||||||
| SUPPORT_STOP_TILT
|
|
||||||
)
|
|
||||||
return supported_features
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def current_cover_position(self) -> int | None:
|
def current_cover_position(self) -> int | None:
|
||||||
"""Return the current position of the cover.
|
"""Return the current position of the cover.
|
||||||
|
@ -66,11 +66,9 @@ class KNXFan(KnxEntity, FanEntity):
|
|||||||
# FanSpeedMode.STEP if max_step is set
|
# FanSpeedMode.STEP if max_step is set
|
||||||
self._step_range: tuple[int, int] | None = (1, max_step) if max_step else None
|
self._step_range: tuple[int, int] | None = (1, max_step) if max_step else None
|
||||||
|
|
||||||
self._attr_supported_features = (
|
self._attr_supported_features = SUPPORT_SET_SPEED
|
||||||
SUPPORT_SET_SPEED | SUPPORT_OSCILLATE
|
if self._device.supports_oscillation:
|
||||||
if self._device.supports_oscillation
|
self._attr_supported_features |= SUPPORT_OSCILLATE
|
||||||
else SUPPORT_SET_SPEED
|
|
||||||
)
|
|
||||||
self._attr_unique_id = str(self._device.speed.group_address)
|
self._attr_unique_id = str(self._device.speed.group_address)
|
||||||
|
|
||||||
async def async_set_percentage(self, percentage: int) -> None:
|
async def async_set_percentage(self, percentage: int) -> None:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user