mirror of
https://github.com/esphome/esphome.git
synced 2025-10-25 05:03:52 +01:00
29 lines
659 B
C++
29 lines
659 B
C++
#pragma once
|
|
|
|
#include "esphome/core/component.h"
|
|
#include "esphome/core/log.h"
|
|
#include "esphome/core/automation.h"
|
|
|
|
namespace esphome {
|
|
namespace interval {
|
|
|
|
class IntervalTrigger : public Trigger<>, public PollingComponent {
|
|
public:
|
|
void update() override { this->trigger(); }
|
|
|
|
void setup() override {
|
|
if (this->startup_delay_ != 0) {
|
|
this->stop_poller();
|
|
this->set_timeout(this->startup_delay_, [this] { this->start_poller(); });
|
|
}
|
|
}
|
|
|
|
void set_startup_delay(const uint32_t startup_delay) { this->startup_delay_ = startup_delay; }
|
|
|
|
protected:
|
|
uint32_t startup_delay_{0};
|
|
};
|
|
|
|
} // namespace interval
|
|
} // namespace esphome
|