-
Notifications
You must be signed in to change notification settings - Fork 6
/
scene.py
executable file
·41 lines (30 loc) · 1.23 KB
/
scene.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
"""Support for Lutron scenes."""
import logging
from typing import Any
from homeassistant.components.scene import Scene
from . import LUTRON_CONTROLLER, LUTRON_DEVICES, LutronDevice
_LOGGER = logging.getLogger(__name__)
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, **kwargs: Any):
"""Activate the scene."""
self._lutron_device.press()
@property
def name(self):
"""Return the name of the device."""
return f"{self._area_name} {self._keypad_name}: {self._lutron_device.name}"