ESPHome
2025.12.3
Loading...
Searching...
No Matches
esphome
components
button
automation.h
Go to the documentation of this file.
1
#pragma once
2
3
#include "
esphome/components/button/button.h
"
4
#include "
esphome/core/automation.h
"
5
#include "
esphome/core/component.h
"
6
7
namespace
esphome::button
{
8
9
template
<
typename
... Ts>
class
PressAction
:
public
Action
<Ts...> {
10
public
:
11
explicit
PressAction
(
Button
*button) :
button_
(button) {}
12
13
void
play
(
const
Ts &...
x
)
override
{ this->
button_
->
press
(); }
14
15
protected
:
16
Button
*
button_
;
17
};
18
19
class
ButtonPressTrigger
:
public
Trigger
<> {
20
public
:
21
ButtonPressTrigger
(
Button
*button) {
22
button->
add_on_press_callback
([
this
]() { this->
trigger
(); });
23
}
24
};
25
26
}
// namespace esphome::button
button.h
esphome::Action
Definition
automation.h:230
esphome::Trigger
Definition
automation.h:201
esphome::Trigger<>::trigger
void trigger(const Ts &...x)
Definition
automation.h:204
esphome::button::Button
Base class for all buttons.
Definition
button.h:25
esphome::button::Button::add_on_press_callback
void add_on_press_callback(std::function< void()> &&callback)
Set callback for state changes.
Definition
button.cpp:26
esphome::button::Button::press
void press()
Press this button.
Definition
button.cpp:21
esphome::button::ButtonPressTrigger
Definition
automation.h:19
esphome::button::ButtonPressTrigger::ButtonPressTrigger
ButtonPressTrigger(Button *button)
Definition
automation.h:21
esphome::button::PressAction
Definition
automation.h:9
esphome::button::PressAction::button_
Button * button_
Definition
automation.h:16
esphome::button::PressAction::play
void play(const Ts &...x) override
Definition
automation.h:13
esphome::button::PressAction::PressAction
PressAction(Button *button)
Definition
automation.h:11
component.h
automation.h
esphome::button
Definition
automation.h:7
x
uint16_t x
Definition
tt21100.cpp:5
Generated by
1.12.0