diff --git a/esphome/components/template/select/__init__.py b/esphome/components/template/select/__init__.py index fd2fd62f597..101b4ade608 100644 --- a/esphome/components/template/select/__init__.py +++ b/esphome/components/template/select/__init__.py @@ -66,8 +66,9 @@ CONFIG_SCHEMA = cv.All( async def to_code(config): # Use subclass with trigger only when set_action is configured - cls = TemplateSelectWithSetAction if CONF_SET_ACTION in config else TemplateSelect - var = cg.new_Pvariable(config[CONF_ID], cls) + if CONF_SET_ACTION in config: + 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])