From d850d27dc15e75276eee1aa8cc365874d3ddbf5d Mon Sep 17 00:00:00 2001 From: samuelbles07 Date: Sat, 2 Nov 2024 17:31:05 +0700 Subject: [PATCH] Clear slr when not avail --- src/AgConfigure.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/AgConfigure.cpp b/src/AgConfigure.cpp index 04efa76..266886e 100644 --- a/src/AgConfigure.cpp +++ b/src/AgConfigure.cpp @@ -136,6 +136,8 @@ bool Configuration::updatePmCorrection(JSONVar &json) { return false; } + // TODO: Need to have data type check, with error message response if invalid + // Check algorithm String algorithm = pm02["correctionAlgorithm"]; PMCorrectionAlgorithm algo = matchPmAlgorithm(algorithm); @@ -149,7 +151,10 @@ bool Configuration::updatePmCorrection(JSONVar &json) { // But first check if pmCorrection different from algo if (algo == None || algo == EPA_2021) { if (pmCorrection.algorithm != algo) { + // Deep copy corrections from root to jconfig, so it will be saved later jconfig[jprop_corrections]["pm02"]["correctionAlgorithm"] = algorithm; + jconfig[jprop_corrections]["pm02"]["slr"] = JSON.parse("{}"); // Clear slr + // Update pmCorrection with new values pmCorrection.algorithm = algo; pmCorrection.changed = true; logInfo("PM2.5 correction updated");