* rough in structure for config_flow * updated json files * initial conversion to config_flow * minor updates * Update binary_sensor.py * Update config_flow.py * Update __init__.py * updates beased on requested changes * Update const.py added doc note for ruff * updated based on suggestions * updated load xmldb for efficiency * updated references * removed unneeded file * updated config flow to use GUID from XML DB * minor update to change logging * updated based on PR feedback * reverted change for line 30 based on testing * corrected user_input * updated based on latest comments * exception handling * added raising of issues for config flow * updated issues strings * config flow test shell - needs work * minor changes * Update strings.json * Update config_flow.py * Update __init__.py * Create conftest.py * Update test_config_flow.py * Update test_config_flow.py * Update config_flow.py * Update strings.json * Update requirements_test_all.txt * Update strings.json * Update strings.json * Update config_flow.py * Update test_config_flow.py * Update config_flow.py * Create test_init.py * Update __init__.py * Delete tests/components/lutron/test_init.py * Update strings.json * updated import parts and tested * updated strings to improve user feedback --------- Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com>
50 lines
1.6 KiB
Python
50 lines
1.6 KiB
Python
"""Support for Lutron scenes."""
|
|
from __future__ import annotations
|
|
|
|
from typing import Any
|
|
|
|
from homeassistant.components.scene import Scene
|
|
from homeassistant.config_entries import ConfigEntry
|
|
from homeassistant.core import HomeAssistant
|
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
|
|
|
from . import LUTRON_CONTROLLER, LUTRON_DEVICES, LutronDevice
|
|
|
|
|
|
async def async_setup_entry(
|
|
hass: HomeAssistant,
|
|
config_entry: ConfigEntry,
|
|
async_add_entities: AddEntitiesCallback,
|
|
) -> None:
|
|
"""Set up the Lutron scene platform.
|
|
|
|
Adds scenes from the Main Repeater associated with the config_entry as
|
|
scene entities.
|
|
"""
|
|
entities = []
|
|
for scene_data in hass.data[LUTRON_DEVICES]["scene"]:
|
|
(area_name, keypad_name, device, led) = scene_data
|
|
entity = LutronScene(
|
|
area_name, keypad_name, device, led, hass.data[LUTRON_CONTROLLER]
|
|
)
|
|
entities.append(entity)
|
|
async_add_entities(entities, 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) -> None:
|
|
"""Activate the scene."""
|
|
self._lutron_device.press()
|
|
|
|
@property
|
|
def name(self) -> str:
|
|
"""Return the name of the device."""
|
|
return f"{self._area_name} {self._keypad_name}: {self._lutron_device.name}"
|