From 43183c33ba3e5cea7e7fb10e67ff0d932584052d Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Tue, 7 Apr 2026 19:27:16 -1000 Subject: [PATCH 1/2] [esp32_ble_tracker] Wrap continuous bool via cg.templatable for TemplatableFn --- esphome/components/esp32_ble_tracker/__init__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/esphome/components/esp32_ble_tracker/__init__.py b/esphome/components/esp32_ble_tracker/__init__.py index b9c4c28ccf..d758b400c4 100644 --- a/esphome/components/esp32_ble_tracker/__init__.py +++ b/esphome/components/esp32_ble_tracker/__init__.py @@ -378,7 +378,8 @@ async def esp32_ble_tracker_start_scan_action_to_code( ): paren = await cg.get_variable(config[CONF_ID]) var = cg.new_Pvariable(action_id, template_arg, paren) - cg.add(var.set_continuous(config[CONF_CONTINUOUS])) + template_ = await cg.templatable(config[CONF_CONTINUOUS], args, cg.bool_) + cg.add(var.set_continuous(template_)) return var From 03d0ff18618e7e6e7a4bda938183a6dc766fddaf Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Tue, 7 Apr 2026 19:27:31 -1000 Subject: [PATCH 2/2] Update esphome/cpp_generator.py Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- esphome/cpp_generator.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/esphome/cpp_generator.py b/esphome/cpp_generator.py index f9330508c8..c41171257b 100644 --- a/esphome/cpp_generator.py +++ b/esphome/cpp_generator.py @@ -823,9 +823,11 @@ async def templatable( """Generate code for a templatable config option. If `value` is a templated value, the lambda expression is returned. - For std::string output, constants are returned as-is (with PROGMEM wrapping). + For std::string output, constants are returned as-is (with PROGMEM wrapping), + using the std::string-specific TemplatableValue specialization. For all other output types, constants are wrapped in stateless lambdas - so that TemplatableValue can store them as function pointers. + so that TemplatableFn-backed macro-generated fields can store them as + function pointers. :param value: The value to process. :param args: The arguments for the lambda expression.