1
mirror of https://github.com/home-assistant/core synced 2024-08-28 03:36:46 +02:00
ha-core/homeassistant/components/gree/entity.py
Joost Lekkerkerker 00e87b9dff
Migrate Gree to has entity name (#104739)
* Migrate Gree to has entity name

* Migrate Gree to has entity name
2023-12-07 22:47:52 +01:00

28 lines
982 B
Python

"""Entity object for shared properties of Gree entities."""
from homeassistant.helpers.device_registry import CONNECTION_NETWORK_MAC, DeviceInfo
from homeassistant.helpers.update_coordinator import CoordinatorEntity
from .bridge import DeviceDataUpdateCoordinator
from .const import DOMAIN
class GreeEntity(CoordinatorEntity[DeviceDataUpdateCoordinator]):
"""Generic Gree entity (base class)."""
_attr_has_entity_name = True
def __init__(
self, coordinator: DeviceDataUpdateCoordinator, desc: str | None = None
) -> None:
"""Initialize the entity."""
super().__init__(coordinator)
name = coordinator.device.device_info.name
mac = coordinator.device.device_info.mac
self._attr_unique_id = f"{mac}_{desc}"
self._attr_device_info = DeviceInfo(
connections={(CONNECTION_NETWORK_MAC, mac)},
identifiers={(DOMAIN, mac)},
manufacturer="Gree",
name=name,
)