Home Assistant Unofficial Reference 2024.12.1
scene.py
Go to the documentation of this file.
1 """Support for Lutron scenes."""
2 
3 from __future__ import annotations
4 
5 from typing import Any
6 
7 from pylutron import Button, Keypad, Lutron
8 
9 from homeassistant.components.scene import Scene
10 from homeassistant.config_entries import ConfigEntry
11 from homeassistant.core import HomeAssistant
12 from homeassistant.helpers.entity_platform import AddEntitiesCallback
13 
14 from . import DOMAIN, LutronData
15 from .entity import LutronKeypad
16 
17 
19  hass: HomeAssistant,
20  config_entry: ConfigEntry,
21  async_add_entities: AddEntitiesCallback,
22 ) -> None:
23  """Set up the Lutron scene platform.
24 
25  Adds scenes from the Main Repeater associated with the config_entry as
26  scene entities.
27  """
28  entry_data: LutronData = hass.data[DOMAIN][config_entry.entry_id]
29 
31  LutronScene(area_name, keypad, device, entry_data.client)
32  for area_name, keypad, device, led in entry_data.scenes
33  )
34 
35 
37  """Representation of a Lutron Scene."""
38 
39  _lutron_device: Button
40 
41  def __init__(
42  self,
43  area_name: str,
44  keypad: Keypad,
45  lutron_device: Button,
46  controller: Lutron,
47  ) -> None:
48  """Initialize the scene/button."""
49  super().__init__(area_name, lutron_device, controller, keypad)
50  self._attr_name_attr_name = lutron_device.name
51 
52  def activate(self, **kwargs: Any) -> None:
53  """Activate the scene."""
54  self._lutron_device_lutron_device.tap()
None __init__(self, str area_name, Keypad keypad, Button lutron_device, Lutron controller)
Definition: scene.py:47
None async_setup_entry(HomeAssistant hass, ConfigEntry config_entry, AddEntitiesCallback async_add_entities)
Definition: scene.py:22