2019-02-14 04:35:12 +00:00
|
|
|
"""Support for Lutron Caseta scenes."""
|
2017-07-29 16:07:28 +00:00
|
|
|
import logging
|
|
|
|
|
2017-11-04 19:04:05 +00:00
|
|
|
from homeassistant.components.scene import Scene
|
2017-07-29 16:07:28 +00:00
|
|
|
|
2019-03-21 05:56:46 +00:00
|
|
|
from . import LUTRON_CASETA_SMARTBRIDGE
|
|
|
|
|
2017-07-29 16:07:28 +00:00
|
|
|
_LOGGER = logging.getLogger(__name__)
|
|
|
|
|
|
|
|
|
2019-07-31 19:25:30 +00:00
|
|
|
async def async_setup_platform(hass, config, async_add_entities, discovery_info=None):
|
2017-07-29 16:07:28 +00:00
|
|
|
"""Set up the Lutron Caseta lights."""
|
2020-03-22 16:35:01 +00:00
|
|
|
entities = []
|
2017-07-29 16:07:28 +00:00
|
|
|
bridge = hass.data[LUTRON_CASETA_SMARTBRIDGE]
|
|
|
|
scenes = bridge.get_scenes()
|
|
|
|
for scene in scenes:
|
2020-03-22 16:35:01 +00:00
|
|
|
entity = LutronCasetaScene(scenes[scene], bridge)
|
|
|
|
entities.append(entity)
|
2017-07-29 16:07:28 +00:00
|
|
|
|
2020-03-22 16:35:01 +00:00
|
|
|
async_add_entities(entities, True)
|
2017-07-29 16:07:28 +00:00
|
|
|
|
|
|
|
|
|
|
|
class LutronCasetaScene(Scene):
|
|
|
|
"""Representation of a Lutron Caseta scene."""
|
|
|
|
|
|
|
|
def __init__(self, scene, bridge):
|
|
|
|
"""Initialize the Lutron Caseta scene."""
|
2019-07-31 19:25:30 +00:00
|
|
|
self._scene_name = scene["name"]
|
|
|
|
self._scene_id = scene["scene_id"]
|
2017-07-29 16:07:28 +00:00
|
|
|
self._bridge = bridge
|
|
|
|
|
|
|
|
@property
|
|
|
|
def name(self):
|
|
|
|
"""Return the name of the scene."""
|
|
|
|
return self._scene_name
|
|
|
|
|
2018-10-01 06:56:50 +00:00
|
|
|
async def async_activate(self):
|
2017-07-29 16:07:28 +00:00
|
|
|
"""Activate the scene."""
|
|
|
|
self._bridge.activate_scene(self._scene_id)
|