mirror of
https://github.com/home-assistant/core.git
synced 2025-07-21 12:17:07 +00:00
Fix yeelight binary sensor unique ID (#42562)
This commit is contained in:
parent
d9d21ab05e
commit
f499187835
@ -34,6 +34,11 @@ class YeelightNightlightModeSensor(YeelightEntity, BinarySensorEntity):
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def unique_id(self) -> str:
|
||||||
|
"""Return a unique ID."""
|
||||||
|
return f"{self._unique_id}-nightlight_sensor"
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def name(self):
|
def name(self):
|
||||||
"""Return the name of the sensor."""
|
"""Return the name of the sensor."""
|
||||||
|
@ -96,7 +96,7 @@ async def test_unique_ids_device(hass: HomeAssistant):
|
|||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
er = await entity_registry.async_get_registry(hass)
|
er = await entity_registry.async_get_registry(hass)
|
||||||
assert er.async_get(ENTITY_BINARY_SENSOR).unique_id == ID
|
assert er.async_get(ENTITY_BINARY_SENSOR).unique_id == f"{ID}-nightlight_sensor"
|
||||||
assert er.async_get(ENTITY_LIGHT).unique_id == ID
|
assert er.async_get(ENTITY_LIGHT).unique_id == ID
|
||||||
assert er.async_get(ENTITY_NIGHTLIGHT).unique_id == f"{ID}-nightlight"
|
assert er.async_get(ENTITY_NIGHTLIGHT).unique_id == f"{ID}-nightlight"
|
||||||
assert er.async_get(ENTITY_AMBILIGHT).unique_id == f"{ID}-ambilight"
|
assert er.async_get(ENTITY_AMBILIGHT).unique_id == f"{ID}-ambilight"
|
||||||
@ -120,7 +120,10 @@ async def test_unique_ids_entry(hass: HomeAssistant):
|
|||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
er = await entity_registry.async_get_registry(hass)
|
er = await entity_registry.async_get_registry(hass)
|
||||||
assert er.async_get(ENTITY_BINARY_SENSOR).unique_id == config_entry.entry_id
|
assert (
|
||||||
|
er.async_get(ENTITY_BINARY_SENSOR).unique_id
|
||||||
|
== f"{config_entry.entry_id}-nightlight_sensor"
|
||||||
|
)
|
||||||
assert er.async_get(ENTITY_LIGHT).unique_id == config_entry.entry_id
|
assert er.async_get(ENTITY_LIGHT).unique_id == config_entry.entry_id
|
||||||
assert (
|
assert (
|
||||||
er.async_get(ENTITY_NIGHTLIGHT).unique_id
|
er.async_get(ENTITY_NIGHTLIGHT).unique_id
|
||||||
|
Loading…
x
Reference in New Issue
Block a user