Avoid unnecessary copying of variables when setting up automations (#124844)

pull/124856/head
Erik Montnemery 2024-08-29 13:03:47 +02:00 committed by GitHub
parent c4fd1cfc8f
commit 354f4491c8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 6 additions and 6 deletions

View File

@ -991,15 +991,15 @@ async def _create_automation_entities(
# Add trigger variables to variables
variables = None
if CONF_TRIGGER_VARIABLES in config_block:
if CONF_TRIGGER_VARIABLES in config_block and CONF_VARIABLES in config_block:
variables = ScriptVariables(
dict(config_block[CONF_TRIGGER_VARIABLES].as_dict())
)
if CONF_VARIABLES in config_block:
if variables:
variables.variables.update(config_block[CONF_VARIABLES].as_dict())
else:
variables = config_block[CONF_VARIABLES]
variables.variables.update(config_block[CONF_VARIABLES].as_dict())
elif CONF_TRIGGER_VARIABLES in config_block:
variables = config_block[CONF_TRIGGER_VARIABLES]
elif CONF_VARIABLES in config_block:
variables = config_block[CONF_VARIABLES]
entity = AutomationEntity(
automation_id,