* use correct serial * add migration handler * adjust init call * add missing types * adjust init call * adjust init call * adjust init call * adjust init call * Update types.py * fix loop * fix loop * fix parameter order * align parameter naming * remove comment * correct init * update * Update types.py * correct merge * revert type change * add test case * add helper * add test case * update snapshot * add snapshot * add device.serial data point * fix device unique id * update snapshot * add comments * update nmigration * fix missing parameter * move static parameters * fix circuit access * update device.serial * update snapshots * remove test case * Update binary_sensor.py * convert climate entity * Update entity.py * update snapshot * use snake case * add migration test * enhance test case * add test case * Apply suggestions from code review --------- Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com>
46 lines
1.5 KiB
Python
46 lines
1.5 KiB
Python
"""Entities for the ViCare integration."""
|
|
|
|
from PyViCare.PyViCareDevice import Device as PyViCareDevice
|
|
from PyViCare.PyViCareDeviceConfig import PyViCareDeviceConfig
|
|
from PyViCare.PyViCareHeatingDevice import (
|
|
HeatingDeviceWithComponent as PyViCareHeatingDeviceComponent,
|
|
)
|
|
|
|
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."""
|
|
|
|
_attr_has_entity_name = True
|
|
|
|
def __init__(
|
|
self,
|
|
unique_id_suffix: str,
|
|
device_config: PyViCareDeviceConfig,
|
|
device: PyViCareDevice,
|
|
component: PyViCareHeatingDeviceComponent | None = None,
|
|
) -> None:
|
|
"""Initialize the entity."""
|
|
gateway_serial = device_config.getConfig().serial
|
|
device_serial = device.getSerial()
|
|
identifier = f"{gateway_serial}_{device_serial}"
|
|
|
|
self._api: PyViCareDevice | PyViCareHeatingDeviceComponent = (
|
|
component if component else device
|
|
)
|
|
self._attr_unique_id = f"{identifier}-{unique_id_suffix}"
|
|
if component:
|
|
self._attr_unique_id += f"-{component.id}"
|
|
|
|
self._attr_device_info = DeviceInfo(
|
|
identifiers={(DOMAIN, identifier)},
|
|
serial_number=device_serial,
|
|
name=device_config.getModel(),
|
|
manufacturer="Viessmann",
|
|
model=device_config.getModel(),
|
|
configuration_url="https://developer.viessmann.com/",
|
|
)
|