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
13
class
YeelightEntity
(
Entity
):
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
()
homeassistant.components.yeelight.entity.YeelightEntity
Definition:
entity.py:13
homeassistant.components.yeelight.entity.YeelightEntity.__init__
None __init__(self, YeelightDevice device, ConfigEntry entry)
Definition:
entity.py:19
homeassistant.components.yeelight.entity.YeelightEntity._unique_id
_unique_id
Definition:
entity.py:22
homeassistant.components.yeelight.entity.YeelightEntity.async_update
None async_update(self)
Definition:
entity.py:41
homeassistant.components.yeelight.entity.YeelightEntity.available
bool available(self)
Definition:
entity.py:37
homeassistant.components.yeelight.entity.YeelightEntity._attr_device_info
_attr_device_info
Definition:
entity.py:23
homeassistant.components.yeelight.entity.YeelightEntity._device
_device
Definition:
entity.py:21
homeassistant.components.yeelight.entity.YeelightEntity.unique_id
str unique_id(self)
Definition:
entity.py:32
homeassistant.helpers.device_registry.DeviceInfo
Definition:
device_registry.py:98
homeassistant.helpers.entity.Entity
Definition:
entity.py:433
homeassistant.config_entries
Definition:
config_entries.py:1
homeassistant.helpers.device_registry
Definition:
device_registry.py:1
homeassistant.helpers.entity
Definition:
entity.py:1
core
homeassistant
components
yeelight
entity.py
Generated by
1.9.1