Home Assistant Unofficial Reference 2024.12.1
cover.py
Go to the documentation of this file.
1 """Support for Tellstick covers using Tellstick Net."""
2 
3 from typing import Any
4 
5 from homeassistant.components import cover
6 from homeassistant.components.cover import CoverEntity
7 from homeassistant.config_entries import ConfigEntry
8 from homeassistant.core import HomeAssistant
9 from homeassistant.helpers.dispatcher import async_dispatcher_connect
10 from homeassistant.helpers.entity_platform import AddEntitiesCallback
11 
12 from . import TelldusLiveClient
13 from .const import DOMAIN, TELLDUS_DISCOVERY_NEW
14 from .entity import TelldusLiveEntity
15 
16 
18  hass: HomeAssistant,
19  config_entry: ConfigEntry,
20  async_add_entities: AddEntitiesCallback,
21 ) -> None:
22  """Set up tellduslive sensors dynamically."""
23 
24  async def async_discover_cover(device_id):
25  """Discover and add a discovered sensor."""
26  client: TelldusLiveClient = hass.data[DOMAIN]
27  async_add_entities([TelldusLiveCover(client, device_id)])
28 
30  hass,
31  TELLDUS_DISCOVERY_NEW.format(cover.DOMAIN, DOMAIN),
32  async_discover_cover,
33  )
34 
35 
37  """Representation of a cover."""
38 
39  _attr_name = None
40 
41  @property
42  def is_closed(self) -> bool:
43  """Return the current position of the cover."""
44  return self.devicedevice.is_down
45 
46  def close_cover(self, **kwargs: Any) -> None:
47  """Close the cover."""
48  self.devicedevice.down()
49  self.schedule_update_ha_stateschedule_update_ha_state()
50 
51  def open_cover(self, **kwargs: Any) -> None:
52  """Open the cover."""
53  self.devicedevice.up()
54  self.schedule_update_ha_stateschedule_update_ha_state()
55 
56  def stop_cover(self, **kwargs: Any) -> None:
57  """Stop the cover."""
58  self.devicedevice.stop()
59  self.schedule_update_ha_stateschedule_update_ha_state()
None schedule_update_ha_state(self, bool force_refresh=False)
Definition: entity.py:1244
None async_setup_entry(HomeAssistant hass, ConfigEntry config_entry, AddEntitiesCallback async_add_entities)
Definition: cover.py:21
Callable[[], None] async_dispatcher_connect(HomeAssistant hass, str signal, Callable[..., Any] target)
Definition: dispatcher.py:103