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:
@@ -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; }
|
||||
|
||||
|
Reference in New Issue
Block a user