ESPHome 2026.1.0-dev
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
15 void play(const Ts &...x) override {
16 if (this->current_temperature_.has_value()) {
17 this->parent_->set_current_temperature(this->current_temperature_.value(x...));
18 }
19 bool needs_call = this->target_temperature_.has_value() || this->mode_.has_value();
20 if (needs_call) {
21 auto call = this->parent_->make_call();
22 if (this->target_temperature_.has_value()) {
23 call.set_target_temperature(this->target_temperature_.value(x...));
24 }
25 if (this->mode_.has_value()) {
26 call.set_mode(this->mode_.value(x...));
27 }
28 call.perform();
29 } else {
30 this->parent_->publish_state();
31 }
32 }
33};
34
35} // 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:1155
TEMPLATABLE_VALUE(float, current_temperature) TEMPLATABLE_VALUE(float
float target_temperature
Definition climate.h:0
uint16_t x
Definition tt21100.cpp:5