1 """Base entity for the Chacon Dio entity."""
6 from dio_chacon_wifi_api
import DIOChaconAPIClient
11 from .const
import DOMAIN, MANUFACTURER
13 _LOGGER = logging.getLogger(__name__)
17 """Implements a common class elements representing the Chacon Dio entity."""
19 _attr_should_poll =
False
20 _attr_has_entity_name =
True
22 def __init__(self, client: DIOChaconAPIClient, device: dict[str, Any]) ->
None:
23 """Initialize Chacon Dio entity."""
27 self.target_id: str = device[
"id"]
29 self._attr_device_info: DeviceInfo |
None =
DeviceInfo(
30 identifiers={(DOMAIN, self.target_id)},
31 manufacturer=MANUFACTURER,
33 model=device[
"model"],
39 """Recomputes the attributes values."""
42 """Register the callback for server side events."""
44 self.
clientclient.set_callback_device_state_by_device(
49 """Receive callback for device state notification pushed from the server."""
51 _LOGGER.debug(
"Data received from server %s", data)
56 """Update the state when the entity is requested to."""
58 _LOGGER.debug(
"Update called for %s, %s", self, self.target_id)
59 data = await self.
clientclient.get_status_details([self.target_id])
60 _LOGGER.debug(
"Received data from server %s", data)
None __init__(self, DIOChaconAPIClient client, dict[str, Any] device)
None _update_attr(self, dict[str, Any] data)
None async_added_to_hass(self)
None callback_device_state(self, dict[str, Any] data)
None async_write_ha_state(self)