Files
home-assistant-core/homeassistant/components/scene/lutron.py
T
cdheiser b2081c579b Improve Lutron RadioRA2 support, adding switches and scenes (#18330)
* Improve Lutron RadioRA2 support, adding switch and scene support.

- Update the version of pylutron to 0.2 which has various bug fixes.
- Switch to pylutron's per-device subscribe
- Add switch support, and configure any non-dimmable output as a switch.
- Add scene support, using any configured keypad button with a corresponding LED as a scene.

* Fixes for comments in pull request home-assistant/home-assistant#18330

* More fixes for comments in pull request #18330

* Remove unused imports

* Cleanup in docstrings for Lutron scene support.
2018-12-25 09:33:03 +01:00

54 lines
1.5 KiB
Python

"""
Support for Lutron scenes.
For more details about this platform, please refer to the documentation at
https://home-assistant.io/components/scene.lutron/
"""
import logging
from homeassistant.components.lutron import (
LutronDevice, LUTRON_DEVICES, LUTRON_CONTROLLER)
from homeassistant.components.scene import Scene
_LOGGER = logging.getLogger(__name__)
DEPENDENCIES = ['lutron']
def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up the Lutron scenes."""
devs = []
for scene_data in hass.data[LUTRON_DEVICES]['scene']:
(area_name, keypad_name, device, led) = scene_data
dev = LutronScene(area_name, keypad_name, device, led,
hass.data[LUTRON_CONTROLLER])
devs.append(dev)
add_entities(devs, True)
class LutronScene(LutronDevice, Scene):
"""Representation of a Lutron Scene."""
def __init__(self,
area_name,
keypad_name,
lutron_device,
lutron_led,
controller):
"""Initialize the scene/button."""
super().__init__(area_name, lutron_device, controller)
self._keypad_name = keypad_name
self._led = lutron_led
def activate(self):
"""Activate the scene."""
self._lutron_device.press()
@property
def name(self):
"""Return the name of the device."""
return "{} {}: {}".format(self._area_name,
self._keypad_name,
self._lutron_device.name)