From 354f4491c86741d4eecb2bc00e46f628ed0126d9 Mon Sep 17 00:00:00 2001 From: Erik Montnemery Date: Thu, 29 Aug 2024 13:03:47 +0200 Subject: [PATCH] Avoid unnecessary copying of variables when setting up automations (#124844) --- homeassistant/components/automation/__init__.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/homeassistant/components/automation/__init__.py b/homeassistant/components/automation/__init__.py index 8ab9c478bc4..2081ea938ae 100644 --- a/homeassistant/components/automation/__init__.py +++ b/homeassistant/components/automation/__init__.py @@ -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,