fix(media_player): unique_id migration pre-checks for an existing entry holding the target MAC — falls back to the config-entry id on collision (t26 F4)
This commit is contained in:
1 parent
2e63135745
commit
3587747c72
1 file changed
+17
@@ -129,6 +129,23 @@ async def _migrate_legacy_unique_id(hass, entry) -> None:
|
|||||||
_name, new_id = info
|
_name, new_id = info
|
||||||
if not new_id:
|
if not new_id:
|
||||||
new_id = entry.entry_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)
|
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)
|
_LOGGER.info("P5-1: legacy unique_id %r migrated to %r", legacy, new_id)
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user