mirror of
https://github.com/home-assistant/core.git
synced 2025-07-22 20:57:21 +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."""
|
||||
|
||||
from contextlib import suppress
|
||||
from typing import Any
|
||||
|
||||
from homeassistant.components.cover import (
|
||||
ATTR_CURRENT_POSITION,
|
||||
DEVICE_CLASSES,
|
||||
CoverDeviceClass,
|
||||
CoverEntity,
|
||||
)
|
||||
@ -14,8 +14,6 @@ from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
|
||||
from .dynalitebase import DynaliteBase, async_setup_entry_base
|
||||
|
||||
DEFAULT_COVER_CLASS = CoverDeviceClass.SHUTTER
|
||||
|
||||
|
||||
async def async_setup_entry(
|
||||
hass: HomeAssistant,
|
||||
@ -39,13 +37,12 @@ class DynaliteCover(DynaliteBase, CoverEntity):
|
||||
"""Representation of a Dynalite Channel as a Home Assistant Cover."""
|
||||
|
||||
@property
|
||||
def device_class(self) -> str:
|
||||
def device_class(self) -> CoverDeviceClass:
|
||||
"""Return the class of the device."""
|
||||
dev_cls = self._device.device_class
|
||||
ret_val = DEFAULT_COVER_CLASS
|
||||
if dev_cls in DEVICE_CLASSES:
|
||||
ret_val = dev_cls
|
||||
return ret_val
|
||||
if device_class := self._device.device_class:
|
||||
with suppress(ValueError):
|
||||
return CoverDeviceClass(device_class)
|
||||
return CoverDeviceClass.SHUTTER
|
||||
|
||||
@property
|
||||
def current_cover_position(self) -> int:
|
||||
|
Loading…
x
Reference in New Issue
Block a user