hass-core/homeassistant/components/tplink_omada/entity.py
MarkGodwin ce9a514667
TP-Link Omada integration (#81223)
* TP-Link Omada integration
Support for PoE config of network switch ports

* Bump omada client version

* Fixing tests

* Refactored site config flow

* Code review comments

* Fixed tests and device display name issue

* Bump isort to fix pre-commit hooks

* Hassfest for the win

* Omada code review

* Black

* More config flow test coverage

* Full coverage for omada config_flow

---------

Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
2023-02-06 10:57:18 -05:00

33 lines
1.1 KiB
Python

"""Base entity definitions."""
from tplink_omada_client.devices import OmadaSwitch, OmadaSwitchPortDetails
from homeassistant.helpers import device_registry
from homeassistant.helpers.entity import DeviceInfo
from homeassistant.helpers.update_coordinator import CoordinatorEntity
from .const import DOMAIN
from .coordinator import OmadaCoordinator
class OmadaSwitchDeviceEntity(
CoordinatorEntity[OmadaCoordinator[OmadaSwitchPortDetails]]
):
"""Common base class for all entities attached to Omada network switches."""
def __init__(
self, coordinator: OmadaCoordinator[OmadaSwitchPortDetails], device: OmadaSwitch
) -> None:
"""Initialize the switch."""
super().__init__(coordinator)
self.device = device
@property
def device_info(self) -> DeviceInfo:
"""Return information about the device."""
return DeviceInfo(
connections={(device_registry.CONNECTION_NETWORK_MAC, self.device.mac)},
identifiers={(DOMAIN, (self.device.mac))},
manufacturer="TP-Link",
model=self.device.model_display_name,
name=self.device.name,
)