Add duotecno covers (#97205)
This commit is contained in:
parent
5ec8165689
commit
d7af1e2d5d
3 changed files with 87 additions and 1 deletions
|
@ -233,6 +233,7 @@ omit =
|
|||
homeassistant/components/duotecno/__init__.py
|
||||
homeassistant/components/duotecno/entity.py
|
||||
homeassistant/components/duotecno/switch.py
|
||||
homeassistant/components/duotecno/cover.py
|
||||
homeassistant/components/dwd_weather_warnings/const.py
|
||||
homeassistant/components/dwd_weather_warnings/coordinator.py
|
||||
homeassistant/components/dwd_weather_warnings/sensor.py
|
||||
|
|
|
@ -11,7 +11,7 @@ from homeassistant.exceptions import ConfigEntryNotReady
|
|||
|
||||
from .const import DOMAIN
|
||||
|
||||
PLATFORMS: list[Platform] = [Platform.SWITCH]
|
||||
PLATFORMS: list[Platform] = [Platform.SWITCH, Platform.COVER]
|
||||
|
||||
|
||||
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||
|
|
85
homeassistant/components/duotecno/cover.py
Normal file
85
homeassistant/components/duotecno/cover.py
Normal file
|
@ -0,0 +1,85 @@
|
|||
"""Support for Velbus covers."""
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any
|
||||
|
||||
from duotecno.unit import DuoswitchUnit
|
||||
|
||||
from homeassistant.components.cover import (
|
||||
CoverEntity,
|
||||
CoverEntityFeature,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.exceptions import HomeAssistantError
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
|
||||
from .const import DOMAIN
|
||||
from .entity import DuotecnoEntity
|
||||
|
||||
|
||||
async def async_setup_entry(
|
||||
hass: HomeAssistant,
|
||||
entry: ConfigEntry,
|
||||
async_add_entities: AddEntitiesCallback,
|
||||
) -> None:
|
||||
"""Set up the duoswitch endities."""
|
||||
cntrl = hass.data[DOMAIN][entry.entry_id]
|
||||
async_add_entities(
|
||||
DuotecnoCover(channel) for channel in cntrl.get_units("DuoSwitchUnit")
|
||||
)
|
||||
|
||||
|
||||
class DuotecnoCover(DuotecnoEntity, CoverEntity):
|
||||
"""Representation a Velbus cover."""
|
||||
|
||||
_unit: DuoswitchUnit
|
||||
|
||||
def __init__(self, unit: DuoswitchUnit) -> None:
|
||||
"""Initialize the cover."""
|
||||
super().__init__(unit)
|
||||
self._attr_supported_features = (
|
||||
CoverEntityFeature.OPEN | CoverEntityFeature.CLOSE | CoverEntityFeature.STOP
|
||||
)
|
||||
|
||||
@property
|
||||
def is_closed(self) -> bool | None:
|
||||
"""Return if the cover is closed."""
|
||||
return self._unit.is_closed()
|
||||
|
||||
@property
|
||||
def is_opening(self) -> bool:
|
||||
"""Return if the cover is opening."""
|
||||
return self._unit.is_opening()
|
||||
|
||||
@property
|
||||
def is_closing(self) -> bool:
|
||||
"""Return if the cover is closing."""
|
||||
return self._unit.is_closing()
|
||||
|
||||
async def async_open_cover(self, **kwargs: Any) -> None:
|
||||
"""Open the cover."""
|
||||
try:
|
||||
await self._unit.open()
|
||||
except OSError as err:
|
||||
raise HomeAssistantError(
|
||||
"Transmit for the open_cover packet failed"
|
||||
) from err
|
||||
|
||||
async def async_close_cover(self, **kwargs: Any) -> None:
|
||||
"""Close the cover."""
|
||||
try:
|
||||
await self._unit.close()
|
||||
except OSError as err:
|
||||
raise HomeAssistantError(
|
||||
"Transmit for the close_cover packet failed"
|
||||
) from err
|
||||
|
||||
async def async_stop_cover(self, **kwargs: Any) -> None:
|
||||
"""Stop the cover."""
|
||||
try:
|
||||
await self._unit.stop()
|
||||
except OSError as err:
|
||||
raise HomeAssistantError(
|
||||
"Transmit for the stop_cover packet failed"
|
||||
) from err
|
Loading…
Add table
Reference in a new issue