1
0
mirror of https://github.com/home-assistant/core.git synced 2026-05-02 06:32:14 +01:00
Files
core/homeassistant/components/solarman/entity.py
SOLARMAN f3cea5160b Add solarman integration (#152525)
Co-authored-by: xiaozhouhhh <13588112144@163.com>
Co-authored-by: Joostlek <joostlek@outlook.com>
2026-03-24 16:09:14 +01:00

35 lines
1.1 KiB
Python

"""Base entity for the Solarman integration."""
from __future__ import annotations
from homeassistant.const import CONF_MAC, CONF_MODEL
from homeassistant.helpers.device_registry import CONNECTION_NETWORK_MAC, DeviceInfo
from homeassistant.helpers.update_coordinator import CoordinatorEntity
from .const import CONF_SN, DOMAIN, MODEL_NAME_MAP
from .coordinator import SolarmanDeviceUpdateCoordinator
class SolarmanEntity(CoordinatorEntity[SolarmanDeviceUpdateCoordinator]):
"""Defines a Solarman entity."""
_attr_has_entity_name = True
def __init__(self, coordinator: SolarmanDeviceUpdateCoordinator) -> None:
"""Initialize the Solarman entity."""
super().__init__(coordinator)
entry = coordinator.config_entry
sn = entry.data[CONF_SN]
model_id = entry.data[CONF_MODEL]
self._attr_device_info = DeviceInfo(
connections={(CONNECTION_NETWORK_MAC, entry.data[CONF_MAC])},
identifiers={(DOMAIN, sn)},
manufacturer="SOLARMAN",
model=MODEL_NAME_MAP[model_id],
model_id=model_id,
serial_number=sn,
)