1 """Insteon base entity."""
6 from pyinsteon
import devices
11 async_dispatcher_connect,
12 async_dispatcher_send,
18 SIGNAL_ADD_DEFAULT_LINKS,
25 from .utils
import print_aldb_to_log
27 _LOGGER = logging.getLogger(__name__)
31 """INSTEON abstract base entity."""
33 _attr_should_poll =
False
36 """Initialize the INSTEON binary sensor."""
41 """Return the hash of the Insteon Entity."""
46 """Return the address of the node."""
51 """Return the INSTEON group that the entity responds to."""
56 """Return a unique ID."""
60 uid = f
"{self._insteon_device.id}_{self._insteon_device_group.group}"
65 """Return the name of the node (used for Entity_ID)."""
67 if (description := self.
_insteon_device_insteon_device.description)
is None:
68 description =
"Unknown Device"
71 extension = f
" {extension}"
72 return f
"{description} {self._insteon_device.address}{extension}"
76 """Provide attributes for display on device card."""
78 "insteon_address": self.
addressaddress,
79 "insteon_group": self.
groupgroup,
84 """Return device information."""
87 manufacturer=
"SmartLabs, Inc",
89 f
"{self._insteon_device.model} ({self._insteon_device.cat!r},"
90 f
" 0x{self._insteon_device.subcat:02x})"
92 name=f
"{self._insteon_device.description} {self._insteon_device.address}",
94 f
"{self._insteon_device.firmware:02x} Engine Version:"
95 f
" {self._insteon_device.engine_version}"
97 via_device=(DOMAIN,
str(devices.modem.address)),
98 configuration_url=f
"homeassistant://insteon/device/config/{self._insteon_device.id}",
103 """Receive notification from transport that new data exists."""
105 "Received update for device %s group %d value %s",
113 """Register INSTEON update events."""
115 "Tracking updates for device %s group %d name %s",
121 load_signal = f
"{self.entity_id}_{SIGNAL_LOAD_ALDB}"
125 print_signal = f
"{self.entity_id}_{SIGNAL_PRINT_ALDB}"
127 default_links_signal = f
"{self.entity_id}_{SIGNAL_ADD_DEFAULT_LINKS}"
131 remove_signal = f
"{self._insteon_device.address.id}_{SIGNAL_REMOVE_ENTITY}"
136 functools.partial(self.
async_removeasync_remove, force_remove=
True),
141 """Unsubscribe to INSTEON update events."""
143 "Remove tracking updates for device %s group %d name %s",
151 """Call device load process and print to log."""
152 await self.
_insteon_device_insteon_device.aldb.async_load(refresh=reload)
157 """Print the device ALDB to the log file."""
161 """Get a single Insteon device property value (raw)."""
162 if (prop := self.
_insteon_device_insteon_device.properties.get(name))
is not None:
167 """Get the device label for grouped devices."""
173 label = f
"Group {self.group:d}"
177 """Add default links between the device and the modem."""
def extra_state_attributes(self)
def _async_add_default_links(self)
DeviceInfo device_info(self)
def async_will_remove_from_hass(self)
def _async_read_aldb(self, reload)
def async_entity_update(self, name, address, value, group)
def async_added_to_hass(self)
def get_device_property(self, str name)
def __init__(self, device, group)
None async_write_ha_state(self)
None async_on_remove(self, CALLBACK_TYPE func)
None async_remove(self, *bool force_remove=False)
def print_aldb_to_log(aldb)
Callable[[], None] subscribe(HomeAssistant hass, str topic, MessageCallbackType msg_callback, int qos=DEFAULT_QOS, str encoding="utf-8")
Callable[[], None] async_dispatcher_connect(HomeAssistant hass, str signal, Callable[..., Any] target)
None async_dispatcher_send(HomeAssistant hass, str signal, *Any args)