1
0
mirror of https://github.com/home-assistant/core.git synced 2026-07-08 07:15:09 +01:00
Files
core/homeassistant/components/indevolt/entity.py
T
2026-06-22 19:21:49 +02:00

39 lines
1.3 KiB
Python

"""Base entity for Indevolt integration."""
from typing import override
from homeassistant.helpers.device_registry import CONNECTION_NETWORK_MAC, DeviceInfo
from homeassistant.helpers.update_coordinator import CoordinatorEntity
from .const import DOMAIN
from .coordinator import IndevoltCoordinator
class IndevoltEntity(CoordinatorEntity[IndevoltCoordinator]):
"""Base Indevolt entity with up-to-date device info."""
_attr_has_entity_name = True
@property
def serial_number(self) -> str:
"""Return the device serial number."""
return self.coordinator.serial_number
@property
@override
def device_info(self) -> DeviceInfo:
"""Return device information for registry."""
coordinator = self.coordinator
connections: set[tuple[str, str]] = set()
if coordinator.mac_address:
connections.add((CONNECTION_NETWORK_MAC, coordinator.mac_address))
return DeviceInfo(
identifiers={(DOMAIN, coordinator.serial_number)},
connections=connections,
manufacturer="INDEVOLT",
serial_number=coordinator.serial_number,
model=coordinator.device_model,
sw_version=coordinator.firmware_version,
hw_version=str(coordinator.generation),
)