Small speedup to processing entity customize (#121271)

This commit is contained in:
J. Nick Koston 2024-07-05 01:57:08 -05:00 committed by GitHub
parent cdb2ec4231
commit e71f6c5948
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1185,11 +1185,18 @@ class Entity(
report_issue,
)
# Overwrite properties that have been set in the config file.
if (customize := hass.data.get(DATA_CUSTOMIZE)) and (
custom := customize.get(entity_id)
):
attr.update(custom)
try:
# Most of the time this will already be
# set and since try is near zero cost
# on py3.11+ its faster to assume it is
# set and catch the exception if it is not.
customize = hass.data[DATA_CUSTOMIZE]
except KeyError:
pass
else:
# Overwrite properties that have been set in the config file.
if custom := customize.get(entity_id):
attr.update(custom)
if (
self._context_set is not None