44 lines
1.1 KiB
Python
44 lines
1.1 KiB
Python
"""Support for VELUX scenes."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from typing import Any
|
|
|
|
from homeassistant.components.scene import Scene
|
|
from homeassistant.config_entries import ConfigEntry
|
|
from homeassistant.core import HomeAssistant
|
|
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
|
|
|
|
from .const import DOMAIN
|
|
|
|
PARALLEL_UPDATES = 1
|
|
|
|
|
|
async def async_setup_entry(
|
|
hass: HomeAssistant,
|
|
config: ConfigEntry,
|
|
async_add_entities: AddConfigEntryEntitiesCallback,
|
|
) -> None:
|
|
"""Set up the scenes for Velux platform."""
|
|
module = hass.data[DOMAIN][config.entry_id]
|
|
|
|
entities = [VeluxScene(scene) for scene in module.pyvlx.scenes]
|
|
async_add_entities(entities)
|
|
|
|
|
|
class VeluxScene(Scene):
|
|
"""Representation of a Velux scene."""
|
|
|
|
def __init__(self, scene):
|
|
"""Init velux scene."""
|
|
self.scene = scene
|
|
|
|
@property
|
|
def name(self):
|
|
"""Return the name of the scene."""
|
|
return self.scene.name
|
|
|
|
async def async_activate(self, **kwargs: Any) -> None:
|
|
"""Activate the scene."""
|
|
await self.scene.run(wait_for_completion=False)
|