2019-02-14 04:35:12 +00:00
|
|
|
"""Support for Lutron scenes."""
|
2020-04-21 01:07:50 +00:00
|
|
|
from typing import Any
|
2018-12-25 08:33:03 +00:00
|
|
|
|
|
|
|
from homeassistant.components.scene import Scene
|
|
|
|
|
2019-03-21 05:56:46 +00:00
|
|
|
from . import LUTRON_CONTROLLER, LUTRON_DEVICES, LutronDevice
|
|
|
|
|
2018-12-25 08:33:03 +00:00
|
|
|
|
|
|
|
def setup_platform(hass, config, add_entities, discovery_info=None):
|
|
|
|
"""Set up the Lutron scenes."""
|
|
|
|
devs = []
|
2019-07-31 19:25:30 +00:00
|
|
|
for scene_data in hass.data[LUTRON_DEVICES]["scene"]:
|
2018-12-25 08:33:03 +00:00
|
|
|
(area_name, keypad_name, device, led) = scene_data
|
2019-07-31 19:25:30 +00:00
|
|
|
dev = LutronScene(
|
|
|
|
area_name, keypad_name, device, led, hass.data[LUTRON_CONTROLLER]
|
|
|
|
)
|
2018-12-25 08:33:03 +00:00
|
|
|
devs.append(dev)
|
|
|
|
|
|
|
|
add_entities(devs, True)
|
|
|
|
|
|
|
|
|
|
|
|
class LutronScene(LutronDevice, Scene):
|
|
|
|
"""Representation of a Lutron Scene."""
|
|
|
|
|
2019-07-31 19:25:30 +00:00
|
|
|
def __init__(self, area_name, keypad_name, lutron_device, lutron_led, controller):
|
2018-12-25 08:33:03 +00:00
|
|
|
"""Initialize the scene/button."""
|
|
|
|
super().__init__(area_name, lutron_device, controller)
|
|
|
|
self._keypad_name = keypad_name
|
|
|
|
self._led = lutron_led
|
|
|
|
|
2020-04-21 01:07:50 +00:00
|
|
|
def activate(self, **kwargs: Any) -> None:
|
2018-12-25 08:33:03 +00:00
|
|
|
"""Activate the scene."""
|
|
|
|
self._lutron_device.press()
|
|
|
|
|
|
|
|
@property
|
|
|
|
def name(self):
|
|
|
|
"""Return the name of the device."""
|
2020-02-28 11:39:29 +00:00
|
|
|
return f"{self._area_name} {self._keypad_name}: {self._lutron_device.name}"
|