From a90a2b1d62401b5cc81f0c722447493b7ca2bc14 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Wed, 25 Mar 2026 15:20:36 -1000 Subject: [PATCH] Address review: simplify template branch, add constructor comment MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Remove unnecessary TriggerForwarder.template() branch — TemplateArguments() already handles the empty case. - Add comment on Automation default constructor explaining its purpose for the forwarder pattern. --- esphome/automation.py | 6 +----- esphome/core/automation.h | 1 + 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/esphome/automation.py b/esphome/automation.py index c9a476622e4..0958e862a8d 100644 --- a/esphome/automation.py +++ b/esphome/automation.py @@ -700,9 +700,5 @@ async def build_callback_automation( # one operator() per forwarder type; different automation pointers are just # data in the struct. if forwarder is None: - forwarder = ( - TriggerForwarder.template(templ) - if arg_types - else TriggerForwarder.template() - ) + forwarder = TriggerForwarder.template(templ) cg.add(getattr(parent, callback_method)(cg.RawExpression(f"{forwarder}{{{obj}}}"))) diff --git a/esphome/core/automation.h b/esphome/core/automation.h index 28eae4e8f07..35f9e9bf387 100644 --- a/esphome/core/automation.h +++ b/esphome/core/automation.h @@ -470,6 +470,7 @@ template class ActionList { template class Automation { public: + /// Default constructor for use with TriggerForwarder (no Trigger object needed). Automation() = default; explicit Automation(Trigger *trigger) { trigger->set_automation_parent(this); }