Avoid linear search of the entity registry in ps4 (#109723)
parent
440212ddce
commit
6fce8a5403
|
@ -120,9 +120,11 @@ async def async_migrate_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||
# Prevent changing entity_id. Updates entity registry.
|
||||
registry = er.async_get(hass)
|
||||
|
||||
for entity_id, e_entry in registry.entities.items():
|
||||
if e_entry.config_entry_id == entry.entry_id:
|
||||
for e_entry in registry.entities.get_entries_for_config_entry_id(
|
||||
entry.entry_id
|
||||
):
|
||||
unique_id = e_entry.unique_id
|
||||
entity_id = e_entry.entity_id
|
||||
|
||||
# Remove old entity entry.
|
||||
registry.async_remove(entity_id)
|
||||
|
|
|
@ -344,10 +344,12 @@ class PS4Device(MediaPlayerEntity):
|
|||
_LOGGER.info("Assuming status from registry")
|
||||
e_registry = er.async_get(self.hass)
|
||||
d_registry = dr.async_get(self.hass)
|
||||
for entity_id, entry in e_registry.entities.items():
|
||||
if entry.config_entry_id == self._entry_id:
|
||||
|
||||
for entry in e_registry.entities.get_entries_for_config_entry_id(
|
||||
self._entry_id
|
||||
):
|
||||
self._attr_unique_id = entry.unique_id
|
||||
self.entity_id = entity_id
|
||||
self.entity_id = entry.entity_id
|
||||
break
|
||||
for device in d_registry.devices.values():
|
||||
if self._entry_id in device.config_entries:
|
||||
|
|
Loading…
Reference in New Issue