2023-02-06 15:57:18 +00:00
|
|
|
"""Base entity definitions."""
|
2023-03-13 01:26:34 +00:00
|
|
|
from typing import Generic, TypeVar
|
|
|
|
|
|
|
|
from tplink_omada_client.devices import OmadaDevice
|
2023-02-06 15:57:18 +00:00
|
|
|
|
2023-03-01 07:02:34 +00:00
|
|
|
from homeassistant.helpers import device_registry as dr
|
2023-08-11 02:04:26 +00:00
|
|
|
from homeassistant.helpers.device_registry import DeviceInfo
|
2023-02-06 15:57:18 +00:00
|
|
|
from homeassistant.helpers.update_coordinator import CoordinatorEntity
|
|
|
|
|
|
|
|
from .const import DOMAIN
|
|
|
|
from .coordinator import OmadaCoordinator
|
|
|
|
|
2023-03-13 01:26:34 +00:00
|
|
|
T = TypeVar("T")
|
|
|
|
|
2023-02-06 15:57:18 +00:00
|
|
|
|
2023-03-13 01:26:34 +00:00
|
|
|
class OmadaDeviceEntity(CoordinatorEntity[OmadaCoordinator[T]], Generic[T]):
|
|
|
|
"""Common base class for all entities associated with Omada SDN Devices."""
|
2023-02-06 15:57:18 +00:00
|
|
|
|
2023-03-13 01:26:34 +00:00
|
|
|
def __init__(self, coordinator: OmadaCoordinator[T], device: OmadaDevice) -> None:
|
|
|
|
"""Initialize the device."""
|
2023-02-06 15:57:18 +00:00
|
|
|
super().__init__(coordinator)
|
|
|
|
self.device = device
|
2023-09-07 23:07:15 +00:00
|
|
|
self._attr_device_info = DeviceInfo(
|
|
|
|
connections={(dr.CONNECTION_NETWORK_MAC, device.mac)},
|
|
|
|
identifiers={(DOMAIN, device.mac)},
|
2023-02-06 15:57:18 +00:00
|
|
|
manufacturer="TP-Link",
|
2023-09-07 23:07:15 +00:00
|
|
|
model=device.model_display_name,
|
|
|
|
name=device.name,
|
2023-02-06 15:57:18 +00:00
|
|
|
)
|