mirror of
https://github.com/home-assistant/core.git
synced 2026-01-25 09:02:38 +01:00
Co-authored-by: NjDaGreat <1754227@students.wits.ac.za> Co-authored-by: NjeruFluss <161302608+NjeruFluss@users.noreply.github.com> Co-authored-by: Josef Zweck <josef@zweck.dev> Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com>
40 lines
1.2 KiB
Python
40 lines
1.2 KiB
Python
"""Base entities for the Fluss+ integration."""
|
|
|
|
from homeassistant.helpers.device_registry import DeviceInfo
|
|
from homeassistant.helpers.update_coordinator import CoordinatorEntity
|
|
|
|
from .coordinator import FlussDataUpdateCoordinator
|
|
|
|
|
|
class FlussEntity(CoordinatorEntity[FlussDataUpdateCoordinator]):
|
|
"""Base class for Fluss entities."""
|
|
|
|
_attr_has_entity_name = True
|
|
|
|
def __init__(
|
|
self,
|
|
coordinator: FlussDataUpdateCoordinator,
|
|
device_id: str,
|
|
device: dict,
|
|
) -> None:
|
|
"""Initialize the entity with a device ID and device data."""
|
|
super().__init__(coordinator)
|
|
self.device_id = device_id
|
|
self._attr_unique_id = device_id
|
|
self._attr_device_info = DeviceInfo(
|
|
identifiers={("fluss", device_id)},
|
|
name=device.get("deviceName"),
|
|
manufacturer="Fluss",
|
|
model="Fluss+ Device",
|
|
)
|
|
|
|
@property
|
|
def available(self) -> bool:
|
|
"""Return if the device is available."""
|
|
return super().available and self.device_id in self.coordinator.data
|
|
|
|
@property
|
|
def device(self) -> dict:
|
|
"""Return the stored device data."""
|
|
return self.coordinator.data[self.device_id]
|