ESPHome 2025.5.0
Loading...
Searching...
No Matches
syncer.h
Go to the documentation of this file.
1#pragma once
2
5
6namespace esphome {
7namespace preferences {
8
9class IntervalSyncer : public Component {
10 public:
11 void set_write_interval(uint32_t write_interval) { this->write_interval_ = write_interval; }
12 void setup() override {
13 if (this->write_interval_ != 0) {
15 }
16 }
17 void loop() override {
18 if (this->write_interval_ == 0) {
20 }
21 }
22 void on_shutdown() override { global_preferences->sync(); }
23 float get_setup_priority() const override { return setup_priority::BUS; }
24
25 protected:
26 uint32_t write_interval_{60000};
27};
28
29} // namespace preferences
30} // namespace esphome
void set_interval(const std::string &name, uint32_t interval, std::function< void()> &&f)
Set an interval function with a unique name.
Definition component.cpp:55
virtual bool sync()=0
Commit pending writes to flash.
void set_write_interval(uint32_t write_interval)
Definition syncer.h:11
float get_setup_priority() const override
Definition syncer.h:23
const float BUS
For communication buses like i2c/spi.
Definition component.cpp:16
Providing packet encoding functions for exchanging data with a remote host.
Definition a01nyub.cpp:7
ESPPreferences * global_preferences