diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSAMA/OpenAPSAMAPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSAMA/OpenAPSAMAPlugin.java index 60853ed4d1..74d15cd2a4 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSAMA/OpenAPSAMAPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSAMA/OpenAPSAMAPlugin.java @@ -1,5 +1,6 @@ package info.nightscout.androidaps.plugins.OpenAPSAMA; +import info.nightscout.androidaps.plugins.IobCobCalculator.AutosensData; import org.json.JSONException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -173,7 +174,11 @@ public class OpenAPSAMAPlugin extends PluginBase implements APSInterface { startPart = new Date(); if (MainApp.getConstraintChecker().isAutosensModeEnabled().value()) { - lastAutosensResult = IobCobCalculatorPlugin.getPlugin().getLastAutosensDataSynchronized("OpenAPSPlugin").autosensResult; + AutosensData autosensData = IobCobCalculatorPlugin.getPlugin().getLastAutosensDataSynchronized("OpenAPSPlugin"); + if (autosensData == null) { + MainApp.bus().post(new EventOpenAPSUpdateResultGui(MainApp.gs(R.string.openaps_noasdata))); + return; + } } else { lastAutosensResult = new AutosensResult(); lastAutosensResult.sensResult = "autosens disabled"; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSSMB/OpenAPSSMBPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSSMB/OpenAPSSMBPlugin.java index 1bb4c25bb3..570b76502f 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSSMB/OpenAPSSMBPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSSMB/OpenAPSSMBPlugin.java @@ -1,5 +1,6 @@ package info.nightscout.androidaps.plugins.OpenAPSSMB; +import info.nightscout.androidaps.plugins.IobCobCalculator.AutosensData; import org.json.JSONException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -180,7 +181,12 @@ public class OpenAPSSMBPlugin extends PluginBase implements APSInterface { startPart = new Date(); if (MainApp.getConstraintChecker().isAutosensModeEnabled().value()) { - lastAutosensResult = IobCobCalculatorPlugin.getPlugin().getLastAutosensDataSynchronized("OpenAPSPlugin").autosensResult; + AutosensData autosensData = IobCobCalculatorPlugin.getPlugin().getLastAutosensDataSynchronized("OpenAPSPlugin"); + if (autosensData == null) { + MainApp.bus().post(new EventOpenAPSUpdateResultGui(MainApp.gs(R.string.openaps_noasdata))); + return; + } + lastAutosensResult = autosensData.autosensResult; } else { lastAutosensResult = new AutosensResult(); lastAutosensResult.sensResult = "autosens disabled"; diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 08e4d42619..f908818749 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1168,6 +1168,7 @@ A treatment (insulin: %.2f, carbs: %d, at: %s) could not be added to treatments. Please check and manually add a record as appropriate. Generated eCarbs with amount: %1$dg, duration: %2$dh, delay: %3$dm key_plugin_stats_report_timestamp + No autosens data available %d day