core/homeassistant/components/overkiz/cover.py

35 lines
1.2 KiB
Python
Raw Normal View History

"""Support for Overkiz covers - shutters etc."""
from pyoverkiz.enums import UIClass
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import Platform
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from . import HomeAssistantOverkizData
from .const import DOMAIN
from .cover_entities.awning import Awning
from .cover_entities.generic_cover import OverkizGenericCover
from .cover_entities.vertical_cover import VerticalCover
async def async_setup_entry(
hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback
) -> None:
"""Set up the Overkiz covers from a config entry."""
data: HomeAssistantOverkizData = hass.data[DOMAIN][entry.entry_id]
entities: list[OverkizGenericCover] = [
Awning(device.device_url, data.coordinator)
for device in data.platforms[Platform.COVER]
if device.ui_class == UIClass.AWNING
]
entities += [
VerticalCover(device.device_url, data.coordinator)
for device in data.platforms[Platform.COVER]
if device.ui_class != UIClass.AWNING
]
async_add_entities(entities)