ESPHome 2026.11.0-dev
Loading...
Searching...
No Matches
output_button.cpp
Go to the documentation of this file.
1#include "output_button.h"
2#include "esphome/core/log.h"
3
4namespace esphome::output {
5
6ESPHOME_LOG_TAG(TAG, "output.button");
7
8static constexpr uint32_t RESET_TIMEOUT_ID = 0;
9
11 LOG_BUTTON("", "Output Button", this);
12 ESP_LOGCONFIG(TAG, " Duration: %.1fs", this->duration_ / 1e3f);
13}
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
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
virtual void turn_off()
Disable this binary output.
virtual void turn_on()
Enable this binary output.
output::BinaryOutput * output_
ESPHOME_LOG_TAG(TAG, "output.button")
static void uint32_t