ESPHome 2025.9.0-dev
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
void set_timeout(const std::string &name, uint32_t timeout, std::function< void()> &&f)
Set a timeout function with a unique name.
This class simplifies creating components that periodically check a state.
Definition component.h:425
void trigger(Ts... x)
Definition automation.h:145
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