hass-core/homeassistant/components/refoss/entity.py
ashionky 3224224bf8
Add Sensor for Refoss Integration (#116965)
Co-authored-by: Robert Resch <robert@resch.dev>
2024-06-20 10:29:37 +02:00

27 lines
943 B
Python

"""Entity object for shared properties of Refoss entities."""
from homeassistant.helpers.device_registry import CONNECTION_NETWORK_MAC, DeviceInfo
from homeassistant.helpers.update_coordinator import CoordinatorEntity
from .bridge import RefossDataUpdateCoordinator
from .const import DOMAIN
class RefossEntity(CoordinatorEntity[RefossDataUpdateCoordinator]):
"""Refoss entity."""
_attr_has_entity_name = True
def __init__(self, coordinator: RefossDataUpdateCoordinator, channel: int) -> None:
"""Initialize the entity."""
super().__init__(coordinator)
mac = coordinator.device.mac
self.channel_id = channel
self._attr_unique_id = f"{mac}_{channel}"
self._attr_device_info = DeviceInfo(
connections={(CONNECTION_NETWORK_MAC, mac)},
identifiers={(DOMAIN, mac)},
manufacturer="Refoss",
name=coordinator.device.dev_name,
)