ESPHome 2026.2.4
Loading...
Searching...
No Matches
automation.h
Go to the documentation of this file.
1#pragma once
2
5
6namespace esphome::template_ {
7
8template<typename... Ts>
9class TemplateWaterHeaterPublishAction : public Action<Ts...>, public Parented<TemplateWaterHeater> {
10 public:
11 TEMPLATABLE_VALUE(float, current_temperature)
13 TEMPLATABLE_VALUE(water_heater::WaterHeaterMode, mode)
14 TEMPLATABLE_VALUE(bool, away)
15 TEMPLATABLE_VALUE(bool, is_on)
16
17 void play(const Ts &...x) override {
18 if (this->current_temperature_.has_value()) {
19 this->parent_->set_current_temperature(this->current_temperature_.value(x...));
20 }
21 bool needs_call = this->target_temperature_.has_value() || this->mode_.has_value() || this->away_.has_value() ||
22 this->is_on_.has_value();
23 if (needs_call) {
24 auto call = this->parent_->make_call();
25 if (this->target_temperature_.has_value()) {
26 call.set_target_temperature(this->target_temperature_.value(x...));
27 }
28 if (this->mode_.has_value()) {
29 call.set_mode(this->mode_.value(x...));
30 }
31 if (this->away_.has_value()) {
32 call.set_away(this->away_.value(x...));
33 }
34 if (this->is_on_.has_value()) {
35 call.set_on(this->is_on_.value(x...));
36 }
37 call.perform();
38 } else {
39 this->parent_->publish_state();
40 }
41 }
42};
43
44} // 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:1471
TEMPLATABLE_VALUE(float, current_temperature) TEMPLATABLE_VALUE(float
float target_temperature
Definition climate.h:0
if(written< 0)
Definition helpers.h:738
uint16_t x
Definition tt21100.cpp:5