2023-06-10 07:21:33 +00:00
|
|
|
"""Entity class for Renson ventilation unit."""
|
2024-03-08 14:05:07 +00:00
|
|
|
|
2023-06-10 07:21:33 +00:00
|
|
|
from __future__ import annotations
|
|
|
|
|
|
|
|
from renson_endura_delta.field_enum import (
|
|
|
|
DEVICE_NAME_FIELD,
|
|
|
|
FIRMWARE_VERSION_FIELD,
|
|
|
|
HARDWARE_VERSION_FIELD,
|
|
|
|
MAC_ADDRESS,
|
|
|
|
)
|
|
|
|
from renson_endura_delta.renson import RensonVentilation
|
|
|
|
|
2023-08-11 02:04:26 +00:00
|
|
|
from homeassistant.helpers.device_registry import DeviceInfo
|
2023-06-10 07:21:33 +00:00
|
|
|
from homeassistant.helpers.update_coordinator import CoordinatorEntity
|
|
|
|
|
|
|
|
from .const import DOMAIN
|
2023-09-20 06:47:20 +00:00
|
|
|
from .coordinator import RensonCoordinator
|
2023-06-10 07:21:33 +00:00
|
|
|
|
|
|
|
|
2023-06-11 00:28:32 +00:00
|
|
|
class RensonEntity(CoordinatorEntity[RensonCoordinator]):
|
2023-06-10 07:21:33 +00:00
|
|
|
"""Renson entity."""
|
|
|
|
|
|
|
|
def __init__(
|
|
|
|
self, name: str, api: RensonVentilation, coordinator: RensonCoordinator
|
|
|
|
) -> None:
|
|
|
|
"""Initialize the Renson entity."""
|
|
|
|
super().__init__(coordinator)
|
|
|
|
|
|
|
|
self._attr_device_info = DeviceInfo(
|
|
|
|
identifiers={
|
|
|
|
(DOMAIN, api.get_field_value(coordinator.data, MAC_ADDRESS.name))
|
|
|
|
},
|
|
|
|
manufacturer="Renson",
|
|
|
|
model=api.get_field_value(coordinator.data, DEVICE_NAME_FIELD.name),
|
|
|
|
name="Ventilation",
|
|
|
|
sw_version=api.get_field_value(
|
|
|
|
coordinator.data, FIRMWARE_VERSION_FIELD.name
|
|
|
|
),
|
|
|
|
hw_version=api.get_field_value(
|
|
|
|
coordinator.data, HARDWARE_VERSION_FIELD.name
|
|
|
|
),
|
|
|
|
)
|
|
|
|
|
|
|
|
self.api = api
|
|
|
|
|
|
|
|
self._attr_unique_id = (
|
|
|
|
api.get_field_value(coordinator.data, MAC_ADDRESS.name) + f"{name}"
|
|
|
|
)
|