mirror of
https://github.com/home-assistant/core.git
synced 2025-07-25 14:17:45 +00:00
parent
36b722960a
commit
23e7638687
@ -37,24 +37,24 @@ async def async_setup_entry(hass: HomeAssistant, entry: HeosConfigEntry) -> bool
|
|||||||
for device in device_registry.devices.get_devices_for_config_entry_id(
|
for device in device_registry.devices.get_devices_for_config_entry_id(
|
||||||
entry.entry_id
|
entry.entry_id
|
||||||
):
|
):
|
||||||
for domain, player_id in device.identifiers:
|
for ident in device.identifiers:
|
||||||
if domain == DOMAIN and not isinstance(player_id, str):
|
if ident[0] != DOMAIN or isinstance(ident[1], str):
|
||||||
# Create set of identifiers excluding this integration
|
continue
|
||||||
identifiers = { # type: ignore[unreachable]
|
|
||||||
(domain, identifier)
|
player_id = int(ident[1]) # type: ignore[unreachable]
|
||||||
for domain, identifier in device.identifiers
|
|
||||||
if domain != DOMAIN
|
# Create set of identifiers excluding this integration
|
||||||
}
|
identifiers = {ident for ident in device.identifiers if ident[0] != DOMAIN}
|
||||||
migrated_identifiers = {(DOMAIN, str(player_id))}
|
migrated_identifiers = {(DOMAIN, str(player_id))}
|
||||||
# Add migrated if not already present in another device, which occurs if the user downgraded and then upgraded
|
# Add migrated if not already present in another device, which occurs if the user downgraded and then upgraded
|
||||||
if not device_registry.async_get_device(migrated_identifiers):
|
if not device_registry.async_get_device(migrated_identifiers):
|
||||||
identifiers.update(migrated_identifiers)
|
identifiers.update(migrated_identifiers)
|
||||||
if len(identifiers) > 0:
|
if len(identifiers) > 0:
|
||||||
device_registry.async_update_device(
|
device_registry.async_update_device(
|
||||||
device.id, new_identifiers=identifiers
|
device.id, new_identifiers=identifiers
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
device_registry.async_remove_device(device.id)
|
device_registry.async_remove_device(device.id)
|
||||||
break
|
break
|
||||||
|
|
||||||
coordinator = HeosCoordinator(hass, entry)
|
coordinator = HeosCoordinator(hass, entry)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user