mirror of
https://github.com/esphome/esphome.git
synced 2026-09-13 08:17:34 +00:00
[ota] Skip safe_shutdown after partition-table OTA
For OTA_TYPE_UPDATE_PARTITION_TABLE the success path runs nvs_flash_deinit() before the final write, which leaves every preference handle held by other components invalid. App.safe_reboot() calls on_safe_shutdown() which tries to flush preferences, and each flush fails with ESP_ERR_NVS_INVALID_HANDLE -- noisy log spam during the reboot window. App.reboot() skips the safe-shutdown callbacks and goes straight to esp_restart(). For partition-table OTAs there is nothing useful to flush (NVS handles are already dead, the device is moments from a reboot anyway), so reboot directly. App-OTA path is unchanged: safe_reboot() still runs on_safe_shutdown so preferences are saved on the way out.
This commit is contained in:
@@ -498,6 +498,13 @@ void ESPHomeOTAComponent::handle_data_() {
|
||||
this->notify_state_(ota::OTA_COMPLETED, 100.0f, 0);
|
||||
#endif
|
||||
delay(100); // NOLINT
|
||||
#ifdef USE_OTA_PARTITIONS
|
||||
if (ota_type == ota::OTA_TYPE_UPDATE_PARTITION_TABLE) {
|
||||
// Skip on_safe_shutdown: nvs_flash_deinit() has already invalidated open NVS handles, so
|
||||
// preferences flush would emit ESP_ERR_NVS_INVALID_HANDLE for every entry. Reboot directly.
|
||||
App.reboot();
|
||||
}
|
||||
#endif
|
||||
App.safe_reboot();
|
||||
|
||||
error:
|
||||
|
||||
Reference in New Issue
Block a user