2019-02-13 20:21:14 +00:00
|
|
|
"""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
|
|
|
|
|
2020-04-25 16:07:15 +00:00
|
|
|
from homeassistant.components.cover import CoverEntity
|
2021-12-24 13:06:14 +00:00
|
|
|
from homeassistant.config_entries import ConfigEntry
|
|
|
|
from homeassistant.core import HomeAssistant
|
|
|
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
2017-08-29 15:34:19 +00:00
|
|
|
|
2022-01-10 14:54:09 +00:00
|
|
|
from . import AbodeDevice, AbodeSystem
|
2019-10-13 18:01:04 +00:00
|
|
|
from .const import DOMAIN
|
2019-03-21 05:56:46 +00:00
|
|
|
|
2017-08-29 15:34:19 +00:00
|
|
|
|
2021-12-24 13:06:14 +00:00
|
|
|
async def async_setup_entry(
|
2022-01-10 14:54:09 +00:00
|
|
|
hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback
|
2021-12-24 13:06:14 +00:00
|
|
|
) -> None:
|
2017-08-29 15:34:19 +00:00
|
|
|
"""Set up Abode cover devices."""
|
2022-01-10 14:54:09 +00:00
|
|
|
data: AbodeSystem = hass.data[DOMAIN]
|
2017-08-29 15:34:19 +00:00
|
|
|
|
2019-11-09 06:35:45 +00:00
|
|
|
entities = []
|
|
|
|
|
2017-09-18 15:39:41 +00:00
|
|
|
for device in data.abode.get_devices(generic_type=CONST.TYPE_COVER):
|
2019-11-09 06:35:45 +00:00
|
|
|
entities.append(AbodeCover(data, device))
|
2017-09-18 15:39:41 +00:00
|
|
|
|
2019-11-09 06:35:45 +00:00
|
|
|
async_add_entities(entities)
|
2017-08-29 15:34:19 +00:00
|
|
|
|
|
|
|
|
2020-04-25 16:07:15 +00:00
|
|
|
class AbodeCover(AbodeDevice, CoverEntity):
|
2017-08-29 15:34:19 +00:00
|
|
|
"""Representation of an Abode cover."""
|
|
|
|
|
2022-01-10 14:54:09 +00:00
|
|
|
_device: AbodeCV
|
|
|
|
|
2017-08-29 15:34:19 +00:00
|
|
|
@property
|
2022-01-10 14:54:09 +00:00
|
|
|
def is_closed(self) -> bool:
|
2017-08-29 15:34:19 +00:00
|
|
|
"""Return true if cover is closed, else False."""
|
2017-09-18 15:39:41 +00:00
|
|
|
return not self._device.is_open
|
2017-08-29 15:34:19 +00:00
|
|
|
|
2022-01-10 14:54:09 +00:00
|
|
|
def close_cover(self, **kwargs: Any) -> None:
|
2017-08-29 15:34:19 +00:00
|
|
|
"""Issue close command to cover."""
|
|
|
|
self._device.close_cover()
|
|
|
|
|
2022-01-10 14:54:09 +00:00
|
|
|
def open_cover(self, **kwargs: Any) -> None:
|
2017-08-29 15:34:19 +00:00
|
|
|
"""Issue open command to cover."""
|
|
|
|
self._device.open_cover()
|