ESPHome 2026.11.0-dev
Loading...
Searching...
No Matches
syncer.h
Go to the documentation of this file.
1#pragma once
2
5// Include for ESPDEPRECATED, Remove before 2027.3.0
7
9
10class IntervalSyncer final : public PollingComponent {
11 public:
12 // User provided, not "= default": `new(p) IntervalSyncer()` would zero-fill .bss that is already zero.
14
15 // Remove before 2027.3.0
16 ESPDEPRECATED("Use set_update_interval() instead. Removed in 2027.3.0", "2026.9.0")
17 void set_write_interval(uint32_t write_interval) { this->set_update_interval(write_interval); }
18 void update() override { global_preferences->sync(); }
19 void on_shutdown() override { global_preferences->sync(); }
20 float get_setup_priority() const override { return setup_priority::BUS; }
21};
22
23} // namespace esphome::preferences
This class simplifies creating components that periodically check a state.
Definition component.h:519
void set_update_interval(uint32_t update_interval)
Manually set the update interval in ms for this polling object.
Definition component.h:533
ESPDEPRECATED("Use set_update_interval() instead. Removed in 2027.3.0", "2026.9.0") void set_write_interval(uint32_t write_interval)
Definition syncer.h:16
float get_setup_priority() const override
Definition syncer.h:20
constexpr float BUS
For communication buses like i2c/spi.
Definition component.h:39
ESPPreferences * global_preferences
static void uint32_t
bool sync()
Commit pending writes to flash.
Definition preferences.h:33