From 91b0b0dd70a590b43e516beb72a9ef0fee62c4bb Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Mon, 23 Mar 2026 20:47:44 -1000 Subject: [PATCH 1/2] Clarify color_mode lookup intent --- esphome/components/light/__init__.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/esphome/components/light/__init__.py b/esphome/components/light/__init__.py index 739f6959089..17553cf6962 100644 --- a/esphome/components/light/__init__.py +++ b/esphome/components/light/__init__.py @@ -265,8 +265,10 @@ async def setup_light_core_(light_var, config, output_var): if (initial_state_config := config.get(CONF_INITIAL_STATE)) is not None: # Emit a stateless lambda that constructs the initial state — values live # in flash as code, not stored in the LightState object (~40 bytes saved). - color_mode_str = initial_state_config.get(CONF_COLOR_MODE) - color_mode_expr = COLOR_MODES.get(color_mode_str, ColorMode.UNKNOWN) + # Map config string to C++ enum; defaults to UNKNOWN if not specified + color_mode_expr = COLOR_MODES.get( + initial_state_config.get(CONF_COLOR_MODE), ColorMode.UNKNOWN + ) initial_state = LightStateRTCState( color_mode_expr, initial_state_config.get(CONF_STATE, False), From 0bbc022311adc89d29581c14539fb697ea7b9b99 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Mon, 23 Mar 2026 21:27:53 -1000 Subject: [PATCH 2/2] =?UTF-8?q?Drop=20unnecessary=20COLOR=5FMODES=20lookup?= =?UTF-8?q?=20=E2=80=94=20codegen=20handles=20EStr=20correctly?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- esphome/components/light/__init__.py | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/esphome/components/light/__init__.py b/esphome/components/light/__init__.py index 17553cf6962..4090ca57c25 100644 --- a/esphome/components/light/__init__.py +++ b/esphome/components/light/__init__.py @@ -52,7 +52,6 @@ from .effects import ( validate_effects, ) from .types import ( # noqa - COLOR_MODES, AddressableLight, AddressableLightState, ColorMode, @@ -265,12 +264,8 @@ async def setup_light_core_(light_var, config, output_var): if (initial_state_config := config.get(CONF_INITIAL_STATE)) is not None: # Emit a stateless lambda that constructs the initial state — values live # in flash as code, not stored in the LightState object (~40 bytes saved). - # Map config string to C++ enum; defaults to UNKNOWN if not specified - color_mode_expr = COLOR_MODES.get( - initial_state_config.get(CONF_COLOR_MODE), ColorMode.UNKNOWN - ) initial_state = LightStateRTCState( - color_mode_expr, + initial_state_config.get(CONF_COLOR_MODE, ColorMode.UNKNOWN), initial_state_config.get(CONF_STATE, False), initial_state_config.get(CONF_BRIGHTNESS, 1.0), initial_state_config.get(CONF_COLOR_BRIGHTNESS, 1.0),