diff --git a/lib/iob/history.js b/lib/iob/history.js index 681f4d345..1006c34b6 100644 --- a/lib/iob/history.js +++ b/lib/iob/history.js @@ -289,7 +289,7 @@ function calcTempTreatments (inputs, zeroTempDuration) { temp.date = temp.started_at.getTime(); temp.insulin = current.insulin; tempBoluses.push(temp); - } else if (current.eventType == "Temp Basal" && current.enteredBy=="HAPP_App") { + } else if (current.eventType == "Temp Basal" && (current.enteredBy == "HAPP_App" || current.enteredBy == "openaps://AndroidAPS")) { var temp = {}; temp.rate = current.absolute; temp.duration = current.duration; @@ -357,6 +357,10 @@ function calcTempTreatments (inputs, zeroTempDuration) { for (var i=0; i+1 < tempHistory.length; i++) { if (tempHistory[i].date + tempHistory[i].duration*60*1000 > tempHistory[i+1].date) { tempHistory[i].duration = (tempHistory[i+1].date - tempHistory[i].date)/60/1000; + // Delete AndroidAPS "Cancel TBR records" in which duration is not populated + if (tempHistory[i+1].duration == null) { + tempHistory.splice(i+1, 1); + } } }