ESPHome 2026.5.0b1
Loading...
Searching...
No Matches
automation.h
Go to the documentation of this file.
1#pragma once
2
6
7namespace esphome::event {
8
9template<typename... Ts> class TriggerEventAction : public Action<Ts...>, public Parented<Event> {
10 public:
11 TEMPLATABLE_VALUE(std::string, event_type)
12
13 void play(const Ts &...x) override { this->parent_->trigger(this->event_type_.value(x...)); }
14};
15
16class EventTrigger : public Trigger<StringRef> {
17 public:
19 event->add_on_event_callback([this](StringRef event_type) { this->trigger(event_type); });
20 }
21};
22
23} // namespace esphome::event
virtual void play(const Ts &...x)=0
Helper class to easily give an object a parent of type T.
Definition helpers.h:1861
StringRef is a reference to a string owned by something else.
Definition string_ref.h:26
void trigger(const Ts &...x) ESPHOME_ALWAYS_INLINE
Definition automation.h:482
TEMPLATABLE_VALUE(std::string, event_type) void play(const Ts &...x) override
Definition automation.h:11
uint16_t x
Definition tt21100.cpp:5