mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 03:07:37 +00:00
Set dynalite cover device class in constructor (#100232)
This commit is contained in:
parent
8fe5a5a398
commit
5e2bf2b015
@ -12,6 +12,7 @@ from homeassistant.core import HomeAssistant, callback
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
from homeassistant.util.enum import try_parse_enum
|
||||
|
||||
from .bridge import DynaliteBridge
|
||||
from .dynalitebase import DynaliteBase, async_setup_entry_base
|
||||
|
||||
|
||||
@ -23,7 +24,7 @@ async def async_setup_entry(
|
||||
"""Record the async_add_entities function to add them later when received from Dynalite."""
|
||||
|
||||
@callback
|
||||
def cover_from_device(device, bridge):
|
||||
def cover_from_device(device: Any, bridge: DynaliteBridge) -> CoverEntity:
|
||||
if device.has_tilt:
|
||||
return DynaliteCoverWithTilt(device, bridge)
|
||||
return DynaliteCover(device, bridge)
|
||||
@ -36,11 +37,11 @@ async def async_setup_entry(
|
||||
class DynaliteCover(DynaliteBase, CoverEntity):
|
||||
"""Representation of a Dynalite Channel as a Home Assistant Cover."""
|
||||
|
||||
@property
|
||||
def device_class(self) -> CoverDeviceClass:
|
||||
"""Return the class of the device."""
|
||||
def __init__(self, device: Any, bridge: DynaliteBridge) -> None:
|
||||
"""Initialize the cover."""
|
||||
super().__init__(device, bridge)
|
||||
device_class = try_parse_enum(CoverDeviceClass, self._device.device_class)
|
||||
return device_class or CoverDeviceClass.SHUTTER
|
||||
self._attr_device_class = device_class or CoverDeviceClass.SHUTTER
|
||||
|
||||
@property
|
||||
def current_cover_position(self) -> int:
|
||||
|
Loading…
x
Reference in New Issue
Block a user