Avoid unnecessary copying of variables when setting up automations (#124844)
parent
c4fd1cfc8f
commit
354f4491c8
|
@ -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,
|
||||
|
|
Loading…
Reference in New Issue