Remove Tile unique id migration (#134106)

pull/134104/head^2
Joost Lekkerkerker 2024-12-27 19:25:10 +01:00 committed by GitHub
parent a9ff5b8007
commit b9c2b3f7e3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 1 additions and 27 deletions

View File

@ -12,10 +12,9 @@ from pytile.tile import Tile
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME, Platform
from homeassistant.core import HomeAssistant, callback
from homeassistant.core import HomeAssistant
from homeassistant.exceptions import ConfigEntryAuthFailed, ConfigEntryNotReady
from homeassistant.helpers import aiohttp_client
from homeassistant.helpers.entity_registry import RegistryEntry, async_migrate_entries
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed
from homeassistant.util.async_ import gather_with_limited_concurrency
@ -41,31 +40,6 @@ class TileData:
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Set up Tile as config entry."""
@callback
def async_migrate_callback(entity_entry: RegistryEntry) -> dict | None:
"""Define a callback to migrate appropriate Tile entities to new unique IDs.
Old: tile_{uuid}
New: {username}_{uuid}
"""
if entity_entry.unique_id.startswith(entry.data[CONF_USERNAME]):
return None
new_unique_id = f"{entry.data[CONF_USERNAME]}_".join(
entity_entry.unique_id.split(f"{DOMAIN}_")
)
LOGGER.debug(
"Migrating entity %s from old unique ID '%s' to new unique ID '%s'",
entity_entry.entity_id,
entity_entry.unique_id,
new_unique_id,
)
return {"new_unique_id": new_unique_id}
await async_migrate_entries(hass, entry.entry_id, async_migrate_callback)
# Tile's API uses cookies to identify a consumer; in order to allow for multiple
# instances of this config entry, we use a new session each time:
websession = aiohttp_client.async_create_clientsession(hass)