mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 05:07:41 +00:00
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:
parent
b0f1c71129
commit
9861bd88b9
@ -843,24 +843,31 @@ class EntityPlatform:
|
||||
else:
|
||||
device = None
|
||||
|
||||
# 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:
|
||||
suggested_object_id = split_entity_id(entity.entity_id)[1]
|
||||
else:
|
||||
if device and entity.has_entity_name:
|
||||
device_name = device.name_by_user or device.name
|
||||
if entity.use_device_name:
|
||||
suggested_object_id = device_name
|
||||
else:
|
||||
suggested_object_id = (
|
||||
f"{device_name} {entity.suggested_object_id}"
|
||||
)
|
||||
if not suggested_object_id:
|
||||
suggested_object_id = entity.suggested_object_id
|
||||
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:
|
||||
suggested_object_id = split_entity_id(entity.entity_id)[1]
|
||||
else:
|
||||
if device and entity.has_entity_name:
|
||||
device_name = device.name_by_user or device.name
|
||||
if entity.use_device_name:
|
||||
suggested_object_id = device_name
|
||||
else:
|
||||
suggested_object_id = (
|
||||
f"{device_name} {entity.suggested_object_id}"
|
||||
)
|
||||
if not suggested_object_id:
|
||||
suggested_object_id = entity.suggested_object_id
|
||||
|
||||
if self.entity_namespace is not None:
|
||||
suggested_object_id = f"{self.entity_namespace} {suggested_object_id}"
|
||||
if self.entity_namespace is not None:
|
||||
suggested_object_id = (
|
||||
f"{self.entity_namespace} {suggested_object_id}"
|
||||
)
|
||||
|
||||
disabled_by: RegistryEntryDisabler | None = None
|
||||
if not entity.entity_registry_enabled_default:
|
||||
|
Loading…
x
Reference in New Issue
Block a user