ESPHome 2026.10.2
Loading...
Searching...
No Matches
automation.h
Go to the documentation of this file.
1#pragma once
2
5#include "valve.h"
6
7namespace esphome::valve {
8
9class ValveOpenTrigger final : public Trigger<> {
10 public:
11 ValveOpenTrigger(Valve *a_valve) : valve_(a_valve) {
12 a_valve->add_on_state_callback([this]() {
13 if (this->valve_->is_fully_open()) {
14 this->trigger();
15 }
16 });
17 }
18
19 protected:
21};
22
23class ValveClosedTrigger final : public Trigger<> {
24 public:
25 ValveClosedTrigger(Valve *a_valve) : valve_(a_valve) {
26 a_valve->add_on_state_callback([this]() {
27 if (this->valve_->is_fully_closed()) {
28 this->trigger();
29 }
30 });
31 }
32
33 protected:
35};
36
37} // namespace esphome::valve
void trigger(const Ts &...x) ESPHOME_ALWAYS_INLINE
Definition automation.h:528
Base class for all valve devices.
Definition valve.h:103
bool is_fully_closed() const
Helper method to check if the valve is fully closed. Equivalent to comparing .position against 0....
Definition valve.h:135
void add_on_state_callback(F &&f)
Definition valve.h:119
bool is_fully_open() const
Helper method to check if the valve is fully open. Equivalent to comparing .position against 1....
Definition valve.h:133