From 2df20e7a42c23b65f11f13d51e19b6e75dfdab08 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Mon, 25 Jul 2022 13:21:43 -0500 Subject: [PATCH] Make lifx async_migrate_legacy_entries a callback (#75719) --- homeassistant/components/lifx/__init__.py | 4 ++-- homeassistant/components/lifx/migration.py | 8 +++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/homeassistant/components/lifx/__init__.py b/homeassistant/components/lifx/__init__.py index 8816226ff84..3faf69483d5 100644 --- a/homeassistant/components/lifx/__init__.py +++ b/homeassistant/components/lifx/__init__.py @@ -77,7 +77,7 @@ async def async_legacy_migration( } # device.mac_addr is not the mac_address, its the serial number hosts_by_serial = {device.mac_addr: device.ip_addr for device in discovered_devices} - missing_discovery_count = await async_migrate_legacy_entries( + missing_discovery_count = async_migrate_legacy_entries( hass, hosts_by_serial, existing_serials, legacy_entry ) if missing_discovery_count: @@ -180,7 +180,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: if legacy_entry := async_get_legacy_entry(hass): # If the legacy entry still exists, harvest the entities # that are moving to this config entry. - await async_migrate_entities_devices(hass, legacy_entry.entry_id, entry) + async_migrate_entities_devices(hass, legacy_entry.entry_id, entry) assert entry.unique_id is not None domain_data = hass.data[DOMAIN] diff --git a/homeassistant/components/lifx/migration.py b/homeassistant/components/lifx/migration.py index 1ff94daa92f..359480a4507 100644 --- a/homeassistant/components/lifx/migration.py +++ b/homeassistant/components/lifx/migration.py @@ -2,14 +2,15 @@ from __future__ import annotations from homeassistant.config_entries import ConfigEntry -from homeassistant.core import HomeAssistant +from homeassistant.core import HomeAssistant, callback from homeassistant.helpers import device_registry as dr, entity_registry as er from .const import _LOGGER, DOMAIN from .discovery import async_init_discovery_flow -async def async_migrate_legacy_entries( +@callback +def async_migrate_legacy_entries( hass: HomeAssistant, discovered_hosts_by_serial: dict[str, str], existing_serials: set[str], @@ -41,7 +42,8 @@ async def async_migrate_legacy_entries( return len(remaining_devices) -async def async_migrate_entities_devices( +@callback +def async_migrate_entities_devices( hass: HomeAssistant, legacy_entry_id: str, new_entry: ConfigEntry ) -> None: """Move entities and devices to the new config entry."""