Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion LoopFollow/Controllers/Nightscout/DeviceStatusLoop.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
10 changes: 8 additions & 2 deletions LoopFollow/Controllers/Nightscout/DeviceStatusOpenAPS.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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
{
Expand Down
3 changes: 3 additions & 0 deletions LoopFollow/Controllers/Nightscout/ProfileManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ final class ProfileManager {
var targetHighSchedule: [TimeValue<HKQuantity>]
var loopOverrides: [LoopOverride]
var trioOverrides: [TrioOverride]
var loopDosingEnabled: Bool?
var units: HKUnit
var timezone: TimeZone
var defaultProfile: String
Expand Down Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions LoopFollow/Controllers/Nightscout/Treatments.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down