From 33afa263dbc88b577586434f8354fe01c8d9a76e Mon Sep 17 00:00:00 2001 From: GrKoR Date: Wed, 25 May 2022 23:31:24 +0300 Subject: [PATCH] =?UTF-8?q?=D0=B2=D0=B5=D1=80=D0=BD=D1=83=D0=BB=20action?= =?UTF-8?q?=20=D0=B4=D0=BB=D1=8F=20=D0=B8=D0=BD=D0=B6=D0=B5=D0=BD=D0=B5?= =?UTF-8?q?=D1=80=D0=BE=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/aux_ac/automation.h | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/components/aux_ac/automation.h b/components/aux_ac/automation.h index d8d9565..a62fb27 100644 --- a/components/aux_ac/automation.h +++ b/components/aux_ac/automation.h @@ -17,7 +17,7 @@ namespace aux_ac { protected: AirCon *ac_; - }; + }; template class AirConDisplayOnAction : public Action @@ -29,7 +29,37 @@ namespace aux_ac { protected: AirCon *ac_; - }; + }; + + template + class AirConSendTestPacketAction : public Action + { + public: + explicit AirConSendTestPacketAction(AirCon *ac) : ac_(ac) {} + void set_data_template(std::function(Ts...)> func) { + this->data_func_ = func; + this->static_ = false; + } + void set_data_static(const std::vector &data) { + this->data_static_ = data; + this->static_ = true; + } + + void play(Ts... x) override { + if (this->static_) { + this->ac_->sendTestPacket(this->data_static_); + } else { + auto val = this->data_func_(x...); + this->ac_->sendTestPacket(val); + } + } + + protected: + AirCon *ac_; + bool static_{false}; + std::function(Ts...)> data_func_{}; + std::vector data_static_{}; + }; } // namespace aux_ac } // namespace esphome \ No newline at end of file