core/homeassistant/components/abode/cover.py

47 lines
1.3 KiB
Python
Raw Normal View History

"""Support for Abode Security System covers."""
2022-01-10 14:54:09 +00:00
from typing import Any
from abodepy.devices.cover import AbodeCover as AbodeCV
2019-10-12 20:02:12 +00:00
import abodepy.helpers.constants as CONST
from homeassistant.components.cover import CoverEntity
from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback
2022-01-10 14:54:09 +00:00
from . import AbodeDevice, AbodeSystem
from .const import DOMAIN
async def async_setup_entry(
2022-01-10 14:54:09 +00:00
hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback
) -> None:
"""Set up Abode cover devices."""
2022-01-10 14:54:09 +00:00
data: AbodeSystem = hass.data[DOMAIN]
entities = []
for device in data.abode.get_devices(generic_type=CONST.TYPE_COVER):
entities.append(AbodeCover(data, device))
async_add_entities(entities)
class AbodeCover(AbodeDevice, CoverEntity):
"""Representation of an Abode cover."""
2022-01-10 14:54:09 +00:00
_device: AbodeCV
@property
2022-01-10 14:54:09 +00:00
def is_closed(self) -> bool:
"""Return true if cover is closed, else False."""
return not self._device.is_open
2022-01-10 14:54:09 +00:00
def close_cover(self, **kwargs: Any) -> None:
"""Issue close command to cover."""
self._device.close_cover()
2022-01-10 14:54:09 +00:00
def open_cover(self, **kwargs: Any) -> None:
"""Issue open command to cover."""
self._device.open_cover()