32 lines
1.0 KiB
Python
32 lines
1.0 KiB
Python
"""Base entity helpers for Sternwarte."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from homeassistant.helpers.device_registry import DeviceInfo
|
|
from homeassistant.helpers.update_coordinator import CoordinatorEntity
|
|
|
|
from .coordinator import SternwarteDataUpdateCoordinator
|
|
from .const import DOMAIN
|
|
|
|
|
|
class SternwarteEntity(CoordinatorEntity[SternwarteDataUpdateCoordinator]):
|
|
"""Base Sternwarte entity."""
|
|
|
|
_attr_has_entity_name = True
|
|
|
|
def __init__(self, coordinator: SternwarteDataUpdateCoordinator, key: str) -> None:
|
|
super().__init__(coordinator)
|
|
self._attr_unique_id = f"{coordinator.config_entry.entry_id}_{key}"
|
|
|
|
@property
|
|
def device_info(self) -> DeviceInfo:
|
|
"""Return device information."""
|
|
host = self.coordinator.config_entry.data["host"]
|
|
return DeviceInfo(
|
|
identifiers={(DOMAIN, self.coordinator.config_entry.entry_id)},
|
|
name="Sternwarte",
|
|
manufacturer="W&T",
|
|
model="Web-IO 57630",
|
|
configuration_url=f"http://{host}",
|
|
)
|