1
mirror of https://github.com/home-assistant/core synced 2024-08-02 23:40:32 +02:00
ha-core/homeassistant/components/tellduslive/cover.py
epenet 1ce75f8e6b
Add cover setup type hints (#63285)
Co-authored-by: epenet <epenet@users.noreply.github.com>
2022-01-03 15:13:18 +01:00

53 lines
1.6 KiB
Python

"""Support for Tellstick covers using Tellstick Net."""
from homeassistant.components import cover, tellduslive
from homeassistant.components.cover import CoverEntity
from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant
from homeassistant.helpers.dispatcher import async_dispatcher_connect
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from .entry import TelldusLiveEntity
async def async_setup_entry(
hass: HomeAssistant,
config_entry: ConfigEntry,
async_add_entities: AddEntitiesCallback,
) -> None:
"""Set up tellduslive sensors dynamically."""
async def async_discover_cover(device_id):
"""Discover and add a discovered sensor."""
client = hass.data[tellduslive.DOMAIN]
async_add_entities([TelldusLiveCover(client, device_id)])
async_dispatcher_connect(
hass,
tellduslive.TELLDUS_DISCOVERY_NEW.format(cover.DOMAIN, tellduslive.DOMAIN),
async_discover_cover,
)
class TelldusLiveCover(TelldusLiveEntity, CoverEntity):
"""Representation of a cover."""
@property
def is_closed(self):
"""Return the current position of the cover."""
return self.device.is_down
def close_cover(self, **kwargs):
"""Close the cover."""
self.device.down()
self._update_callback()
def open_cover(self, **kwargs):
"""Open the cover."""
self.device.up()
self._update_callback()
def stop_cover(self, **kwargs):
"""Stop the cover."""
self.device.stop()
self._update_callback()