diff --git a/custom_components/nvidia_shield/media_player.py b/custom_components/nvidia_shield/media_player.py index 37e308e..b9164ab 100644 --- a/custom_components/nvidia_shield/media_player.py +++ b/custom_components/nvidia_shield/media_player.py @@ -129,6 +129,23 @@ async def _migrate_legacy_unique_id(hass, entry) -> None: _name, new_id = info if not new_id: new_id = entry.entry_id + # t26 F4: another entry may already own the target MAC — the collision + # pre-check falls back to the config-entry id instead of re-binding the + # unique_id to a MAC that could collide with a real second instance. + other_entries = getattr( + getattr(hass, "config_entries", None), "entries", [] + ) or [] + if any( + getattr(other, "unique_id", None) == new_id + for other in other_entries + if getattr(other, "entry_id", None) != entry.entry_id + ): + _LOGGER.warning( + "P5-1: unique_id migration target %r already in use — falling " + "back to the config-entry id", + new_id, + ) + new_id = entry.entry_id hass.config_entries.async_update_entry(entry, unique_id=new_id) _LOGGER.info("P5-1: legacy unique_id %r migrated to %r", legacy, new_id)