1
0
mirror of https://github.com/esphome/esphome.git synced 2025-09-06 13:22:19 +01:00

[switch] Add trigger `on_state` (#10108)

This commit is contained in:
Edward Firmo
2025-08-09 13:09:40 +02:00
committed by GitHub
parent ff9ddb9d68
commit 2b9e1ce315
3 changed files with 31 additions and 0 deletions

View File

@@ -64,6 +64,13 @@ template<typename... Ts> class SwitchCondition : public Condition<Ts...> {
bool state_;
};
class SwitchStateTrigger : public Trigger<bool> {
public:
SwitchStateTrigger(Switch *a_switch) {
a_switch->add_on_state_callback([this](bool state) { this->trigger(state); });
}
};
class SwitchTurnOnTrigger : public Trigger<> {
public:
SwitchTurnOnTrigger(Switch *a_switch) {