mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 19:27:45 +00:00
Avoid linear search of the entity registry in ps4 (#109723)
This commit is contained in:
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.
|
# Prevent changing entity_id. Updates entity registry.
|
||||||
registry = er.async_get(hass)
|
registry = er.async_get(hass)
|
||||||
|
|
||||||
for entity_id, e_entry in registry.entities.items():
|
for e_entry in registry.entities.get_entries_for_config_entry_id(
|
||||||
if e_entry.config_entry_id == entry.entry_id:
|
entry.entry_id
|
||||||
|
):
|
||||||
unique_id = e_entry.unique_id
|
unique_id = e_entry.unique_id
|
||||||
|
entity_id = e_entry.entity_id
|
||||||
|
|
||||||
# Remove old entity entry.
|
# Remove old entity entry.
|
||||||
registry.async_remove(entity_id)
|
registry.async_remove(entity_id)
|
||||||
|
@ -344,10 +344,12 @@ class PS4Device(MediaPlayerEntity):
|
|||||||
_LOGGER.info("Assuming status from registry")
|
_LOGGER.info("Assuming status from registry")
|
||||||
e_registry = er.async_get(self.hass)
|
e_registry = er.async_get(self.hass)
|
||||||
d_registry = dr.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._attr_unique_id = entry.unique_id
|
||||||
self.entity_id = entity_id
|
self.entity_id = entry.entity_id
|
||||||
break
|
break
|
||||||
for device in d_registry.devices.values():
|
for device in d_registry.devices.values():
|
||||||
if self._entry_id in device.config_entries:
|
if self._entry_id in device.config_entries:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user