Home Assistant Unofficial Reference 2024.12.1
entity.py
Go to the documentation of this file.
1 """The radiotherm integration base entity."""
2 
3 from abc import abstractmethod
4 
5 from homeassistant.core import callback
6 from homeassistant.helpers import device_registry as dr
7 from homeassistant.helpers.device_registry import DeviceInfo
8 from homeassistant.helpers.update_coordinator import CoordinatorEntity
9 
10 from .coordinator import RadioThermUpdateCoordinator
11 from .data import RadioThermUpdate
12 
13 
14 class RadioThermostatEntity(CoordinatorEntity[RadioThermUpdateCoordinator]):
15  """Base class for radiotherm entities."""
16 
17  _attr_has_entity_name = True
18 
19  def __init__(self, coordinator: RadioThermUpdateCoordinator) -> None:
20  """Initialize the entity."""
21  super().__init__(coordinator)
22  self.init_datainit_datainit_data = coordinator.init_data
23  self.devicedevice = coordinator.init_data.tstat
24  self._attr_device_info_attr_device_info = DeviceInfo(
25  name=self.init_datainit_datainit_data.name,
26  model=self.init_datainit_datainit_data.model,
27  manufacturer="Radio Thermostats",
28  sw_version=self.init_datainit_datainit_data.fw_version,
29  connections={(dr.CONNECTION_NETWORK_MAC, self.init_datainit_datainit_data.mac)},
30  )
31  self._process_data_process_data()
32 
33  @property
34  def data(self) -> RadioThermUpdate:
35  """Returnt the last update."""
36  return self.coordinator.data
37 
38  @callback
39  @abstractmethod
40  def _process_data(self) -> None:
41  """Update and validate the data from the thermostat."""
42 
43  @callback
44  def _handle_coordinator_update(self) -> None:
45  self._process_data_process_data()
46  return super()._handle_coordinator_update()
None __init__(self, RadioThermUpdateCoordinator coordinator)
Definition: entity.py:19