From 1edc3278354bd2bbcc447b79fe660aac1adb7e8d Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Fri, 25 Sep 2026 19:56:06 +0100 Subject: [PATCH] [cc1101] Use register_apply_action for begin_tx, begin_rx, reset and set_idle (#19661) --- esphome/components/cc1101/__init__.py | 43 ++++++--------------------- esphome/components/cc1101/cc1101.h | 20 ------------- 2 files changed, 9 insertions(+), 54 deletions(-) diff --git a/esphome/components/cc1101/__init__.py b/esphome/components/cc1101/__init__.py index d851d7386d..5de39a16ce 100644 --- a/esphome/components/cc1101/__init__.py +++ b/esphome/components/cc1101/__init__.py @@ -351,10 +351,6 @@ async def to_code(config): # Actions -BeginTxAction = ns.class_("BeginTxAction", automation.Action) -BeginRxAction = ns.class_("BeginRxAction", automation.Action) -ResetAction = ns.class_("ResetAction", automation.Action) -SetIdleAction = ns.class_("SetIdleAction", automation.Action) SendPacketAction = ns.class_( "SendPacketAction", automation.Action, cg.Parented.template(CC1101Component) ) @@ -364,36 +360,15 @@ CC1101_ACTION_SCHEMA = cv.Schema( ) -automation.register_parented_action( - "cc1101.begin_tx", - BeginTxAction, - CC1101_ACTION_SCHEMA, - synchronous=True, -) - - -automation.register_parented_action( - "cc1101.begin_rx", - BeginRxAction, - CC1101_ACTION_SCHEMA, - synchronous=True, -) - - -automation.register_parented_action( - "cc1101.reset", - ResetAction, - CC1101_ACTION_SCHEMA, - synchronous=True, -) - - -automation.register_parented_action( - "cc1101.set_idle", - SetIdleAction, - CC1101_ACTION_SCHEMA, - synchronous=True, -) +for _name, _call in ( + ("cc1101.begin_tx", "begin_tx()"), + ("cc1101.begin_rx", "begin_rx()"), + ("cc1101.reset", "reset()"), + ("cc1101.set_idle", "set_idle()"), +): + automation.register_apply_action( + _name, CC1101_ACTION_SCHEMA, automation.ApplyCall(_call) + ) def validate_raw_data(value): diff --git a/esphome/components/cc1101/cc1101.h b/esphome/components/cc1101/cc1101.h index 1f7a55fbf1..499f77a809 100644 --- a/esphome/components/cc1101/cc1101.h +++ b/esphome/components/cc1101/cc1101.h @@ -130,26 +130,6 @@ class CC1101Component final : public Component, }; // Action Wrappers -template class BeginTxAction final : public Action, public Parented { - public: - void play(const Ts &...x) override { this->parent_->begin_tx(); } -}; - -template class BeginRxAction final : public Action, public Parented { - public: - void play(const Ts &...x) override { this->parent_->begin_rx(); } -}; - -template class ResetAction final : public Action, public Parented { - public: - void play(const Ts &...x) override { this->parent_->reset(); } -}; - -template class SetIdleAction final : public Action, public Parented { - public: - void play(const Ts &...x) override { this->parent_->set_idle(); } -}; - template class SendPacketAction final : public Action, public Parented { public: void set_data_template(std::function(Ts...)> func) { this->data_func_ = func; }