mirror of
https://github.com/home-assistant/core.git
synced 2025-08-08 04:58:19 +00:00
Fixes
This commit is contained in:
parent
de5145f5a6
commit
543fc3f634
@ -192,20 +192,19 @@ async def async_migrate_entry(hass: HomeAssistant, entry: ScrapeConfigEntry) ->
|
|||||||
entity_reg = er.async_get(hass)
|
entity_reg = er.async_get(hass)
|
||||||
entities = er.async_entries_for_config_entry(entity_reg, entry.entry_id)
|
entities = er.async_entries_for_config_entry(entity_reg, entry.entry_id)
|
||||||
for entity in entities:
|
for entity in entities:
|
||||||
|
if entity.unique_id in old_to_new_sensor_id:
|
||||||
|
new_unique_id = old_to_new_sensor_id[old_unique_id]
|
||||||
_LOGGER.debug(
|
_LOGGER.debug(
|
||||||
(
|
|
||||||
"Migrating entity %s with unique id %s to new unique id %s",
|
"Migrating entity %s with unique id %s to new unique id %s",
|
||||||
entity.entity_id,
|
entity.entity_id,
|
||||||
entity.unique_id,
|
entity.unique_id,
|
||||||
old_to_new_sensor_id.get(entity.unique_id),
|
new_unique_id,
|
||||||
)
|
)
|
||||||
)
|
|
||||||
if entity.unique_id in old_to_new_sensor_id:
|
|
||||||
entity_reg.async_update_entity(
|
entity_reg.async_update_entity(
|
||||||
entity.entity_id,
|
entity.entity_id,
|
||||||
config_entry_id=entry.entry_id,
|
config_entry_id=entry.entry_id,
|
||||||
config_subentry_id=old_to_new_sensor_id[entity.unique_id],
|
config_subentry_id=new_unique_id,
|
||||||
new_unique_id=old_to_new_sensor_id[entity.unique_id],
|
new_unique_id=new_unique_id,
|
||||||
)
|
)
|
||||||
|
|
||||||
# Use the new sub config entry id as the unique id for the sensor device
|
# Use the new sub config entry id as the unique id for the sensor device
|
||||||
@ -213,21 +212,20 @@ async def async_migrate_entry(hass: HomeAssistant, entry: ScrapeConfigEntry) ->
|
|||||||
devices = dr.async_entries_for_config_entry(device_reg, entry.entry_id)
|
devices = dr.async_entries_for_config_entry(device_reg, entry.entry_id)
|
||||||
for device in devices:
|
for device in devices:
|
||||||
for identifier in device.identifiers:
|
for identifier in device.identifiers:
|
||||||
|
device_unique_id = identifier[1]
|
||||||
|
if device_unique_id in old_to_new_sensor_id:
|
||||||
|
new_unique_id = old_to_new_sensor_id[device_unique_id]
|
||||||
_LOGGER.debug(
|
_LOGGER.debug(
|
||||||
"Migrating device %s with identifiers %s to new unique id %s",
|
"Migrating device %s with identifiers %s to new unique id %s",
|
||||||
device.id,
|
device.id,
|
||||||
device.identifiers,
|
device.identifiers,
|
||||||
old_to_new_sensor_id.get(identifier[1]),
|
new_unique_id,
|
||||||
)
|
)
|
||||||
device_unique_id = identifier[1]
|
|
||||||
if device_unique_id in old_to_new_sensor_id:
|
|
||||||
device_reg.async_update_device(
|
device_reg.async_update_device(
|
||||||
device.id,
|
device.id,
|
||||||
add_config_entry_id=entry.entry_id,
|
add_config_entry_id=entry.entry_id,
|
||||||
add_config_subentry_id=old_to_new_sensor_id[device_unique_id],
|
add_config_subentry_id=new_unique_id,
|
||||||
new_identifiers={
|
new_identifiers={(DOMAIN, new_unique_id)},
|
||||||
(DOMAIN, old_to_new_sensor_id[device_unique_id])
|
|
||||||
},
|
|
||||||
)
|
)
|
||||||
|
|
||||||
# Remove the sensors as they are now subentries
|
# Remove the sensors as they are now subentries
|
||||||
|
Loading…
x
Reference in New Issue
Block a user