diff --git a/LoopFollow/Controllers/Nightscout/DeviceStatusLoop.swift b/LoopFollow/Controllers/Nightscout/DeviceStatusLoop.swift index 1727c0729..f1d048bf8 100644 --- a/LoopFollow/Controllers/Nightscout/DeviceStatusLoop.swift +++ b/LoopFollow/Controllers/Nightscout/DeviceStatusLoop.swift @@ -112,7 +112,11 @@ extension MainViewController { infoManager.clearInfoData(type: .recBolus) Observable.shared.deviceRecBolus.value = nil } - if let loopStatus = lastLoopRecord["recommendedTempBasal"] as? [String: AnyObject] { + // Loop uploads its Closed Loop toggle as loopSettings.dosingEnabled in the profile + if profileManager.loopDosingEnabled == false { + Observable.shared.loopStatusText.value = "⏀" + latestLoopStatusString = "⏀" + } else if let loopStatus = lastLoopRecord["recommendedTempBasal"] as? [String: AnyObject] { if let tempBasalString = loopStatus["timestamp"] as? String, let tempBasalTime = formatter.date(from: tempBasalString)?.timeIntervalSince1970 { diff --git a/LoopFollow/Controllers/Nightscout/DeviceStatusOpenAPS.swift b/LoopFollow/Controllers/Nightscout/DeviceStatusOpenAPS.swift index ceaef95c5..775530d08 100644 --- a/LoopFollow/Controllers/Nightscout/DeviceStatusOpenAPS.swift +++ b/LoopFollow/Controllers/Nightscout/DeviceStatusOpenAPS.swift @@ -72,7 +72,9 @@ extension MainViewController { } // IOB - if let iobMetric = InsulinMetric(from: lastLoopRecord["iob"], key: "iob") { + if let iobMetric = InsulinMetric(from: lastLoopRecord["iob"], key: "iob") + ?? InsulinMetric(from: enactedOrSuggested, key: "IOB") + { infoManager.updateInfoData(type: .iob, value: iobMetric) latestIOB = iobMetric Observable.shared.iobText.value = iobMetric.formattedValue() @@ -224,7 +226,11 @@ extension MainViewController { openAPSPredUpdatedTime = nil } - if let loopStatus = lastLoopRecord["recommendedTempBasal"] as? [String: AnyObject] { + // Trio uploads dosingMode "open" while Closed Loop is off + if lastLoopRecord["dosingMode"] as? String == "open" { + Observable.shared.loopStatusText.value = "⏀" + latestLoopStatusString = "⏀" + } else if let loopStatus = lastLoopRecord["recommendedTempBasal"] as? [String: AnyObject] { if let tempBasalString = loopStatus["timestamp"] as? String, let tempBasalTime = formatter.date(from: tempBasalString)?.timeIntervalSince1970 { diff --git a/LoopFollow/Controllers/Nightscout/ProfileManager.swift b/LoopFollow/Controllers/Nightscout/ProfileManager.swift index 13134f8b6..abbf7000e 100644 --- a/LoopFollow/Controllers/Nightscout/ProfileManager.swift +++ b/LoopFollow/Controllers/Nightscout/ProfileManager.swift @@ -18,6 +18,7 @@ final class ProfileManager { var targetHighSchedule: [TimeValue] var loopOverrides: [LoopOverride] var trioOverrides: [TrioOverride] + var loopDosingEnabled: Bool? var units: HKUnit var timezone: TimeZone var defaultProfile: String @@ -94,6 +95,8 @@ final class ProfileManager { loopOverrides = [] } + loopDosingEnabled = profileData.loopSettings?.dosingEnabled + if let trioOverrides = profileData.trioOverrides { self.trioOverrides = trioOverrides.map { entry in let targetQuantity = entry.target != nil ? HKQuantity(unit: .milligramsPerDeciliter, doubleValue: entry.target!) : nil diff --git a/LoopFollow/Controllers/Nightscout/Treatments.swift b/LoopFollow/Controllers/Nightscout/Treatments.swift index 430751bc4..cdf0d60cc 100644 --- a/LoopFollow/Controllers/Nightscout/Treatments.swift +++ b/LoopFollow/Controllers/Nightscout/Treatments.swift @@ -143,6 +143,10 @@ extension MainViewController { if basalData.count > 0 { clearOldTempBasal() } + if let profileBasal = profileManager.currentBasal() { + infoManager.updateInfoData(type: .basal, value: profileBasal) + Storage.shared.lastBasal.value = profileBasal + } } if bolus.count > 0 { processNSBolus(entries: bolus)