mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 13:17:32 +00:00
Use CoverDeviceClass in Dynalite (#83394)
This commit is contained in:
parent
04793978d3
commit
9f36412076
@ -1,10 +1,10 @@
|
|||||||
"""Support for the Dynalite channels as covers."""
|
"""Support for the Dynalite channels as covers."""
|
||||||
|
|
||||||
|
from contextlib import suppress
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
from homeassistant.components.cover import (
|
from homeassistant.components.cover import (
|
||||||
ATTR_CURRENT_POSITION,
|
ATTR_CURRENT_POSITION,
|
||||||
DEVICE_CLASSES,
|
|
||||||
CoverDeviceClass,
|
CoverDeviceClass,
|
||||||
CoverEntity,
|
CoverEntity,
|
||||||
)
|
)
|
||||||
@ -14,8 +14,6 @@ from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
|||||||
|
|
||||||
from .dynalitebase import DynaliteBase, async_setup_entry_base
|
from .dynalitebase import DynaliteBase, async_setup_entry_base
|
||||||
|
|
||||||
DEFAULT_COVER_CLASS = CoverDeviceClass.SHUTTER
|
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_entry(
|
async def async_setup_entry(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
@ -39,13 +37,12 @@ class DynaliteCover(DynaliteBase, CoverEntity):
|
|||||||
"""Representation of a Dynalite Channel as a Home Assistant Cover."""
|
"""Representation of a Dynalite Channel as a Home Assistant Cover."""
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def device_class(self) -> str:
|
def device_class(self) -> CoverDeviceClass:
|
||||||
"""Return the class of the device."""
|
"""Return the class of the device."""
|
||||||
dev_cls = self._device.device_class
|
if device_class := self._device.device_class:
|
||||||
ret_val = DEFAULT_COVER_CLASS
|
with suppress(ValueError):
|
||||||
if dev_cls in DEVICE_CLASSES:
|
return CoverDeviceClass(device_class)
|
||||||
ret_val = dev_cls
|
return CoverDeviceClass.SHUTTER
|
||||||
return ret_val
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def current_cover_position(self) -> int:
|
def current_cover_position(self) -> int:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user