From 89bd9b610e576b357e2697ab9f561cd75b833317 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Mon, 2 Feb 2026 02:48:00 +0100 Subject: [PATCH] modify in validation instead to avoid copy --- esphome/components/template/select/__init__.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/esphome/components/template/select/__init__.py b/esphome/components/template/select/__init__.py index 08c7c07132..da57e94b07 100644 --- a/esphome/components/template/select/__init__.py +++ b/esphome/components/template/select/__init__.py @@ -42,6 +42,11 @@ def validate(config): raise cv.Invalid( "Either optimistic mode must be enabled, or set_action must be set, to handle the option being set." ) + + # Use subclass with trigger only when set_action is configured + if CONF_SET_ACTION in config: + config[CONF_ID].type = TemplateSelectWithSetAction + return config @@ -65,10 +70,6 @@ CONFIG_SCHEMA = cv.All( async def to_code(config): - # Use subclass with trigger only when set_action is configured - if CONF_SET_ACTION in config: - config[CONF_ID] = config[CONF_ID].copy() - config[CONF_ID].type = TemplateSelectWithSetAction var = cg.new_Pvariable(config[CONF_ID]) await cg.register_component(var, config) await select.register_select(var, config, options=config[CONF_OPTIONS])