mirror of
https://github.com/home-assistant/core.git
synced 2025-07-20 19:57:07 +00:00
Add unique ID to demo fan (#39658)
This commit is contained in:
parent
f1ee11cb14
commit
05e15dc318
@ -18,8 +18,8 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=
|
|||||||
"""Set up the demo fan platform."""
|
"""Set up the demo fan platform."""
|
||||||
async_add_entities(
|
async_add_entities(
|
||||||
[
|
[
|
||||||
DemoFan(hass, "Living Room Fan", FULL_SUPPORT),
|
DemoFan(hass, "fan1", "Living Room Fan", FULL_SUPPORT),
|
||||||
DemoFan(hass, "Ceiling Fan", LIMITED_SUPPORT),
|
DemoFan(hass, "fan2", "Ceiling Fan", LIMITED_SUPPORT),
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -32,9 +32,12 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
|
|||||||
class DemoFan(FanEntity):
|
class DemoFan(FanEntity):
|
||||||
"""A demonstration fan component."""
|
"""A demonstration fan component."""
|
||||||
|
|
||||||
def __init__(self, hass, name: str, supported_features: int) -> None:
|
def __init__(
|
||||||
|
self, hass, unique_id: str, name: str, supported_features: int
|
||||||
|
) -> None:
|
||||||
"""Initialize the entity."""
|
"""Initialize the entity."""
|
||||||
self.hass = hass
|
self.hass = hass
|
||||||
|
self._unique_id = unique_id
|
||||||
self._supported_features = supported_features
|
self._supported_features = supported_features
|
||||||
self._speed = STATE_OFF
|
self._speed = STATE_OFF
|
||||||
self._oscillating = None
|
self._oscillating = None
|
||||||
@ -46,6 +49,11 @@ class DemoFan(FanEntity):
|
|||||||
if supported_features & SUPPORT_DIRECTION:
|
if supported_features & SUPPORT_DIRECTION:
|
||||||
self._direction = "forward"
|
self._direction = "forward"
|
||||||
|
|
||||||
|
@property
|
||||||
|
def unique_id(self):
|
||||||
|
"""Return the unique id."""
|
||||||
|
return self._unique_id
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def name(self) -> str:
|
def name(self) -> str:
|
||||||
"""Get entity name."""
|
"""Get entity name."""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user