From 63aaa3883437f3a32cf22e27672a8d9017e3179b Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Fri, 11 Oct 2019 10:12:58 +0200 Subject: [PATCH] do not run automation if loop is suspended --- .../plugins/general/automation/AutomationPlugin.kt | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/AutomationPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/AutomationPlugin.kt index 7a2023cc1e..8b78ae6458 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/AutomationPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/AutomationPlugin.kt @@ -13,6 +13,7 @@ import info.nightscout.androidaps.interfaces.PluginBase import info.nightscout.androidaps.interfaces.PluginDescription import info.nightscout.androidaps.interfaces.PluginType import info.nightscout.androidaps.logging.L +import info.nightscout.androidaps.plugins.aps.loop.LoopPlugin import info.nightscout.androidaps.plugins.bus.RxBus import info.nightscout.androidaps.plugins.general.automation.actions.* import info.nightscout.androidaps.plugins.general.automation.events.EventAutomationDataChanged @@ -160,11 +161,16 @@ object AutomationPlugin : PluginBase(PluginDescription() private fun processActions() { if (!isEnabled(PluginType.GENERAL)) return + if (LoopPlugin.getPlugin().isSuspended) { + if (L.isEnabled(L.AUTOMATION)) + log.debug("Loop deactivated") + return + } if (L.isEnabled(L.AUTOMATION)) log.debug("processActions") for (event in automationEvents) { - if (event.isEnabled() && event.trigger.shouldRun() && event.preconditions.shouldRun()) { + if (event.isEnabled && event.trigger.shouldRun() && event.preconditions.shouldRun()) { val actions = event.actions for (action in actions) { action.doAction(object : Callback() {