forked from home-assistant/core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeconz.py
44 lines (32 loc) · 1.09 KB
/
deconz.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
"""
Support for deCONZ scenes.
For more details about this platform, please refer to the documentation at
https://home-assistant.io/components/scene.deconz/
"""
import asyncio
from homeassistant.components.deconz import DOMAIN as DECONZ_DATA
from homeassistant.components.scene import Scene
DEPENDENCIES = ['deconz']
@asyncio.coroutine
def async_setup_platform(hass, config, async_add_devices, discovery_info=None):
"""Set up scenes for deCONZ component."""
if discovery_info is None:
return
scenes = hass.data[DECONZ_DATA].scenes
entities = []
for scene in scenes.values():
entities.append(DeconzScene(scene))
async_add_devices(entities)
class DeconzScene(Scene):
"""Representation of a deCONZ scene."""
def __init__(self, scene):
"""Set up a scene."""
self._scene = scene
@asyncio.coroutine
def async_activate(self, **kwargs):
"""Activate the scene."""
yield from self._scene.async_set_state({})
@property
def name(self):
"""Return the name of the scene."""
return self._scene.full_name