1 """Base class for Lutron devices."""
3 from pylutron
import Keypad, Lutron, LutronEntity, LutronEvent
9 from .const
import DOMAIN
13 """Base class for Lutron entities."""
15 _attr_should_poll =
False
16 _attr_has_entity_name =
True
19 self, area_name: str, lutron_device: LutronEntity, controller: Lutron
21 """Initialize the device."""
27 """Register callbacks."""
31 """Request the state."""
34 """Update the entity's attributes."""
37 self, _device: LutronEntity, _context:
None, _event: LutronEvent, _params: dict
39 """Run when invoked by pylutron when the device state changes."""
41 self.schedule_update_ha_state()
45 """Return a unique ID."""
48 return f
"{self._controller.guid}_{self._lutron_device.legacy_uuid}"
49 return f
"{self._controller.guid}_{self._lutron_device.uuid}"
52 """Update the entity's state."""
58 """Representation of a Lutron device entity."""
61 self, area_name: str, lutron_device: LutronEntity, controller: Lutron
63 """Initialize the device."""
64 super().
__init__(area_name, lutron_device, controller)
67 manufacturer=
"Lutron",
68 name=lutron_device.name,
69 suggested_area=area_name,
70 via_device=(DOMAIN, controller.guid),
75 """Representation of a Lutron Keypad."""
80 lutron_device: LutronEntity,
84 """Initialize the device."""
85 super().
__init__(area_name, lutron_device, controller)
87 identifiers={(DOMAIN, keypad.id)},
88 manufacturer=
"Lutron",
91 if keypad.type ==
"MAIN_REPEATER":
94 self.
_attr_device_info_attr_device_info[ATTR_VIA_DEVICE] = (DOMAIN, controller.guid)
None async_added_to_hass(self)
None _request_state(self)
None _update_callback(self, LutronEntity _device, None _context, LutronEvent _event, dict _params)
None __init__(self, str area_name, LutronEntity lutron_device, Lutron controller)
None __init__(self, str area_name, LutronEntity lutron_device, Lutron controller)
None __init__(self, str area_name, LutronEntity lutron_device, Lutron controller, Keypad keypad)
bool add(self, _T matcher)
Callable[[], None] subscribe(HomeAssistant hass, str topic, MessageCallbackType msg_callback, int qos=DEFAULT_QOS, str encoding="utf-8")