Avoid working out suggested id in entity_platform when already registered (#144079)

If the entity is already registered, avoid trying to work
out the suggested_entity_id and suggested_object_id as
async_get_or_create will discard them anyways.
This commit is contained in:
J. Nick Koston 2025-05-02 04:44:38 -05:00 committed by GitHub
parent b0f1c71129
commit 9861bd88b9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -843,6 +843,11 @@ class EntityPlatform:
else:
device = None
if not registered_entity_id:
# Do not bother working out a suggested_object_id
# if the entity is already registered as it will
# be ignored.
#
# An entity may suggest the entity_id by setting entity_id itself
suggested_entity_id: str | None = entity.entity_id
if suggested_entity_id is not None:
@ -860,7 +865,9 @@ class EntityPlatform:
suggested_object_id = entity.suggested_object_id
if self.entity_namespace is not None:
suggested_object_id = f"{self.entity_namespace} {suggested_object_id}"
suggested_object_id = (
f"{self.entity_namespace} {suggested_object_id}"
)
disabled_by: RegistryEntryDisabler | None = None
if not entity.entity_registry_enabled_default: