ESPHome  2024.4.0
interval.h
Go to the documentation of this file.
1 #pragma once
2 
5 
6 namespace esphome {
7 namespace interval {
8 
9 class IntervalTrigger : public Trigger<>, public PollingComponent {
10  public:
11  void update() override {
12  if (this->started_)
13  this->trigger();
14  }
15 
16  void setup() override {
17  if (this->startup_delay_ == 0) {
18  this->started_ = true;
19  } else {
20  this->set_timeout(this->startup_delay_, [this] { this->started_ = true; });
21  }
22  }
23 
24  void set_startup_delay(const uint32_t startup_delay) { this->startup_delay_ = startup_delay; }
25 
26  float get_setup_priority() const override { return setup_priority::DATA; }
27 
28  protected:
29  uint32_t startup_delay_{0};
30  bool started_{false};
31 };
32 
33 } // namespace interval
34 } // namespace esphome
const float DATA
For components that import data from directly connected sensors like DHT.
Definition: component.cpp:19
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:69
float get_setup_priority() const override
Definition: interval.h:26
This class simplifies creating components that periodically check a state.
Definition: component.h:283
void trigger(Ts... x)
Inform the parent automation that the event has triggered.
Definition: automation.h:95
void set_startup_delay(const uint32_t startup_delay)
Definition: interval.h:24
This is a workaround until we can figure out a way to get the tflite-micro idf component code availab...
Definition: a01nyub.cpp:7