Calculate 3h average only if data is available
parent
da9261446f
commit
02bb0ab481
|
|
@ -171,11 +171,15 @@
|
||||||
storage.writeJSON(LOG_FILE, history3);
|
storage.writeJSON(LOG_FILE, history3);
|
||||||
|
|
||||||
// calculate 3h average for widget
|
// calculate 3h average for widget
|
||||||
|
if (history3.length > 0) {
|
||||||
let sum = 0;
|
let sum = 0;
|
||||||
for (let i = 0; i < history3.length; i++) {
|
for (let i = 0; i < history3.length; i++) {
|
||||||
sum += history3[i]["p"];
|
sum += history3[i]["p"];
|
||||||
}
|
}
|
||||||
threeHourAvrPressure = sum / history3.length;
|
threeHourAvrPressure = sum / history3.length;
|
||||||
|
} else {
|
||||||
|
threeHourAvrPressure = undefined;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue