Home Assistant Unofficial Reference 2024.12.1
entity.py
Go to the documentation of this file.
1 """Entity object for shared properties of Refoss entities."""
2 
3 from homeassistant.helpers.device_registry import CONNECTION_NETWORK_MAC, DeviceInfo
4 from homeassistant.helpers.update_coordinator import CoordinatorEntity
5 
6 from .bridge import RefossDataUpdateCoordinator
7 from .const import DOMAIN
8 
9 
10 class RefossEntity(CoordinatorEntity[RefossDataUpdateCoordinator]):
11  """Refoss entity."""
12 
13  _attr_has_entity_name = True
14 
15  def __init__(self, coordinator: RefossDataUpdateCoordinator, channel: int) -> None:
16  """Initialize the entity."""
17  super().__init__(coordinator)
18 
19  mac = coordinator.device.mac
20  self.channel_idchannel_id = channel
21  self._attr_unique_id_attr_unique_id = f"{mac}_{channel}"
22  self._attr_device_info_attr_device_info = DeviceInfo(
23  connections={(CONNECTION_NETWORK_MAC, mac)},
24  identifiers={(DOMAIN, mac)},
25  manufacturer="Refoss",
26  name=coordinator.device.dev_name,
27  )
None __init__(self, RefossDataUpdateCoordinator coordinator, int channel)
Definition: entity.py:15