Add unique ID to demo fan (#39658)
This commit is contained in:
parent
f1ee11cb14
commit
05e15dc318
1 changed files with 11 additions and 3 deletions
|
@ -18,8 +18,8 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=
|
|||
"""Set up the demo fan platform."""
|
||||
async_add_entities(
|
||||
[
|
||||
DemoFan(hass, "Living Room Fan", FULL_SUPPORT),
|
||||
DemoFan(hass, "Ceiling Fan", LIMITED_SUPPORT),
|
||||
DemoFan(hass, "fan1", "Living Room Fan", FULL_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):
|
||||
"""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."""
|
||||
self.hass = hass
|
||||
self._unique_id = unique_id
|
||||
self._supported_features = supported_features
|
||||
self._speed = STATE_OFF
|
||||
self._oscillating = None
|
||||
|
@ -46,6 +49,11 @@ class DemoFan(FanEntity):
|
|||
if supported_features & SUPPORT_DIRECTION:
|
||||
self._direction = "forward"
|
||||
|
||||
@property
|
||||
def unique_id(self):
|
||||
"""Return the unique id."""
|
||||
return self._unique_id
|
||||
|
||||
@property
|
||||
def name(self) -> str:
|
||||
"""Get entity name."""
|
||||
|
|
Loading…
Add table
Reference in a new issue