ESPHome 2026.10.0-dev
Loading...
Searching...
No Matches
automation.h
Go to the documentation of this file.
1#pragma once
2
3#include "template_climate.h"
5
6namespace esphome::template_ {
7
8template<typename... Ts>
9class TemplateClimatePublishAction final : public Action<Ts...>, public Parented<TemplateClimate> {
10 public:
11 TEMPLATABLE_VALUE(float, current_temperature)
12 TEMPLATABLE_VALUE(float, current_humidity)
17 TEMPLATABLE_VALUE(climate::ClimateMode, mode)
18 TEMPLATABLE_VALUE(climate::ClimateAction, action)
19 TEMPLATABLE_VALUE(climate::ClimateFanMode, fan_mode)
21 TEMPLATABLE_VALUE(climate::ClimateSwingMode, swing_mode)
22 TEMPLATABLE_VALUE(climate::ClimatePreset, preset)
24
25 void play(const Ts &...x) override {
26 if (this->current_temperature_.has_value())
27 this->parent_->current_temperature = this->current_temperature_.value(x...);
28 if (this->current_humidity_.has_value())
29 this->parent_->current_humidity = this->current_humidity_.value(x...);
30 if (this->target_temperature_.has_value())
31 this->parent_->set_target_temperature(this->target_temperature_.value(x...));
32 if (this->target_temperature_low_.has_value())
33 this->parent_->set_target_temperature_low(this->target_temperature_low_.value(x...));
34 if (this->target_temperature_high_.has_value())
35 this->parent_->set_target_temperature_high(this->target_temperature_high_.value(x...));
36 if (this->target_humidity_.has_value())
37 this->parent_->set_target_humidity(this->target_humidity_.value(x...));
38 if (this->mode_.has_value())
39 this->parent_->set_mode(this->mode_.value(x...));
40 if (this->action_.has_value())
41 this->parent_->action = this->action_.value(x...);
42 if (this->fan_mode_.has_value())
43 this->parent_->set_fan_mode(this->fan_mode_.value(x...));
44 if (this->custom_fan_mode_.has_value())
45 this->parent_->set_custom_fan_mode(StringRef(this->custom_fan_mode_.value(x...)));
46 if (this->swing_mode_.has_value())
47 this->parent_->set_swing_mode(this->swing_mode_.value(x...));
48 if (this->preset_.has_value())
49 this->parent_->set_preset(this->preset_.value(x...));
50 if (this->custom_preset_.has_value())
51 this->parent_->set_custom_preset(StringRef(this->custom_preset_.value(x...)));
52
53 this->parent_->publish_state();
54 }
55};
56
57} // namespace esphome::template_
BedjetMode mode
BedJet operating mode.
virtual void play(const Ts &...x)=0
Helper class to easily give an object a parent of type T.
Definition helpers.h:1910
StringRef is a reference to a string owned by something else.
Definition string_ref.h:26
TEMPLATABLE_VALUE(float, current_temperature) TEMPLATABLE_VALUE(float
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
if(written< 0)
Definition helpers.h:1101
STL namespace.
uint16_t x
Definition tt21100.cpp:5