1 """Component for interacting with a Lutron Caseta system."""
3 from __future__
import annotations
12 from .const
import CONFIG_URL, DOMAIN, MANUFACTURER, UNASSIGNED_AREA
13 from .models
import LutronCasetaData
14 from .util
import area_name_from_id, serial_to_unique_id
16 _LOGGER = logging.getLogger(__name__)
20 """Common base class for all Lutron Caseta devices."""
22 _attr_should_poll =
False
24 def __init__(self, device: dict[str, Any], data: LutronCasetaData) ->
None:
25 """Set up the base class.
27 [:param]device the device metadata
28 [:param]bridge the smartbridge object
29 [:param]bridge_device a dict with the details of the bridge
35 if "serial" not in self.
_device_device:
38 if "parent_device" in device:
42 name = device[
"name"].split(
"_")[-1]
56 manufacturer=MANUFACTURER,
57 model=f
"{device['model']} ({device['type']})",
60 configuration_url=CONFIG_URL,
62 if area != UNASSIGNED_AREA:
63 info[ATTR_SUGGESTED_AREA] = area
67 """Register callbacks."""
71 """Handle None serial returned by RA3 and QSX processors."""
73 return f
"{self._bridge_unique_id}_{self.device_id}"
78 """Return the device ID used for calling pylutron_caseta."""
79 return self.
_device_device[
"device_id"]
83 """Return the serial number of the device."""
84 return self.
_device_device[
"serial"]
88 """Return the unique ID of the device (serial)."""
93 """Return the state attributes."""
98 attributes[
"zone_id"] = zone
103 """A lutron_caseta entity that can update by syncing data from the bridge."""
106 """Update when forcing a refresh of the device."""
None __init__(self, dict[str, Any] device, LutronCasetaData data)
def extra_state_attributes(self)
def async_added_to_hass(self)
str|int _handle_none_serial(self, str|int|None serial)
None async_write_ha_state(self)
web.Response get(self, web.Request request, str config_key)
str serial_to_unique_id(int serial)
str area_name_from_id(dict[str, dict] areas, str|None area_id)