2021-04-11 22:36:44 +02:00
|
|
|
"""Base class for Rituals Perfume Genie diffuser entity."""
|
2021-04-17 15:41:45 +02:00
|
|
|
from __future__ import annotations
|
|
|
|
|
2023-08-11 04:04:26 +02:00
|
|
|
from homeassistant.helpers.device_registry import DeviceInfo
|
|
|
|
from homeassistant.helpers.entity import EntityDescription
|
2021-04-11 22:36:44 +02:00
|
|
|
from homeassistant.helpers.update_coordinator import CoordinatorEntity
|
|
|
|
|
2021-07-12 20:40:16 +02:00
|
|
|
from .const import DOMAIN
|
2023-04-30 17:07:55 +02:00
|
|
|
from .coordinator import RitualsDataUpdateCoordinator
|
2021-04-11 22:36:44 +02:00
|
|
|
|
|
|
|
MANUFACTURER = "Rituals Cosmetics"
|
2021-04-17 15:41:45 +02:00
|
|
|
MODEL = "The Perfume Genie"
|
|
|
|
MODEL2 = "The Perfume Genie 2.0"
|
2021-04-11 22:36:44 +02:00
|
|
|
|
|
|
|
|
2022-03-21 15:24:05 +01:00
|
|
|
class DiffuserEntity(CoordinatorEntity[RitualsDataUpdateCoordinator]):
|
2021-04-11 22:36:44 +02:00
|
|
|
"""Representation of a diffuser entity."""
|
|
|
|
|
2023-05-26 08:09:29 +02:00
|
|
|
_attr_has_entity_name = True
|
|
|
|
|
2021-04-17 15:41:45 +02:00
|
|
|
def __init__(
|
2021-05-04 14:47:17 +02:00
|
|
|
self,
|
|
|
|
coordinator: RitualsDataUpdateCoordinator,
|
2023-05-04 21:54:28 +02:00
|
|
|
description: EntityDescription,
|
2021-04-17 15:41:45 +02:00
|
|
|
) -> None:
|
2021-04-11 22:36:44 +02:00
|
|
|
"""Init from config, hookup diffuser and coordinator."""
|
|
|
|
super().__init__(coordinator)
|
2023-05-04 21:54:28 +02:00
|
|
|
self.entity_description = description
|
|
|
|
self._attr_unique_id = f"{coordinator.diffuser.hublot}-{description.key}"
|
2021-10-25 12:26:03 -04:00
|
|
|
self._attr_device_info = DeviceInfo(
|
2023-05-04 12:25:22 +02:00
|
|
|
identifiers={(DOMAIN, coordinator.diffuser.hublot)},
|
2021-10-25 12:26:03 -04:00
|
|
|
manufacturer=MANUFACTURER,
|
2023-04-30 21:32:14 +02:00
|
|
|
model=MODEL if coordinator.diffuser.has_battery else MODEL2,
|
2023-05-04 12:25:22 +02:00
|
|
|
name=coordinator.diffuser.name,
|
2023-04-30 21:32:14 +02:00
|
|
|
sw_version=coordinator.diffuser.version,
|
2021-10-25 12:26:03 -04:00
|
|
|
)
|
2021-04-11 22:36:44 +02:00
|
|
|
|
|
|
|
@property
|
2021-04-17 15:41:45 +02:00
|
|
|
def available(self) -> bool:
|
|
|
|
"""Return if the entity is available."""
|
2023-04-30 21:32:14 +02:00
|
|
|
return super().available and self.coordinator.diffuser.is_online
|