1
0
mirror of https://github.com/esphome/esphome.git synced 2025-09-11 15:52:20 +01:00

Feat/component poller suspend (#5423)

This commit is contained in:
De Cock Xavier
2023-10-02 22:25:13 +02:00
committed by GitHub
parent 589b9e10b2
commit a33b8abce8
5 changed files with 104 additions and 0 deletions

View File

@@ -188,10 +188,20 @@ void PollingComponent::call_setup() {
// Let the polling component subclass setup their HW.
this->setup();
// init the poller
this->start_poller();
}
void PollingComponent::start_poller() {
// Register interval.
this->set_interval("update", this->get_update_interval(), [this]() { this->update(); });
}
void PollingComponent::stop_poller() {
// Clear the interval to suspend component
this->cancel_interval("update");
}
uint32_t PollingComponent::get_update_interval() const { return this->update_interval_; }
void PollingComponent::set_update_interval(uint32_t update_interval) { this->update_interval_ = update_interval; }