Skip to content

Commit

Permalink
Added Lutron Caseta Scene Support (home-assistant#8690)
Browse files Browse the repository at this point in the history
* added scene support

* Updated pylutron_caseta version number

* Updated pylutron_caseta version number

* Fixed lint errors

* fix style
  • Loading branch information
kfcook authored and pvizeli committed Jul 29, 2017
1 parent 1749859 commit d1b73a9
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 3 deletions.
8 changes: 6 additions & 2 deletions homeassistant/components/lutron_caseta.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__)

Expand All @@ -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."""
Expand All @@ -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
Expand Down
55 changes: 55 additions & 0 deletions homeassistant/components/scene/lutron_caseta.py
Original file line number Diff line number Diff line change
@@ -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)
2 changes: 1 addition & 1 deletion requirements_all.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit d1b73a9

Please sign in to comment.