ESPHome 2025.5.0
Loading...
Searching...
No Matches
automation.h
Go to the documentation of this file.
1#pragma once
2
5#include "text.h"
6
7namespace esphome {
8namespace text {
9
10class 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
17template<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
virtual void play(Ts... x)=0
TextCall & set_value(const std::string &value)
Definition text_call.cpp:10
Base-class for all text inputs.
Definition text.h:24
TextCall make_call()
Instantiate a TextCall object to modify this text component's state.
Definition text.h:35
void add_on_state_callback(std::function< void(std::string)> &&callback)
Definition text.cpp:21
TEMPLATABLE_VALUE(std::string, value) void play(Ts... x) override
Definition automation.h:20
Providing packet encoding functions for exchanging data with a remote host.
Definition a01nyub.cpp:7
uint16_t x
Definition tt21100.cpp:5