2023-10-12 12:54:16 +00:00
|
|
|
"""Entities for the ViCare integration."""
|
2024-03-08 15:35:23 +00:00
|
|
|
|
2023-11-21 08:53:02 +00:00
|
|
|
from PyViCare.PyViCareDevice import Device as PyViCareDevice
|
|
|
|
from PyViCare.PyViCareDeviceConfig import PyViCareDeviceConfig
|
|
|
|
|
2023-10-12 12:54:16 +00:00
|
|
|
from homeassistant.helpers.device_registry import DeviceInfo
|
|
|
|
from homeassistant.helpers.entity import Entity
|
|
|
|
|
|
|
|
from .const import DOMAIN
|
|
|
|
|
|
|
|
|
|
|
|
class ViCareEntity(Entity):
|
|
|
|
"""Base class for ViCare entities."""
|
|
|
|
|
2023-10-12 19:06:09 +00:00
|
|
|
_attr_has_entity_name = True
|
|
|
|
|
2023-11-21 08:53:02 +00:00
|
|
|
def __init__(
|
|
|
|
self,
|
|
|
|
device_config: PyViCareDeviceConfig,
|
|
|
|
device: PyViCareDevice,
|
|
|
|
unique_id_suffix: str,
|
|
|
|
) -> None:
|
2023-10-12 12:54:16 +00:00
|
|
|
"""Initialize the entity."""
|
2023-11-21 08:53:02 +00:00
|
|
|
self._api = device
|
|
|
|
|
|
|
|
self._attr_unique_id = f"{device_config.getConfig().serial}-{unique_id_suffix}"
|
|
|
|
# valid for compressors, circuits, burners (HeatingDeviceWithComponent)
|
|
|
|
if hasattr(device, "id"):
|
|
|
|
self._attr_unique_id += f"-{device.id}"
|
2023-10-12 12:54:16 +00:00
|
|
|
|
|
|
|
self._attr_device_info = DeviceInfo(
|
|
|
|
identifiers={(DOMAIN, device_config.getConfig().serial)},
|
2023-10-22 14:52:38 +00:00
|
|
|
serial_number=device_config.getConfig().serial,
|
2023-10-12 12:54:16 +00:00
|
|
|
name=device_config.getModel(),
|
|
|
|
manufacturer="Viessmann",
|
|
|
|
model=device_config.getModel(),
|
|
|
|
configuration_url="https://developer.viessmann.com/",
|
|
|
|
)
|