ESPHome
2026.11.0-dev
Loading...
Searching...
No Matches
esphome
components
output
button
output_button.cpp
Go to the documentation of this file.
1
#include "
output_button.h
"
2
#include "
esphome/core/log.h
"
3
4
namespace
esphome::output
{
5
6
ESPHOME_LOG_TAG
(TAG,
"output.button"
);
7
8
static
constexpr
uint32_t
RESET_TIMEOUT_ID = 0;
9
10
void
OutputButton::dump_config
() {
11
LOG_BUTTON(
""
,
"Output Button"
,
this
);
12
ESP_LOGCONFIG(TAG,
" Duration: %.1fs"
, this->
duration_
/ 1e3f);
13
}
14
void
OutputButton::press_action
() {
15
this->
output_
->
turn_on
();
16
17
// One timeout id, so a second press restarts the reset instead of stacking another
18
this->
set_timeout
(RESET_TIMEOUT_ID, this->
duration_
, [
this
]() { this->
output_
->
turn_off
(); });
19
}
20
21
}
// namespace esphome::output
esphome::Component::set_timeout
void set_timeout(const char *name, uint32_t timeout, std::function< void()> &&f)
Set a timeout function with a const char* name.
Definition
component.cpp:96
esphome::output::BinaryOutput::turn_off
virtual void turn_off()
Disable this binary output.
Definition
binary_output.h:50
esphome::output::BinaryOutput::turn_on
virtual void turn_on()
Enable this binary output.
Definition
binary_output.h:42
esphome::output::OutputButton::dump_config
void dump_config() override
Definition
output_button.cpp:10
esphome::output::OutputButton::press_action
void press_action() override
Definition
output_button.cpp:14
esphome::output::OutputButton::output_
output::BinaryOutput * output_
Definition
output_button.h:19
esphome::output::OutputButton::duration_
uint32_t duration_
Definition
output_button.h:20
log.h
esphome::output
Definition
binary_output.h:10
esphome::output::ESPHOME_LOG_TAG
ESPHOME_LOG_TAG(TAG, "output.button")
output_button.h
uint32_t
static void uint32_t
Definition
crash_handler.cpp:153
Generated by
1.12.0