2019-02-13 20:21:14 +00:00
|
|
|
"""Support for VELUX scenes."""
|
2017-07-08 14:12:19 +00:00
|
|
|
from homeassistant.components.scene import Scene
|
2019-03-21 05:56:46 +00:00
|
|
|
|
|
|
|
from . import _LOGGER, DATA_VELUX
|
2017-07-08 14:12:19 +00:00
|
|
|
|
|
|
|
|
2019-07-31 19:25:30 +00:00
|
|
|
async def async_setup_platform(hass, config, async_add_entities, discovery_info=None):
|
2019-02-13 20:21:14 +00:00
|
|
|
"""Set up the scenes for Velux platform."""
|
2017-07-08 14:12:19 +00:00
|
|
|
entities = []
|
|
|
|
for scene in hass.data[DATA_VELUX].pyvlx.scenes:
|
2018-02-14 14:00:45 +00:00
|
|
|
entities.append(VeluxScene(scene))
|
2018-08-24 14:37:30 +00:00
|
|
|
async_add_entities(entities)
|
2017-07-08 14:12:19 +00:00
|
|
|
|
|
|
|
|
|
|
|
class VeluxScene(Scene):
|
2019-02-13 20:21:14 +00:00
|
|
|
"""Representation of a Velux scene."""
|
2017-07-08 14:12:19 +00:00
|
|
|
|
2018-02-14 14:00:45 +00:00
|
|
|
def __init__(self, scene):
|
2017-07-08 14:12:19 +00:00
|
|
|
"""Init velux scene."""
|
2019-02-13 20:21:14 +00:00
|
|
|
_LOGGER.info("Adding Velux scene: %s", scene)
|
2017-07-08 14:12:19 +00:00
|
|
|
self.scene = scene
|
|
|
|
|
|
|
|
@property
|
|
|
|
def name(self):
|
|
|
|
"""Return the name of the scene."""
|
|
|
|
return self.scene.name
|
|
|
|
|
2018-02-24 18:24:33 +00:00
|
|
|
async def async_activate(self):
|
2017-07-08 14:12:19 +00:00
|
|
|
"""Activate the scene."""
|
2019-03-10 10:47:22 +00:00
|
|
|
await self.scene.run(wait_for_completion=False)
|