ESPHome 2025.5.0
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 {
5namespace output {
6
7static const char *const TAG = "output.button";
8
10 LOG_BUTTON("", "Output Button", this);
11 ESP_LOGCONFIG(TAG, " Duration: %.1fs", this->duration_ / 1e3f);
12}
14 this->output_->turn_on();
15
16 // Use a named timeout so that it's automatically cancelled if button is pressed again before it's reset
17 this->set_timeout("reset", this->duration_, [this]() { this->output_->turn_off(); });
18}
19
20} // namespace output
21} // namespace esphome
void set_timeout(const std::string &name, uint32_t timeout, std::function< void()> &&f)
Set a timeout function with a unique name.
Definition component.cpp:72
virtual void turn_off()
Disable this binary output.
virtual void turn_on()
Enable this binary output.
output::BinaryOutput * output_
Providing packet encoding functions for exchanging data with a remote host.
Definition a01nyub.cpp:7