ESPHome
2024.10.2
esphome
esphome
components
text
automation.h
Go to the documentation of this file.
1
#pragma once
2
3
#include "
esphome/core/automation.h
"
4
#include "
esphome/core/component.h
"
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
:
29
Text
*
text_
;
30
};
31
32
}
// namespace text
33
}
// namespace esphome
esphome::text::TextStateTrigger::TextStateTrigger
TextStateTrigger(Text *parent)
Definition:
automation.h:12
text.h
x
uint16_t x
Definition:
tt21100.cpp:17
automation.h
esphome::text::Text
Base-class for all text inputs.
Definition:
text.h:24
esphome::Trigger< std::string >::trigger
void trigger(Ts... x)
Inform the parent automation that the event has triggered.
Definition:
automation.h:95
esphome::Action
Definition:
automation.h:121
esphome::text::Text::add_on_state_callback
void add_on_state_callback(std::function< void(std::string)> &&callback)
Definition:
text.cpp:21
esphome::text::TextStateTrigger
Definition:
automation.h:10
esphome::text::TextSetAction::TextSetAction
TextSetAction(Text *text)
Definition:
automation.h:19
esphome::text::TextSetAction::text_
Text * text_
Definition:
automation.h:29
esphome
Implementation of SPI Controller mode.
Definition:
a01nyub.cpp:7
esphome::Trigger
Definition:
automation.h:92
component.h
esphome::text::TextSetAction::TEMPLATABLE_VALUE
TEMPLATABLE_VALUE(std::string, value) void play(Ts... x) override
Definition:
automation.h:20
esphome::text::TextSetAction
Definition:
automation.h:17
Generated by
1.8.13