Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove Tile unique id migration #134106

Merged
merged 1 commit into from
Dec 27, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Remove Tile unique id migration
  • Loading branch information
joostlek committed Dec 27, 2024
commit 0aaa76dcb9221d0638058cde3f86f30b097d7c08
28 changes: 1 addition & 27 deletions homeassistant/components/tile/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,9 @@

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

Expand All @@ -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)
Expand Down