diff --git a/NightscoutServiceKit/Extensions/StoredDosingDecision.swift b/NightscoutServiceKit/Extensions/StoredDosingDecision.swift index 09e59fb..c1bf0c9 100644 --- a/NightscoutServiceKit/Extensions/StoredDosingDecision.swift +++ b/NightscoutServiceKit/Extensions/StoredDosingDecision.swift @@ -61,11 +61,10 @@ extension StoredDosingDecision { } var loopStatusEnacted: LoopEnacted? { - guard case .some(.tempBasal(let tempBasal)) = pumpManagerStatus?.basalDeliveryState else { + guard let automaticDoseRecommendation = automaticDoseRecommendation, errors.isEmpty, let tempBasal = automaticDoseRecommendation.basalAdjustment else { return nil } - let duration = tempBasal.endDate.timeIntervalSince(tempBasal.startDate) - return LoopEnacted(rate: tempBasal.unitsPerHour, duration: duration, timestamp: tempBasal.startDate, received: true) + return LoopEnacted(rate: tempBasal.unitsPerHour, duration: tempBasal.duration, timestamp: date, received: true, bolusVolume: automaticDoseRecommendation.bolusUnits ?? 0) } var loopStatusFailureReason: String? {