Home Assistant Unofficial Reference 2024.12.1
entity.py
Go to the documentation of this file.
1 """Aquacell entity."""
2 
3 from aioaquacell import Softener
4 
5 from homeassistant.helpers.device_registry import DeviceInfo
6 from homeassistant.helpers.update_coordinator import CoordinatorEntity
7 
8 from .const import DOMAIN
9 from .coordinator import AquacellCoordinator
10 
11 
12 class AquacellEntity(CoordinatorEntity[AquacellCoordinator]):
13  """Representation of an aquacell entity."""
14 
15  _attr_has_entity_name = True
16 
17  def __init__(
18  self,
19  coordinator: AquacellCoordinator,
20  softener_key: str,
21  entity_key: str,
22  ) -> None:
23  """Initialize the aquacell entity."""
24  super().__init__(coordinator)
25 
26  self.softener_keysoftener_key = softener_key
27 
28  self._attr_unique_id_attr_unique_id = f"{softener_key}-{entity_key}"
29  self._attr_device_info_attr_device_info = DeviceInfo(
30  name=self.softenersoftener.name,
31  hw_version=self.softenersoftener.fwVersion,
32  identifiers={(DOMAIN, str(softener_key))},
33  manufacturer=self.softenersoftener.brand,
34  model=self.softenersoftener.ssn,
35  serial_number=softener_key,
36  )
37 
38  @property
39  def softener(self) -> Softener:
40  """Handle updated data from the coordinator."""
41  return self.coordinator.data[self.softener_keysoftener_key]
None __init__(self, AquacellCoordinator coordinator, str softener_key, str entity_key)
Definition: entity.py:22