Use CoverDeviceClass in Dynalite (#83394)

This commit is contained in:
Franck Nijhof 2022-12-06 13:30:22 +01:00 committed by GitHub
parent 04793978d3
commit 9f36412076
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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: