forked from home-assistant/core
Small speedup to processing entity customize (#121271)
This commit is contained in:
@@ -1185,11 +1185,18 @@ class Entity(
|
|||||||
report_issue,
|
report_issue,
|
||||||
)
|
)
|
||||||
|
|
||||||
# Overwrite properties that have been set in the config file.
|
try:
|
||||||
if (customize := hass.data.get(DATA_CUSTOMIZE)) and (
|
# Most of the time this will already be
|
||||||
custom := customize.get(entity_id)
|
# set and since try is near zero cost
|
||||||
):
|
# on py3.11+ its faster to assume it is
|
||||||
attr.update(custom)
|
# 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 (
|
if (
|
||||||
self._context_set is not None
|
self._context_set is not None
|
||||||
|
Reference in New Issue
Block a user