Home Assistant Unofficial Reference 2024.12.1
entity.py
Go to the documentation of this file.
1 """Elmax integration common classes and utilities."""
2 
3 from __future__ import annotations
4 
5 from elmax_api.model.endpoint import DeviceEndpoint
6 
7 from homeassistant.helpers.device_registry import DeviceInfo
8 from homeassistant.helpers.update_coordinator import CoordinatorEntity
9 
10 from .const import DOMAIN
11 from .coordinator import ElmaxCoordinator
12 
13 
14 class ElmaxEntity(CoordinatorEntity[ElmaxCoordinator]):
15  """Wrapper for Elmax entities."""
16 
17  def __init__(
18  self,
19  elmax_device: DeviceEndpoint,
20  panel_version: str,
21  coordinator: ElmaxCoordinator,
22  ) -> None:
23  """Construct the object."""
24  super().__init__(coordinator=coordinator)
25  self._device_device = elmax_device
26  self._attr_unique_id_attr_unique_id = elmax_device.endpoint_id
27  self._attr_name_attr_name = elmax_device.name
28  self._attr_device_info_attr_device_info = DeviceInfo(
29  identifiers={(DOMAIN, coordinator.panel_entry.hash)},
30  name=coordinator.panel_entry.get_name_by_user(
31  coordinator.http_client.get_authenticated_username()
32  ),
33  manufacturer="Elmax",
34  model=panel_version,
35  sw_version=panel_version,
36  )
37 
38  @property
39  def available(self) -> bool:
40  """Return if entity is available."""
41  return super().available and self.coordinator.panel_entry.online
None __init__(self, DeviceEndpoint elmax_device, str panel_version, ElmaxCoordinator coordinator)
Definition: entity.py:22