ESPHome 2026.5.0
Loading...
Searching...
No Matches
automation.h
Go to the documentation of this file.
1#pragma once
2
8
9namespace esphome::output {
10
11template<typename... Ts> class TurnOffAction : public Action<Ts...> {
12 public:
13 TurnOffAction(BinaryOutput *output) : output_(output) {}
14
15 void play(const Ts &...x) override { this->output_->turn_off(); }
16
17 protected:
19};
20
21template<typename... Ts> class TurnOnAction : public Action<Ts...> {
22 public:
23 TurnOnAction(BinaryOutput *output) : output_(output) {}
24
25 void play(const Ts &...x) override { this->output_->turn_on(); }
26
27 protected:
29};
30
31template<typename... Ts> class SetLevelAction : public Action<Ts...> {
32 public:
33 SetLevelAction(FloatOutput *output) : output_(output) {}
34
35 TEMPLATABLE_VALUE(float, level)
36
37 void play(const Ts &...x) override { this->output_->set_level(this->level_.value(x...)); }
38
39 protected:
41};
42
43#ifdef USE_OUTPUT_FLOAT_POWER_SCALING
44template<typename... Ts> class SetMinPowerAction : public Action<Ts...> {
45 public:
47
48 TEMPLATABLE_VALUE(float, min_power)
49
50 void play(const Ts &...x) override { this->output_->set_min_power(this->min_power_.value(x...)); }
51
52 protected:
54};
55
56template<typename... Ts> class SetMaxPowerAction : public Action<Ts...> {
57 public:
59
60 TEMPLATABLE_VALUE(float, max_power)
61
62 void play(const Ts &...x) override { this->output_->set_max_power(this->max_power_.value(x...)); }
63
64 protected:
66};
67#endif // USE_OUTPUT_FLOAT_POWER_SCALING
68
69} // namespace esphome::output
virtual void play(const Ts &...x)=0
virtual void turn_off()
Disable this binary output.
virtual void turn_on()
Enable this binary output.
Base class for all output components that can output a variable level, like PWM.
void set_level(float state)
Set the level of this float output, this is called from the front-end.
void set_max_power(float max_power)
Set the maximum power output of this component.
void set_min_power(float min_power)
Set the minimum power output of this component.
TEMPLATABLE_VALUE(float, level) void play(const Ts &...x) override
Definition automation.h:35
SetLevelAction(FloatOutput *output)
Definition automation.h:33
SetMaxPowerAction(FloatOutput *output)
Definition automation.h:58
TEMPLATABLE_VALUE(float, max_power) void play(const Ts &...x) override
Definition automation.h:60
TEMPLATABLE_VALUE(float, min_power) void play(const Ts &...x) override
Definition automation.h:48
SetMinPowerAction(FloatOutput *output)
Definition automation.h:46
TurnOffAction(BinaryOutput *output)
Definition automation.h:13
void play(const Ts &...x) override
Definition automation.h:15
void play(const Ts &...x) override
Definition automation.h:25
TurnOnAction(BinaryOutput *output)
Definition automation.h:23
uint16_t x
Definition tt21100.cpp:5