Home Assistant Unofficial Reference 2024.12.1
cover.py
Go to the documentation of this file.
1 """Support for Velbus covers."""
2 
3 from __future__ import annotations
4 
5 from typing import Any
6 
7 from duotecno.controller import PyDuotecno
8 from duotecno.unit import DuoswitchUnit
9 
10 from homeassistant.components.cover import CoverEntity, CoverEntityFeature
11 from homeassistant.config_entries import ConfigEntry
12 from homeassistant.core import HomeAssistant
13 from homeassistant.helpers.entity_platform import AddEntitiesCallback
14 
15 from .const import DOMAIN
16 from .entity import DuotecnoEntity, api_call
17 
18 
20  hass: HomeAssistant,
21  entry: ConfigEntry,
22  async_add_entities: AddEntitiesCallback,
23 ) -> None:
24  """Set up the duoswitch endities."""
25  cntrl: PyDuotecno = hass.data[DOMAIN][entry.entry_id]
27  DuotecnoCover(channel) for channel in cntrl.get_units("DuoswitchUnit")
28  )
29 
30 
32  """Representation a Velbus cover."""
33 
34  _unit: DuoswitchUnit
35  _attr_supported_features = (
36  CoverEntityFeature.OPEN | CoverEntityFeature.CLOSE | CoverEntityFeature.STOP
37  )
38 
39  @property
40  def is_closed(self) -> bool | None:
41  """Return if the cover is closed."""
42  return self._unit_unit.is_closed()
43 
44  @property
45  def is_opening(self) -> bool:
46  """Return if the cover is opening."""
47  return self._unit_unit.is_opening()
48 
49  @property
50  def is_closing(self) -> bool:
51  """Return if the cover is closing."""
52  return self._unit_unit.is_closing()
53 
54  @api_call
55  async def async_open_cover(self, **kwargs: Any) -> None:
56  """Open the cover."""
57  await self._unit_unit.open()
58 
59  @api_call
60  async def async_close_cover(self, **kwargs: Any) -> None:
61  """Close the cover."""
62  await self._unit_unit.close()
63 
64  @api_call
65  async def async_stop_cover(self, **kwargs: Any) -> None:
66  """Stop the cover."""
67  await self._unit_unit.stop()
None async_setup_entry(HomeAssistant hass, ConfigEntry entry, AddEntitiesCallback async_add_entities)
Definition: cover.py:23
None open(self, **Any kwargs)
Definition: lock.py:86