2020-06-23 01:22:41 +00:00
|
|
|
"""DataUpdate Coordinator, and base Entity and Device models for Toon."""
|
2021-03-18 13:43:52 +00:00
|
|
|
from __future__ import annotations
|
|
|
|
|
2021-09-27 17:37:12 +00:00
|
|
|
from dataclasses import dataclass
|
|
|
|
|
2021-05-01 22:37:19 +00:00
|
|
|
from homeassistant.helpers.entity import DeviceInfo
|
2020-08-30 16:26:37 +00:00
|
|
|
from homeassistant.helpers.update_coordinator import CoordinatorEntity
|
2020-06-23 01:22:41 +00:00
|
|
|
|
|
|
|
from .const import DOMAIN
|
|
|
|
from .coordinator import ToonDataUpdateCoordinator
|
|
|
|
|
|
|
|
|
2022-03-21 13:20:35 +00:00
|
|
|
class ToonEntity(CoordinatorEntity[ToonDataUpdateCoordinator]):
|
2020-06-23 01:22:41 +00:00
|
|
|
"""Defines a base Toon entity."""
|
|
|
|
|
|
|
|
|
|
|
|
class ToonDisplayDeviceEntity(ToonEntity):
|
|
|
|
"""Defines a Toon display device entity."""
|
|
|
|
|
|
|
|
@property
|
2021-05-01 22:37:19 +00:00
|
|
|
def device_info(self) -> DeviceInfo:
|
2020-06-23 01:22:41 +00:00
|
|
|
"""Return device information about this thermostat."""
|
|
|
|
agreement = self.coordinator.data.agreement
|
2021-10-28 16:20:41 +00:00
|
|
|
return DeviceInfo(
|
|
|
|
identifiers={(DOMAIN, agreement.agreement_id)},
|
|
|
|
manufacturer="Eneco",
|
|
|
|
model=agreement.display_hardware_version.rpartition("/")[0],
|
|
|
|
name="Toon Display",
|
|
|
|
sw_version=agreement.display_software_version.rpartition("/")[-1],
|
|
|
|
)
|
2020-06-23 01:22:41 +00:00
|
|
|
|
|
|
|
|
|
|
|
class ToonElectricityMeterDeviceEntity(ToonEntity):
|
|
|
|
"""Defines a Electricity Meter device entity."""
|
|
|
|
|
|
|
|
@property
|
2021-05-01 22:37:19 +00:00
|
|
|
def device_info(self) -> DeviceInfo:
|
2020-06-23 01:22:41 +00:00
|
|
|
"""Return device information about this entity."""
|
|
|
|
agreement_id = self.coordinator.data.agreement.agreement_id
|
2021-10-22 10:52:33 +00:00
|
|
|
return DeviceInfo(
|
|
|
|
name="Electricity Meter",
|
2022-07-11 11:40:54 +00:00
|
|
|
identifiers={(DOMAIN, agreement_id, "electricity")}, # type: ignore[arg-type]
|
|
|
|
via_device=(DOMAIN, agreement_id, "meter_adapter"), # type: ignore[typeddict-item]
|
2021-10-22 10:52:33 +00:00
|
|
|
)
|
2020-06-23 01:22:41 +00:00
|
|
|
|
|
|
|
|
|
|
|
class ToonGasMeterDeviceEntity(ToonEntity):
|
|
|
|
"""Defines a Gas Meter device entity."""
|
|
|
|
|
|
|
|
@property
|
2021-05-01 22:37:19 +00:00
|
|
|
def device_info(self) -> DeviceInfo:
|
2020-06-23 01:22:41 +00:00
|
|
|
"""Return device information about this entity."""
|
|
|
|
agreement_id = self.coordinator.data.agreement.agreement_id
|
2021-10-22 10:52:33 +00:00
|
|
|
return DeviceInfo(
|
|
|
|
name="Gas Meter",
|
2022-07-11 11:40:54 +00:00
|
|
|
identifiers={(DOMAIN, agreement_id, "gas")}, # type: ignore[arg-type]
|
|
|
|
via_device=(DOMAIN, agreement_id, "electricity"), # type: ignore[typeddict-item]
|
2021-10-22 10:52:33 +00:00
|
|
|
)
|
2020-06-23 01:22:41 +00:00
|
|
|
|
|
|
|
|
2020-08-04 23:02:19 +00:00
|
|
|
class ToonWaterMeterDeviceEntity(ToonEntity):
|
|
|
|
"""Defines a Water Meter device entity."""
|
|
|
|
|
|
|
|
@property
|
2021-05-01 22:37:19 +00:00
|
|
|
def device_info(self) -> DeviceInfo:
|
2020-08-04 23:02:19 +00:00
|
|
|
"""Return device information about this entity."""
|
|
|
|
agreement_id = self.coordinator.data.agreement.agreement_id
|
2021-10-22 10:52:33 +00:00
|
|
|
return DeviceInfo(
|
|
|
|
name="Water Meter",
|
2022-07-11 11:40:54 +00:00
|
|
|
identifiers={(DOMAIN, agreement_id, "water")}, # type: ignore[arg-type]
|
|
|
|
via_device=(DOMAIN, agreement_id, "electricity"), # type: ignore[typeddict-item]
|
2021-10-22 10:52:33 +00:00
|
|
|
)
|
2020-08-04 23:02:19 +00:00
|
|
|
|
|
|
|
|
2020-06-23 01:22:41 +00:00
|
|
|
class ToonSolarDeviceEntity(ToonEntity):
|
|
|
|
"""Defines a Solar Device device entity."""
|
|
|
|
|
|
|
|
@property
|
2021-05-01 22:37:19 +00:00
|
|
|
def device_info(self) -> DeviceInfo:
|
2020-06-23 01:22:41 +00:00
|
|
|
"""Return device information about this entity."""
|
|
|
|
agreement_id = self.coordinator.data.agreement.agreement_id
|
2021-10-22 10:52:33 +00:00
|
|
|
return DeviceInfo(
|
|
|
|
name="Solar Panels",
|
2022-07-11 11:40:54 +00:00
|
|
|
identifiers={(DOMAIN, agreement_id, "solar")}, # type: ignore[arg-type]
|
|
|
|
via_device=(DOMAIN, agreement_id, "meter_adapter"), # type: ignore[typeddict-item]
|
2021-10-22 10:52:33 +00:00
|
|
|
)
|
2020-06-23 01:22:41 +00:00
|
|
|
|
|
|
|
|
|
|
|
class ToonBoilerModuleDeviceEntity(ToonEntity):
|
|
|
|
"""Defines a Boiler Module device entity."""
|
|
|
|
|
|
|
|
@property
|
2021-05-01 22:37:19 +00:00
|
|
|
def device_info(self) -> DeviceInfo:
|
2020-06-23 01:22:41 +00:00
|
|
|
"""Return device information about this entity."""
|
|
|
|
agreement_id = self.coordinator.data.agreement.agreement_id
|
2021-10-22 10:52:33 +00:00
|
|
|
return DeviceInfo(
|
|
|
|
name="Boiler Module",
|
|
|
|
manufacturer="Eneco",
|
2022-07-11 11:40:54 +00:00
|
|
|
identifiers={(DOMAIN, agreement_id, "boiler_module")}, # type: ignore[arg-type]
|
2021-10-22 10:52:33 +00:00
|
|
|
via_device=(DOMAIN, agreement_id),
|
|
|
|
)
|
2020-06-23 01:22:41 +00:00
|
|
|
|
|
|
|
|
|
|
|
class ToonBoilerDeviceEntity(ToonEntity):
|
|
|
|
"""Defines a Boiler device entity."""
|
|
|
|
|
|
|
|
@property
|
2021-05-01 22:37:19 +00:00
|
|
|
def device_info(self) -> DeviceInfo:
|
2020-06-23 01:22:41 +00:00
|
|
|
"""Return device information about this entity."""
|
|
|
|
agreement_id = self.coordinator.data.agreement.agreement_id
|
2021-10-22 10:52:33 +00:00
|
|
|
return DeviceInfo(
|
|
|
|
name="Boiler",
|
2022-07-11 11:40:54 +00:00
|
|
|
identifiers={(DOMAIN, agreement_id, "boiler")}, # type: ignore[arg-type]
|
|
|
|
via_device=(DOMAIN, agreement_id, "boiler_module"), # type: ignore[typeddict-item]
|
2021-10-22 10:52:33 +00:00
|
|
|
)
|
2021-09-27 17:37:12 +00:00
|
|
|
|
|
|
|
|
|
|
|
@dataclass
|
|
|
|
class ToonRequiredKeysMixin:
|
|
|
|
"""Mixin for required keys."""
|
|
|
|
|
|
|
|
section: str
|
|
|
|
measurement: str
|