2023-09-11 20:25:08 +00:00
|
|
|
"""Base entity for Withings."""
|
|
|
|
from __future__ import annotations
|
|
|
|
|
|
|
|
from homeassistant.helpers.device_registry import DeviceInfo
|
2023-09-26 07:17:11 +00:00
|
|
|
from homeassistant.helpers.update_coordinator import CoordinatorEntity
|
2023-09-11 20:25:08 +00:00
|
|
|
|
2023-10-12 11:42:00 +00:00
|
|
|
from .const import DOMAIN
|
2023-09-26 08:59:45 +00:00
|
|
|
from .coordinator import WithingsDataUpdateCoordinator
|
2023-09-11 20:25:08 +00:00
|
|
|
|
|
|
|
|
2023-09-26 07:17:11 +00:00
|
|
|
class WithingsEntity(CoordinatorEntity[WithingsDataUpdateCoordinator]):
|
|
|
|
"""Base class for withings entities."""
|
2023-09-11 20:25:08 +00:00
|
|
|
|
|
|
|
_attr_has_entity_name = True
|
|
|
|
|
|
|
|
def __init__(
|
2023-09-26 07:17:11 +00:00
|
|
|
self,
|
|
|
|
coordinator: WithingsDataUpdateCoordinator,
|
2023-10-12 11:42:00 +00:00
|
|
|
key: str,
|
2023-09-11 20:25:08 +00:00
|
|
|
) -> None:
|
2023-09-26 07:17:11 +00:00
|
|
|
"""Initialize the Withings entity."""
|
|
|
|
super().__init__(coordinator)
|
2023-10-12 11:42:00 +00:00
|
|
|
self._attr_unique_id = f"withings_{coordinator.config_entry.unique_id}_{key}"
|
2023-09-11 20:25:08 +00:00
|
|
|
self._attr_device_info = DeviceInfo(
|
2023-09-26 07:17:11 +00:00
|
|
|
identifiers={(DOMAIN, str(coordinator.config_entry.unique_id))},
|
|
|
|
manufacturer="Withings",
|
2023-09-11 20:25:08 +00:00
|
|
|
)
|