ESPHome 2026.5.0-dev
Loading...
Searching...
No Matches
factory_reset.h
Go to the documentation of this file.
1#pragma once
2
6#if !defined(USE_RP2040) && !defined(USE_HOST)
7
8#ifdef USE_ESP32
9#include <esp_system.h>
10#endif
11
12namespace esphome::factory_reset {
14 public:
15 FactoryResetComponent(uint8_t required_count, uint16_t max_interval)
16 : max_interval_(max_interval), required_count_(required_count) {}
17
18 void dump_config() override;
19 void setup() override;
20 template<typename F> void add_increment_callback(F &&callback) {
21 this->increment_callback_.add(std::forward<F>(callback));
22 }
23
24 protected:
26 void save_(uint8_t count);
27 ESPPreferenceObject flash_{}; // saves the number of fast power cycles
28 CallbackManager<void(uint8_t, uint8_t)> increment_callback_{};
29 uint16_t max_interval_; // max interval between power cycles in seconds
30 uint8_t required_count_; // The number of boot attempts before fast boot is enabled
31};
32
33} // namespace esphome::factory_reset
34
35#endif // !defined(USE_RP2040) && !defined(USE_HOST)
CallbackManager< void(uint8_t, uint8_t)> increment_callback_
FactoryResetComponent(uint8_t required_count, uint16_t max_interval)