Migrate Gree to has entity name (#104739)

* Migrate Gree to has entity name

* Migrate Gree to has entity name
This commit is contained in:
Joost Lekkerkerker 2023-12-07 22:47:52 +01:00 committed by GitHub
parent c4d77877d2
commit 00e87b9dff
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 58 additions and 49 deletions

View file

@ -9,13 +9,15 @@ from .const import DOMAIN
class GreeEntity(CoordinatorEntity[DeviceDataUpdateCoordinator]):
"""Generic Gree entity (base class)."""
def __init__(self, coordinator: DeviceDataUpdateCoordinator, desc: str) -> None:
_attr_has_entity_name = True
def __init__(
self, coordinator: DeviceDataUpdateCoordinator, desc: str | None = None
) -> None:
"""Initialize the entity."""
super().__init__(coordinator)
self._desc = desc
name = coordinator.device.device_info.name
mac = coordinator.device.device_info.mac
self._attr_name = f"{name} {desc}"
self._attr_unique_id = f"{mac}_{desc}"
self._attr_device_info = DeviceInfo(
connections={(CONNECTION_NETWORK_MAC, mac)},