Home Assistant Unofficial Reference 2024.12.1
cover.py
Go to the documentation of this file.
1 """Platform for cover integration."""
2 
3 from __future__ import annotations
4 
5 from typing import Any
6 
8  CoverDeviceClass,
9  CoverEntity,
10  CoverEntityFeature,
11 )
12 from homeassistant.core import HomeAssistant
13 from homeassistant.helpers.entity_platform import AddEntitiesCallback
14 
15 from . import DevoloHomeControlConfigEntry
16 from .devolo_multi_level_switch import DevoloMultiLevelSwitchDeviceEntity
17 
18 
20  hass: HomeAssistant,
21  entry: DevoloHomeControlConfigEntry,
22  async_add_entities: AddEntitiesCallback,
23 ) -> None:
24  """Get all cover devices and setup them via config entry."""
25 
28  homecontrol=gateway,
29  device_instance=device,
30  element_uid=multi_level_switch,
31  )
32  for gateway in entry.runtime_data
33  for device in gateway.multi_level_switch_devices
34  for multi_level_switch in device.multi_level_switch_property
35  if multi_level_switch.startswith("devolo.Blinds")
36  )
37 
38 
40  """Representation of a cover device within devolo Home Control."""
41 
42  _attr_supported_features = (
43  CoverEntityFeature.OPEN
44  | CoverEntityFeature.CLOSE
45  | CoverEntityFeature.SET_POSITION
46  )
47  _attr_device_class = CoverDeviceClass.BLIND
48 
49  @property
50  def current_cover_position(self) -> int:
51  """Return the current position. 0 is closed. 100 is open."""
52  return int(self._value_value_value)
53 
54  @property
55  def is_closed(self) -> bool:
56  """Return if the blind is closed or not."""
57  return not bool(self._value_value_value)
58 
59  def open_cover(self, **kwargs: Any) -> None:
60  """Open the blind."""
61  self._multi_level_switch_property_multi_level_switch_property.set(100)
62 
63  def close_cover(self, **kwargs: Any) -> None:
64  """Close the blind."""
65  self._multi_level_switch_property_multi_level_switch_property.set(0)
66 
67  def set_cover_position(self, **kwargs: Any) -> None:
68  """Set the blind to the given position."""
69  self._multi_level_switch_property_multi_level_switch_property.set(kwargs["position"])
None async_setup_entry(HomeAssistant hass, DevoloHomeControlConfigEntry entry, AddEntitiesCallback async_add_entities)
Definition: cover.py:23