diff --git a/FreeAPS/Sources/Models/RawFetchedProfile.swift b/FreeAPS/Sources/Models/RawFetchedProfile.swift index 8411ea979..0e0363bee 100644 --- a/FreeAPS/Sources/Models/RawFetchedProfile.swift +++ b/FreeAPS/Sources/Models/RawFetchedProfile.swift @@ -4,16 +4,12 @@ struct FetchedNightscoutProfileStore: JSON { let _id: String let defaultProfile: String let startDate: String - let mills: Decimal let enteredBy: String - let store: [String: ScheduledNightscoutProfile] - let created_at: String + let store: [String: FetchedNightscoutProfile] } struct FetchedNightscoutProfile: JSON { let dia: Decimal - let carbs_hr: Int - let delay: Decimal let timezone: String let target_low: [NightscoutTimevalue] let target_high: [NightscoutTimevalue] diff --git a/FreeAPS/Sources/Modules/NightscoutConfig/NightscoutConfigStateModel.swift b/FreeAPS/Sources/Modules/NightscoutConfig/NightscoutConfigStateModel.swift index 36cb7a262..8b87cd08c 100644 --- a/FreeAPS/Sources/Modules/NightscoutConfig/NightscoutConfigStateModel.swift +++ b/FreeAPS/Sources/Modules/NightscoutConfig/NightscoutConfigStateModel.swift @@ -133,7 +133,9 @@ extension NightscoutConfig { { do { let fetchedProfileStore = try jsonDecoder.decode([FetchedNightscoutProfileStore].self, from: data) - guard let fetchedProfile: ScheduledNightscoutProfile = fetchedProfileStore.first?.store["default"] + let loop = fetchedProfileStore.first?.enteredBy.contains("Loop") + guard let fetchedProfile: FetchedNightscoutProfile = fetchedProfileStore.first? + .store[loop! ? "Default" : "default"] else { error = "\nCan't find the default Nightscout Profile." group.leave()