diff --git a/homeassistant/components/lutron_caseta.py b/homeassistant/components/lutron_caseta.py index e2ad733fb36ea9..dcb3347e9196c7 100644 --- a/homeassistant/components/lutron_caseta.py +++ b/homeassistant/components/lutron_caseta.py @@ -14,7 +14,7 @@ from homeassistant.helpers import discovery from homeassistant.helpers.entity import Entity -REQUIREMENTS = ['pylutron-caseta==0.2.6'] +REQUIREMENTS = ['pylutron-caseta==0.2.7'] _LOGGER = logging.getLogger(__name__) @@ -28,6 +28,10 @@ }) }, extra=vol.ALLOW_EXTRA) +LUTRON_CASETA_COMPONENTS = [ + 'light', 'switch', 'cover', 'scene' +] + def setup(hass, base_config): """Set up the Lutron component.""" @@ -44,7 +48,7 @@ def setup(hass, base_config): _LOGGER.info("Connected to Lutron smartbridge at %s", config[CONF_HOST]) - for component in ('light', 'switch', 'cover'): + for component in LUTRON_CASETA_COMPONENTS: discovery.load_platform(hass, component, DOMAIN, {}, config) return True diff --git a/homeassistant/components/scene/lutron_caseta.py b/homeassistant/components/scene/lutron_caseta.py new file mode 100644 index 00000000000000..b98f7f3e6ea467 --- /dev/null +++ b/homeassistant/components/scene/lutron_caseta.py @@ -0,0 +1,55 @@ +""" +Support for Lutron Caseta scenes. + +For more details about this platform, please refer to the documentation at +https://home-assistant.io/components/scene.lutron_caseta/ +""" +import logging + +from homeassistant.components.scene import Scene +from homeassistant.components.lutron_caseta import LUTRON_CASETA_SMARTBRIDGE + +_LOGGER = logging.getLogger(__name__) + +DEPENDENCIES = ['lutron_caseta'] + + +def setup_platform(hass, config, add_devices, discovery_info=None): + """Set up the Lutron Caseta lights.""" + devs = [] + bridge = hass.data[LUTRON_CASETA_SMARTBRIDGE] + scenes = bridge.get_scenes() + for scene in scenes: + dev = LutronCasetaScene(scenes[scene], bridge) + devs.append(dev) + + add_devices(devs, True) + + +class LutronCasetaScene(Scene): + """Representation of a Lutron Caseta scene.""" + + def __init__(self, scene, bridge): + """Initialize the Lutron Caseta scene.""" + self._scene_name = scene["name"] + self._scene_id = scene["scene_id"] + self._bridge = bridge + + @property + def name(self): + """Return the name of the scene.""" + return self._scene_name + + @property + def should_poll(self): + """Return that polling is not necessary.""" + return False + + @property + def is_on(self): + """There is no way of detecting if a scene is active (yet).""" + return False + + def activate(self, **kwargs): + """Activate the scene.""" + self._bridge.activate_scene(self._scene_id) diff --git a/requirements_all.txt b/requirements_all.txt index 5b140580140372..7220bd0cfc2338 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -624,7 +624,7 @@ pylitejet==0.1 pyloopenergy==0.0.17 # homeassistant.components.lutron_caseta -pylutron-caseta==0.2.6 +pylutron-caseta==0.2.7 # homeassistant.components.lutron pylutron==0.1.0