mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 11:17:21 +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.helpers.entity_platform import AddEntitiesCallback
|
||||||
from homeassistant.util.enum import try_parse_enum
|
from homeassistant.util.enum import try_parse_enum
|
||||||
|
|
||||||
|
from .bridge import DynaliteBridge
|
||||||
from .dynalitebase import DynaliteBase, async_setup_entry_base
|
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."""
|
"""Record the async_add_entities function to add them later when received from Dynalite."""
|
||||||
|
|
||||||
@callback
|
@callback
|
||||||
def cover_from_device(device, bridge):
|
def cover_from_device(device: Any, bridge: DynaliteBridge) -> CoverEntity:
|
||||||
if device.has_tilt:
|
if device.has_tilt:
|
||||||
return DynaliteCoverWithTilt(device, bridge)
|
return DynaliteCoverWithTilt(device, bridge)
|
||||||
return DynaliteCover(device, bridge)
|
return DynaliteCover(device, bridge)
|
||||||
@ -36,11 +37,11 @@ async def async_setup_entry(
|
|||||||
class DynaliteCover(DynaliteBase, CoverEntity):
|
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
|
def __init__(self, device: Any, bridge: DynaliteBridge) -> None:
|
||||||
def device_class(self) -> CoverDeviceClass:
|
"""Initialize the cover."""
|
||||||
"""Return the class of the device."""
|
super().__init__(device, bridge)
|
||||||
device_class = try_parse_enum(CoverDeviceClass, self._device.device_class)
|
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
|
@property
|
||||||
def current_cover_position(self) -> int:
|
def current_cover_position(self) -> int:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user