ESPHome  2024.12.2
automation.h
Go to the documentation of this file.
1 #pragma once
2 
5 #include "text.h"
6 
7 namespace esphome {
8 namespace text {
9 
10 class TextStateTrigger : public Trigger<std::string> {
11  public:
12  explicit TextStateTrigger(Text *parent) {
13  parent->add_on_state_callback([this](const std::string &value) { this->trigger(value); });
14  }
15 };
16 
17 template<typename... Ts> class TextSetAction : public Action<Ts...> {
18  public:
19  explicit TextSetAction(Text *text) : text_(text) {}
20  TEMPLATABLE_VALUE(std::string, value)
21 
22  void play(Ts... x) override {
23  auto call = this->text_->make_call();
24  call.set_value(this->value_.value(x...));
25  call.perform();
26  }
27 
28  protected:
30 };
31 
32 } // namespace text
33 } // namespace esphome
uint16_t x
Definition: tt21100.cpp:17
Base-class for all text inputs.
Definition: text.h:24
void trigger(Ts... x)
Inform the parent automation that the event has triggered.
Definition: automation.h:95
void add_on_state_callback(std::function< void(std::string)> &&callback)
Definition: text.cpp:21
Implementation of SPI Controller mode.
Definition: a01nyub.cpp:7
TEMPLATABLE_VALUE(std::string, value) void play(Ts... x) override
Definition: automation.h:20