Add device classes to homematicip_cloud cover (#52793)

Make HMIP covers report a SHUTTER/BLIND/GARAGE device_class (as
appropriate).
This commit is contained in:
Leszek Swirski 2021-07-12 00:51:28 +02:00 committed by GitHub
parent 574cb03acc
commit e556722281
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -15,6 +15,9 @@ from homematicip.base.enums import DoorCommand, DoorState
from homeassistant.components.cover import ( from homeassistant.components.cover import (
ATTR_POSITION, ATTR_POSITION,
ATTR_TILT_POSITION, ATTR_TILT_POSITION,
DEVICE_CLASS_BLIND,
DEVICE_CLASS_GARAGE,
DEVICE_CLASS_SHUTTER,
CoverEntity, CoverEntity,
) )
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
@ -63,6 +66,11 @@ async def async_setup_entry(
class HomematicipBlindModule(HomematicipGenericEntity, CoverEntity): class HomematicipBlindModule(HomematicipGenericEntity, CoverEntity):
"""Representation of the HomematicIP blind module.""" """Representation of the HomematicIP blind module."""
@property
def device_class(self) -> str:
"""Return the class of the cover."""
return DEVICE_CLASS_BLIND
@property @property
def current_cover_position(self) -> int: def current_cover_position(self) -> int:
"""Return current position of cover.""" """Return current position of cover."""
@ -151,6 +159,11 @@ class HomematicipMultiCoverShutter(HomematicipGenericEntity, CoverEntity):
hap, device, channel=channel, is_multi_channel=is_multi_channel hap, device, channel=channel, is_multi_channel=is_multi_channel
) )
@property
def device_class(self) -> str:
"""Return the class of the cover."""
return DEVICE_CLASS_SHUTTER
@property @property
def current_cover_position(self) -> int: def current_cover_position(self) -> int:
"""Return current position of cover.""" """Return current position of cover."""
@ -264,6 +277,11 @@ class HomematicipGarageDoorModule(HomematicipGenericEntity, CoverEntity):
} }
return door_state_to_position.get(self._device.doorState) return door_state_to_position.get(self._device.doorState)
@property
def device_class(self) -> str:
"""Return the class of the cover."""
return DEVICE_CLASS_GARAGE
@property @property
def is_closed(self) -> bool | None: def is_closed(self) -> bool | None:
"""Return if the cover is closed.""" """Return if the cover is closed."""
@ -290,6 +308,11 @@ class HomematicipCoverShutterGroup(HomematicipGenericEntity, CoverEntity):
device.modelType = f"HmIP-{post}" device.modelType = f"HmIP-{post}"
super().__init__(hap, device, post, is_multi_channel=False) super().__init__(hap, device, post, is_multi_channel=False)
@property
def device_class(self) -> str:
"""Return the class of the cover."""
return DEVICE_CLASS_SHUTTER
@property @property
def current_cover_position(self) -> int: def current_cover_position(self) -> int:
"""Return current position of cover.""" """Return current position of cover."""