mirror of
https://github.com/esphome/esphome.git
synced 2026-09-17 18:18:43 +00:00
Address review: simplify template branch, add constructor comment
- Remove unnecessary TriggerForwarder.template() branch — TemplateArguments() already handles the empty case. - Add comment on Automation default constructor explaining its purpose for the forwarder pattern.
This commit is contained in:
@@ -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}}}")))
|
||||
|
||||
@@ -470,6 +470,7 @@ template<typename... Ts> class ActionList {
|
||||
|
||||
template<typename... Ts> class Automation {
|
||||
public:
|
||||
/// Default constructor for use with TriggerForwarder (no Trigger object needed).
|
||||
Automation() = default;
|
||||
explicit Automation(Trigger<Ts...> *trigger) { trigger->set_automation_parent(this); }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user