ESPHome 2026.2.4
Loading...
Searching...
No Matches
interval.h
Go to the documentation of this file.
1#pragma once
2
4#include "esphome/core/log.h"
6
7namespace esphome {
8namespace interval {
9
10class IntervalTrigger : public Trigger<>, public PollingComponent {
11 public:
12 void update() override { this->trigger(); }
13
14 void setup() override {
15 if (this->startup_delay_ != 0) {
16 this->stop_poller();
17 this->set_timeout(this->startup_delay_, [this] { this->start_poller(); });
18 }
19 }
20
21 void set_startup_delay(const uint32_t startup_delay) { this->startup_delay_ = startup_delay; }
22
23 protected:
24 uint32_t startup_delay_{0};
25};
26
27} // namespace interval
28} // namespace esphome
ESPDEPRECATED("Use const char* or uint32_t overload instead. Removed in 2026.7.0", "2026.1.0") void set_timeout(const std voi set_timeout)(const char *name, uint32_t timeout, std::function< void()> &&f)
Set a timeout function with a unique name.
Definition component.h:429
This class simplifies creating components that periodically check a state.
Definition component.h:512
void trigger(const Ts &...x)
Definition automation.h:279
void set_startup_delay(const uint32_t startup_delay)
Definition interval.h:21
Providing packet encoding functions for exchanging data with a remote host.
Definition a01nyub.cpp:7