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