ESPHome 2025.5.0
Loading...
Searching...
No Matches
automation.h
Go to the documentation of this file.
1#pragma once
2
4#include "climate.h"
5
6namespace esphome {
7namespace climate {
8
9template<typename... Ts> class ControlAction : public Action<Ts...> {
10 public:
11 explicit ControlAction(Climate *climate) : climate_(climate) {}
12
18 TEMPLATABLE_VALUE(bool, away)
24
25 void play(Ts... x) override {
26 auto call = this->climate_->make_call();
27 call.set_mode(this->mode_.optional_value(x...));
28 call.set_target_temperature(this->target_temperature_.optional_value(x...));
29 call.set_target_temperature_low(this->target_temperature_low_.optional_value(x...));
30 call.set_target_temperature_high(this->target_temperature_high_.optional_value(x...));
31 call.set_target_humidity(this->target_humidity_.optional_value(x...));
32 if (away_.has_value()) {
33 call.set_preset(away_.value(x...) ? CLIMATE_PRESET_AWAY : CLIMATE_PRESET_HOME);
34 }
35 call.set_fan_mode(this->fan_mode_.optional_value(x...));
36 call.set_fan_mode(this->custom_fan_mode_.optional_value(x...));
37 call.set_preset(this->preset_.optional_value(x...));
38 call.set_preset(this->custom_preset_.optional_value(x...));
39 call.set_swing_mode(this->swing_mode_.optional_value(x...));
40 call.perform();
41 }
42
43 protected:
44 Climate *climate_;
45};
46
47class ControlTrigger : public Trigger<ClimateCall &> {
48 public:
50 climate->add_on_control_callback([this](ClimateCall &x) { this->trigger(x); });
51 }
52};
53
54class StateTrigger : public Trigger<Climate &> {
55 public:
57 climate->add_on_state_callback([this](Climate &x) { this->trigger(x); });
58 }
59};
60
61} // namespace climate
62} // namespace esphome
BedjetMode mode
BedJet operating mode.
virtual void play(Ts... x)=0
This class is used to encode all control actions on a climate device.
Definition climate.h:33
ClimateDevice - This is the base class for all climate integrations.
Definition climate.h:168
void add_on_state_callback(std::function< void(Climate &)> &&callback)
Add a callback for the climate device state, each time the state of the climate device is updated (us...
Definition climate.cpp:318
void add_on_control_callback(std::function< void(ClimateCall &)> &&callback)
Add a callback for the climate device configuration; each time the configuration parameters of a clim...
Definition climate.cpp:322
ControlAction(Climate *climate)
Definition automation.h:11
TEMPLATABLE_VALUE(ClimateMode, mode) TEMPLATABLE_VALUE(float
ControlTrigger(Climate *climate)
Definition automation.h:49
StateTrigger(Climate *climate)
Definition automation.h:56
float target_temperature_high
Definition climate.h:3
float target_humidity
Definition climate.h:19
ClimateSwingMode swing_mode
Definition climate.h:11
float target_temperature
Definition climate.h:0
uint8_t custom_preset
Definition climate.h:9
ClimateFanMode fan_mode
Definition climate.h:3
ClimatePreset preset
Definition climate.h:8
float target_temperature_low
Definition climate.h:2
uint8_t custom_fan_mode
Definition climate.h:4
ClimatePreset
Enum for all preset modes.
ClimateSwingMode
Enum for all modes a climate swing can be in.
ClimateMode
Enum for all modes a climate device can be in.
Providing packet encoding functions for exchanging data with a remote host.
Definition a01nyub.cpp:7
uint16_t x
Definition tt21100.cpp:5