ESPHome 2026.3.0-dev
Loading...
Searching...
No Matches
automation.h
Go to the documentation of this file.
1#pragma once
2
5#include "text.h"
6
7namespace esphome::text {
8
9class TextStateTrigger : public Trigger<std::string> {
10 public:
11 explicit TextStateTrigger(Text *parent) {
12 parent->add_on_state_callback([this](const std::string &value) { this->trigger(value); });
13 }
14};
15
16template<typename... Ts> class TextSetAction : public Action<Ts...> {
17 public:
18 explicit TextSetAction(Text *text) : text_(text) {}
19 TEMPLATABLE_VALUE(std::string, value)
20
21 void play(const Ts &...x) override {
22 auto call = this->text_->make_call();
23 call.set_value(this->value_.value(x...));
24 call.perform();
25 }
26
27 protected:
29};
30
31} // namespace esphome::text
virtual void play(const Ts &...x)=0
void trigger(const Ts &...x)
Definition automation.h:325
TextCall & set_value(const std::string &value)
Definition text_call.cpp:9
Base-class for all text inputs.
Definition text.h:21
TextCall make_call()
Instantiate a TextCall object to modify this text component's state.
Definition text.h:31
void add_on_state_callback(std::function< void(const std::string &)> &&callback)
Definition text.cpp:32
TEMPLATABLE_VALUE(std::string, value) void play(const Ts &...x) override
Definition automation.h:19
uint16_t x
Definition tt21100.cpp:5