mirror of
https://github.com/home-assistant/core.git
synced 2025-05-07 07:29:17 +00:00
Make lifx async_migrate_legacy_entries a callback (#75719)
This commit is contained in:
parent
f4e7436421
commit
2df20e7a42
@ -77,7 +77,7 @@ async def async_legacy_migration(
|
|||||||
}
|
}
|
||||||
# device.mac_addr is not the mac_address, its the serial number
|
# 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}
|
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
|
hass, hosts_by_serial, existing_serials, legacy_entry
|
||||||
)
|
)
|
||||||
if missing_discovery_count:
|
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 legacy_entry := async_get_legacy_entry(hass):
|
||||||
# If the legacy entry still exists, harvest the entities
|
# If the legacy entry still exists, harvest the entities
|
||||||
# that are moving to this config entry.
|
# 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
|
assert entry.unique_id is not None
|
||||||
domain_data = hass.data[DOMAIN]
|
domain_data = hass.data[DOMAIN]
|
||||||
|
@ -2,14 +2,15 @@
|
|||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from homeassistant.config_entries import ConfigEntry
|
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 homeassistant.helpers import device_registry as dr, entity_registry as er
|
||||||
|
|
||||||
from .const import _LOGGER, DOMAIN
|
from .const import _LOGGER, DOMAIN
|
||||||
from .discovery import async_init_discovery_flow
|
from .discovery import async_init_discovery_flow
|
||||||
|
|
||||||
|
|
||||||
async def async_migrate_legacy_entries(
|
@callback
|
||||||
|
def async_migrate_legacy_entries(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
discovered_hosts_by_serial: dict[str, str],
|
discovered_hosts_by_serial: dict[str, str],
|
||||||
existing_serials: set[str],
|
existing_serials: set[str],
|
||||||
@ -41,7 +42,8 @@ async def async_migrate_legacy_entries(
|
|||||||
return len(remaining_devices)
|
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
|
hass: HomeAssistant, legacy_entry_id: str, new_entry: ConfigEntry
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Move entities and devices to the new config entry."""
|
"""Move entities and devices to the new config entry."""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user