From 4cab4c348af5a67d7f68d611598d5262b69dc13b Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Mon, 23 Mar 2026 21:38:33 -1000 Subject: [PATCH] Use plain bool instead of RawExpression for IfAction template arg --- esphome/automation.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/esphome/automation.py b/esphome/automation.py index 669e902bc9..17966dc782 100644 --- a/esphome/automation.py +++ b/esphome/automation.py @@ -415,9 +415,7 @@ async def if_action_to_code( ) -> MockObj: has_else = CONF_ELSE in config # Prepend HasElse bool to template arguments: IfAction - if_template_arg = cg.TemplateArguments( - cg.RawExpression("true" if has_else else "false"), *template_arg - ) + if_template_arg = cg.TemplateArguments(has_else, *template_arg) cond_conf = next(el for el in config if el in (CONF_ANY, CONF_ALL, CONF_CONDITION)) condition = await build_condition(config[cond_conf], template_arg, args) var = cg.new_Pvariable(action_id, if_template_arg, condition)