Remove extreme fluctuation check, because of accuracy decline

master
RKBoss6 2025-08-01 16:13:24 -04:00 committed by GitHub
parent c97d8179df
commit d28d762304
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 32 additions and 57 deletions

View File

@ -60,37 +60,12 @@
data.battLastRecorded = batt;
storage.writeJSON(dataFile, data);
} else {
let weightCoefficient = 1;
let currentDrainage = battChange / deltaHours;
let drainageChange = data.avgBattDrainage - currentDrainage;
//check if drainage rate has fluctuated quite a bit
//If fluctuation event is 0, first time fluctuating like this, cycles > 10 so as not to interfere with initial data collection.
if(Math.abs(drainageChange)>currentDrainage*0.7&&data.fluctuationEvent==0&&data.totalCycles>=10){
//has fluctuated, first time doing so
reason="Skipped: Extreme fluctuation";
//set fluctuationevent so it knows what was the first time.
data.fluctuationEvent=data.totalCycles+1;
data.battLastRecorded=batt;
storage.writeJSON(dataFile, data);
if(getSettings().doLogging){
// Always log the sample
logBatterySample({
battNow: batt,
battLast: data.battLastRecorded,
battChange: battChange,
deltaHours: deltaHours,
avgDrainage: data.avgBattDrainage,
reason: reason
});
return;
}else{
data.fluctuationEvent=0;
}
}
let newAvg = weightedAverage(data.avgBattDrainage, data.totalHours, currentDrainage, deltaHours);
let newAvg = weightedAverage(data.avgBattDrainage, data.totalHours, currentDrainage, deltaHours * weightCoefficient);
data.avgBattDrainage = newAvg;
data.timeLastRecorded = now;
data.totalCycles += 1;
@ -107,6 +82,7 @@
battLast: data.battLastRecorded,
battChange: battChange,
deltaHours: deltaHours,
timeLastRecorded: data.timeLastRecorded,
avgDrainage: data.avgBattDrainage,
reason: reason
});
@ -126,7 +102,6 @@
timeLastRecorded: Date.now(),
totalCycles: 0,
totalHours: 0,
fluctuationEvent:0
};
}