From 3587747c72f805e0c469a6c1f7d88484bdfc2f78 Mon Sep 17 00:00:00 2001 From: James Mackay Date: Fri, 9 Oct 2026 06:11:36 +0100 Subject: [PATCH] =?UTF-8?q?fix(media=5Fplayer):=20unique=5Fid=20migration?= =?UTF-8?q?=20pre-checks=20for=20an=20existing=20entry=20holding=20the=20t?= =?UTF-8?q?arget=20MAC=20=E2=80=94=20falls=20back=20to=20the=20config-entr?= =?UTF-8?q?y=20id=20on=20collision=20(t26=20F4)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- custom_components/nvidia_shield/media_player.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) 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)