Make lifx async_migrate_legacy_entries a callback (#75719)

This commit is contained in:
J. Nick Koston 2022-07-25 13:21:43 -05:00 committed by GitHub
parent f4e7436421
commit 2df20e7a42
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 5 deletions

View File

@ -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]

View File

@ -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."""