diff --git a/esphome/cpp_generator.py b/esphome/cpp_generator.py index 55f49fcfa7..48b53b197a 100644 --- a/esphome/cpp_generator.py +++ b/esphome/cpp_generator.py @@ -845,7 +845,7 @@ async def templatable( if output_type is std_string: return FlashStringLiteral(value) # For non-string types, wrap constants in stateless lambdas so that - # TemplatableValue stores them as function pointers (4 bytes vs 8). + # TemplatableFn (used by TEMPLATABLE_VALUE macro) stores them as function pointers. if output_type is not None: from esphome.cpp_types import std_string diff --git a/tests/unit_tests/test_cpp_generator.py b/tests/unit_tests/test_cpp_generator.py index aef6d056b2..3c87e311c3 100644 --- a/tests/unit_tests/test_cpp_generator.py +++ b/tests/unit_tests/test_cpp_generator.py @@ -673,6 +673,7 @@ async def test_templatable__string_with_non_string_output_type() -> None: result = await cg.templatable("hello", [], ct.bool_) assert isinstance(result, cg.LambdaExpression) + assert result.capture == "" @pytest.mark.asyncio