From 3a491035845dc84f44b960c95c997b5a0f1a8ed1 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Sat, 25 Oct 2025 10:31:13 -0700 Subject: [PATCH] touch ups --- esphome/components/template/select/__init__.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/esphome/components/template/select/__init__.py b/esphome/components/template/select/__init__.py index b998a1c2c7..93aa2c8b05 100644 --- a/esphome/components/template/select/__init__.py +++ b/esphome/components/template/select/__init__.py @@ -75,7 +75,10 @@ async def to_code(config): else: cg.add(var.set_optimistic(config[CONF_OPTIMISTIC])) initial_option_index = config[CONF_OPTIONS].index(config[CONF_INITIAL_OPTION]) - cg.add(var.set_initial_option_index(initial_option_index)) + # Only set if non-zero to avoid bloating setup() function + # (initial_option_index_ is zero-initialized in the header) + if initial_option_index != 0: + cg.add(var.set_initial_option_index(initial_option_index)) if CONF_RESTORE_VALUE in config: cg.add(var.set_restore_value(config[CONF_RESTORE_VALUE]))