mirror of
https://github.com/home-assistant/core.git
synced 2025-07-16 17:57:11 +00:00
Added Lutron Caseta Scene Support (#8690)
* added scene support * Updated pylutron_caseta version number * Updated pylutron_caseta version number * Fixed lint errors * fix style
This commit is contained in:
parent
1749859cdf
commit
d1b73a96f4
@ -14,7 +14,7 @@ from homeassistant.const import CONF_HOST
|
|||||||
from homeassistant.helpers import discovery
|
from homeassistant.helpers import discovery
|
||||||
from homeassistant.helpers.entity import Entity
|
from homeassistant.helpers.entity import Entity
|
||||||
|
|
||||||
REQUIREMENTS = ['pylutron-caseta==0.2.6']
|
REQUIREMENTS = ['pylutron-caseta==0.2.7']
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -28,6 +28,10 @@ CONFIG_SCHEMA = vol.Schema({
|
|||||||
})
|
})
|
||||||
}, extra=vol.ALLOW_EXTRA)
|
}, extra=vol.ALLOW_EXTRA)
|
||||||
|
|
||||||
|
LUTRON_CASETA_COMPONENTS = [
|
||||||
|
'light', 'switch', 'cover', 'scene'
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
def setup(hass, base_config):
|
def setup(hass, base_config):
|
||||||
"""Set up the Lutron component."""
|
"""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])
|
_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)
|
discovery.load_platform(hass, component, DOMAIN, {}, config)
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
55
homeassistant/components/scene/lutron_caseta.py
Normal file
55
homeassistant/components/scene/lutron_caseta.py
Normal file
@ -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)
|
@ -624,7 +624,7 @@ pylitejet==0.1
|
|||||||
pyloopenergy==0.0.17
|
pyloopenergy==0.0.17
|
||||||
|
|
||||||
# homeassistant.components.lutron_caseta
|
# homeassistant.components.lutron_caseta
|
||||||
pylutron-caseta==0.2.6
|
pylutron-caseta==0.2.7
|
||||||
|
|
||||||
# homeassistant.components.lutron
|
# homeassistant.components.lutron
|
||||||
pylutron==0.1.0
|
pylutron==0.1.0
|
||||||
|
Loading…
x
Reference in New Issue
Block a user