From d05c0b1a9d2f4efb506800b17e7ae48af7586c5c Mon Sep 17 00:00:00 2001 From: RKBoss6 Date: Thu, 24 Jul 2025 21:11:04 -0400 Subject: [PATCH] Use log file dynamically as getSettings() --- apps/smartbatt/module.js | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/apps/smartbatt/module.js b/apps/smartbatt/module.js index 9cbced6b7..5ed500f53 100644 --- a/apps/smartbatt/module.js +++ b/apps/smartbatt/module.js @@ -2,13 +2,16 @@ var dataFile = "smartbattdata.json"; var interval; var storage=require("Storage"); - var settings = Object.assign({ - //Record Interval stored in ms - doLogging:false - }, require('Storage').readJSON("smartbatt.settings.json", true) || {}); + var logFile = "smartbattlog.json"; - var doLogging=true; + + function getSettings(){ + return Object.assign({ + //Record Interval stored in ms + doLogging:false + }, require('Storage').readJSON("smartbatt.settings.json", true) || {}); + } function logBatterySample(entry) { let log = storage.readJSON(logFile, 1) || []; @@ -65,7 +68,7 @@ reason = "Drainage recorded: " + currentDrainage.toFixed(3) + "%/hr"; } - if(settings.doLogging){ + if(getSettings().doLogging){ // Always log the sample logBatterySample({ time: now, @@ -83,7 +86,7 @@ return (oldValue * oldWeight + newValue * newWeight) / (oldWeight + newWeight); } - + function getData() { return storage.readJSON(dataFile, 1) || {