mirror of
https://github.com/home-assistant/core.git
synced 2025-07-08 05:47:10 +00:00
Fix late review findings in Minecraft Server (#99865)
This commit is contained in:
parent
aff49cb67a
commit
23f4ccd4f1
@ -77,9 +77,8 @@ async def async_migrate_entry(hass: HomeAssistant, config_entry: ConfigEntry) ->
|
|||||||
|
|
||||||
# 1 --> 2: Use config entry ID as base for unique IDs.
|
# 1 --> 2: Use config entry ID as base for unique IDs.
|
||||||
if config_entry.version == 1:
|
if config_entry.version == 1:
|
||||||
assert config_entry.unique_id
|
|
||||||
assert config_entry.entry_id
|
|
||||||
old_unique_id = config_entry.unique_id
|
old_unique_id = config_entry.unique_id
|
||||||
|
assert old_unique_id
|
||||||
config_entry_id = config_entry.entry_id
|
config_entry_id = config_entry.entry_id
|
||||||
|
|
||||||
# Migrate config entry.
|
# Migrate config entry.
|
||||||
@ -94,7 +93,7 @@ async def async_migrate_entry(hass: HomeAssistant, config_entry: ConfigEntry) ->
|
|||||||
# Migrate entities.
|
# Migrate entities.
|
||||||
await er.async_migrate_entries(hass, config_entry_id, _migrate_entity_unique_id)
|
await er.async_migrate_entries(hass, config_entry_id, _migrate_entity_unique_id)
|
||||||
|
|
||||||
_LOGGER.info("Migration to version %s successful", config_entry.version)
|
_LOGGER.debug("Migration to version %s successful", config_entry.version)
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@ -108,7 +107,6 @@ async def _async_migrate_device_identifiers(
|
|||||||
for device_entry in dr.async_entries_for_config_entry(
|
for device_entry in dr.async_entries_for_config_entry(
|
||||||
device_registry, config_entry.entry_id
|
device_registry, config_entry.entry_id
|
||||||
):
|
):
|
||||||
assert device_entry
|
|
||||||
for identifier in device_entry.identifiers:
|
for identifier in device_entry.identifiers:
|
||||||
if identifier[1] == old_unique_id:
|
if identifier[1] == old_unique_id:
|
||||||
# Device found in registry. Update identifiers.
|
# Device found in registry. Update identifiers.
|
||||||
@ -138,7 +136,6 @@ async def _async_migrate_device_identifiers(
|
|||||||
@callback
|
@callback
|
||||||
def _migrate_entity_unique_id(entity_entry: er.RegistryEntry) -> dict[str, Any]:
|
def _migrate_entity_unique_id(entity_entry: er.RegistryEntry) -> dict[str, Any]:
|
||||||
"""Migrate the unique ID of an entity to the new format."""
|
"""Migrate the unique ID of an entity to the new format."""
|
||||||
assert entity_entry
|
|
||||||
|
|
||||||
# Different variants of unique IDs are available in version 1:
|
# Different variants of unique IDs are available in version 1:
|
||||||
# 1) SRV record: '<host>-srv-<entity_type>'
|
# 1) SRV record: '<host>-srv-<entity_type>'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user