diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/autotune/AutotunePlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/autotune/AutotunePlugin.kt index c652c832e0..5f926c28c5 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/autotune/AutotunePlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/autotune/AutotunePlugin.kt @@ -310,11 +310,16 @@ class AutotunePlugin @Inject constructor( json.put("pumpProfileName", pumpProfile.profilename) json.put("pumpPeak", pumpProfile.peak) json.put("pumpDia", pumpProfile.dia) - json.put("tunedProfile", tunedProfile?.profile?.toPureNsJson(dateUtil)) - json.put("tunedCircadianProfile", tunedProfile?.circadianProfile?.toPureNsJson(dateUtil)) - json.put("tunedProfileName", tunedProfile?.profilename) - json.put("tunedPeak", tunedProfile?.peak) - json.put("tunedDia", tunedProfile?.dia) + tunedProfile?.let { atProfile -> + json.put("tunedProfile", atProfile.profile.toPureNsJson(dateUtil)) + json.put("tunedCircadianProfile", atProfile.circadianProfile.toPureNsJson(dateUtil)) + json.put("tunedProfileName", atProfile.profilename) + json.put("tunedPeak", atProfile.peak) + json.put("tunedDia", atProfile.dia) + for (i in 0..23) { + json.put("missingDays_$i", atProfile.basalUntuned[i]) + } + } json.put("result", result) json.put("updateButtonVisibility", updateButtonVisibility) sp.putString(R.string.key_autotune_last_run, json.toString()) @@ -345,6 +350,9 @@ class AutotunePlugin @Inject constructor( tunedProfile = ATProfile(ProfileSealed.Pure(tuned), localInsulin, injector).also { atProfile -> atProfile.profilename = tunedProfileName atProfile.circadianProfile = ProfileSealed.Pure(circadianTuned) + for (i in 0..23) { + atProfile.basalUntuned[i] = JsonHelper.safeGetInt(json,"missingDays_$i") + } } result = JsonHelper.safeGetString(json, "result", "") updateButtonVisibility = JsonHelper.safeGetInt(json, "updateButtonVisibility")