diff --git a/homeassistant/components/yeelight/binary_sensor.py b/homeassistant/components/yeelight/binary_sensor.py index 731751b66f3..4fe3709cdd2 100644 --- a/homeassistant/components/yeelight/binary_sensor.py +++ b/homeassistant/components/yeelight/binary_sensor.py @@ -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 def name(self): """Return the name of the sensor.""" diff --git a/tests/components/yeelight/test_init.py b/tests/components/yeelight/test_init.py index 86f5bad65da..d9c23cfa1a7 100644 --- a/tests/components/yeelight/test_init.py +++ b/tests/components/yeelight/test_init.py @@ -96,7 +96,7 @@ async def test_unique_ids_device(hass: HomeAssistant): await hass.async_block_till_done() 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_NIGHTLIGHT).unique_id == f"{ID}-nightlight" 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() 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_NIGHTLIGHT).unique_id