mirror of
https://github.com/esphome/esphome.git
synced 2025-09-16 02:02:21 +01:00
Add Factory Reset button and switch (#3724)
Co-authored-by: Jesse Hills <3060199+jesserockz@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
790280ace9
commit
9a5f865eea
@@ -141,7 +141,7 @@ class ESP32Preferences : public ESPPreferences {
|
||||
ESP_LOGD(TAG, "Saving %d preferences to flash: %d cached, %d written, %d failed", cached + written + failed, cached,
|
||||
written, failed);
|
||||
if (failed > 0) {
|
||||
ESP_LOGD(TAG, "Error saving %d preferences to flash. Last error=%s for key=%s", failed, esp_err_to_name(last_err),
|
||||
ESP_LOGE(TAG, "Error saving %d preferences to flash. Last error=%s for key=%s", failed, esp_err_to_name(last_err),
|
||||
last_key.c_str());
|
||||
}
|
||||
|
||||
@@ -170,6 +170,17 @@ class ESP32Preferences : public ESPPreferences {
|
||||
}
|
||||
return to_save.data != stored_data.data;
|
||||
}
|
||||
|
||||
bool reset() override {
|
||||
ESP_LOGD(TAG, "Cleaning up preferences in flash...");
|
||||
s_pending_save.clear();
|
||||
|
||||
nvs_flash_deinit();
|
||||
nvs_flash_erase();
|
||||
// Make the handle invalid to prevent any saves until restart
|
||||
nvs_handle = 0;
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
void setup_preferences() {
|
||||
|
Reference in New Issue
Block a user