From 9c1adc2bdcde6666123a6fbf2159171b3dbeb3b2 Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Sat, 5 Feb 2022 11:29:35 +0100 Subject: [PATCH] Add postpone flash writes for SPM energy updates --- tasmota/xdrv_86_esp32_sonoff_spm.ino | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tasmota/xdrv_86_esp32_sonoff_spm.ino b/tasmota/xdrv_86_esp32_sonoff_spm.ino index a29ae8237..be2cd0ccb 100644 --- a/tasmota/xdrv_86_esp32_sonoff_spm.ino +++ b/tasmota/xdrv_86_esp32_sonoff_spm.ino @@ -1138,6 +1138,9 @@ void SSPMHandleReceivedData(void) { if (0 == Sspm->Settings.energy_total[module][channel]) { Sspm->Settings.energy_yesterday[module][channel] = energy_yesterday; // Inital setting Sspm->Settings.energy_total[module][channel] = energy_total; // Initial setting + if (Settings->save_data) { + TasmotaGlobal.save_data_counter = Settings->save_data +2; // Potspone flash write until all relays are updated + } } // If received daily energy is below last daily energy then update total energy @@ -1145,6 +1148,9 @@ void SSPMHandleReceivedData(void) { if (Sspm->energy_today[module][channel] < last_energy_today) { Sspm->Settings.energy_yesterday[module][channel] = last_energy_today; // Daily save Sspm->Settings.energy_total[module][channel] += last_energy_today; // Daily incremental save + if (Settings->save_data) { + TasmotaGlobal.save_data_counter = Settings->save_data +2; // Potspone flash write until all relays are updated + } } Sspm->energy_total[module][channel] = Sspm->Settings.energy_total[module][channel] + Sspm->energy_today[module][channel];