2022-08-07 03:28:30 +00:00
|
|
|
"""Support for LIFX lights."""
|
|
|
|
from __future__ import annotations
|
|
|
|
|
|
|
|
from aiolifx import products
|
|
|
|
|
|
|
|
from homeassistant.helpers import device_registry as dr
|
2023-08-11 02:04:26 +00:00
|
|
|
from homeassistant.helpers.device_registry import DeviceInfo
|
2022-08-07 03:28:30 +00:00
|
|
|
from homeassistant.helpers.update_coordinator import CoordinatorEntity
|
|
|
|
|
|
|
|
from .const import DOMAIN
|
2023-04-04 03:48:32 +00:00
|
|
|
from .coordinator import LIFXUpdateCoordinator
|
2022-08-07 03:28:30 +00:00
|
|
|
|
|
|
|
|
|
|
|
class LIFXEntity(CoordinatorEntity[LIFXUpdateCoordinator]):
|
|
|
|
"""Representation of a LIFX entity with a coordinator."""
|
|
|
|
|
2023-07-03 01:42:02 +00:00
|
|
|
_attr_has_entity_name = True
|
|
|
|
|
2022-08-07 03:28:30 +00:00
|
|
|
def __init__(self, coordinator: LIFXUpdateCoordinator) -> None:
|
|
|
|
"""Initialise the light."""
|
|
|
|
super().__init__(coordinator)
|
|
|
|
self.bulb = coordinator.device
|
|
|
|
self._attr_device_info = DeviceInfo(
|
|
|
|
identifiers={(DOMAIN, coordinator.serial_number)},
|
|
|
|
connections={(dr.CONNECTION_NETWORK_MAC, coordinator.mac_address)},
|
|
|
|
manufacturer="LIFX",
|
|
|
|
name=coordinator.label,
|
|
|
|
model=products.product_map.get(self.bulb.product, "LIFX Bulb"),
|
|
|
|
sw_version=self.bulb.host_firmware_version,
|
2022-12-05 02:31:08 +00:00
|
|
|
suggested_area=self.bulb.group,
|
2022-08-07 03:28:30 +00:00
|
|
|
)
|