#pragma once #include "esphome/core/component.h" #include "esphome/core/automation.h" #include "empty_automation.h" namespace esphome { namespace empty_automation { template class EmptyAutomationSetStateAction : public Action { public: explicit EmptyAutomationSetStateAction(EmptyAutomation *ea) : ea_(ea) {} TEMPLATABLE_VALUE(bool, state) void play(Ts... x) override { auto val = this->state_.value(x...); this->ea_->set_state(val); } protected: EmptyAutomation *ea_; }; template class EmptyAutomationCondition : public Condition { public: EmptyAutomationCondition(EmptyAutomation *parent, bool state) : parent_(parent), state_(state) {} bool check(Ts... x) override { return this->parent_->state == this->state_; } protected: EmptyAutomation *parent_; bool state_; }; class StateTrigger : public Trigger { public: explicit StateTrigger(EmptyAutomation *parent) { parent->add_on_state_callback([this](bool state) { this->trigger(state); }); } }; } // namespace empty_automation } // namespace esphome