Home Assistant Unofficial Reference 2024.12.1
entity.py
Go to the documentation of this file.
1 """Support for Xiaomi Yeelight WiFi color bulb."""
2 
3 from __future__ import annotations
4 
5 from homeassistant.config_entries import ConfigEntry
6 from homeassistant.helpers.device_registry import DeviceInfo
7 from homeassistant.helpers.entity import Entity
8 
9 from .const import DOMAIN
10 from .device import YeelightDevice
11 
12 
14  """Represents single Yeelight entity."""
15 
16  _attr_should_poll = False
17  _attr_has_entity_name = True
18 
19  def __init__(self, device: YeelightDevice, entry: ConfigEntry) -> None:
20  """Initialize the entity."""
21  self._device_device = device
22  self._unique_id_unique_id = entry.unique_id or entry.entry_id
23  self._attr_device_info_attr_device_info = DeviceInfo(
24  identifiers={(DOMAIN, self._unique_id_unique_id)},
25  name=self._device_device.name,
26  manufacturer="Yeelight",
27  model=self._device_device.model,
28  sw_version=self._device_device.fw_version,
29  )
30 
31  @property
32  def unique_id(self) -> str:
33  """Return the unique ID."""
34  return self._unique_id_unique_id
35 
36  @property
37  def available(self) -> bool:
38  """Return if bulb is available."""
39  return self._device_device.available
40 
41  async def async_update(self) -> None:
42  """Update the entity."""
43  await self._device_device.async_update()
None __init__(self, YeelightDevice device, ConfigEntry entry)
Definition: entity.py:19