diff --git a/plugins/automation/src/main/kotlin/app/aaps/plugins/automation/triggers/TriggerBg.kt b/plugins/automation/src/main/kotlin/app/aaps/plugins/automation/triggers/TriggerBg.kt index 83d0a7c3a3..b7f2fd696f 100644 --- a/plugins/automation/src/main/kotlin/app/aaps/plugins/automation/triggers/TriggerBg.kt +++ b/plugins/automation/src/main/kotlin/app/aaps/plugins/automation/triggers/TriggerBg.kt @@ -13,6 +13,7 @@ import app.aaps.plugins.automation.elements.StaticLabel import dagger.android.HasAndroidInjector import org.json.JSONObject import java.util.Optional +import kotlin.math.roundToInt class TriggerBg(injector: HasAndroidInjector) : Trigger(injector) { @@ -54,7 +55,7 @@ class TriggerBg(injector: HasAndroidInjector) : Trigger(injector) { aapsLogger.debug(LTag.AUTOMATION, "NOT ready for execution: " + friendlyDescription()) return false } - if (comparator.value.check(glucoseStatus.glucose, profileUtil.convertToMgdl(bg.value, bg.units))) { + if (comparator.value.check(glucoseStatus.glucose.roundToInt(), profileUtil.convertToMgdl(bg.value, bg.units).roundToInt())) { aapsLogger.debug(LTag.AUTOMATION, "Ready for execution: " + friendlyDescription()) return true } diff --git a/plugins/automation/src/main/kotlin/app/aaps/plugins/automation/triggers/TriggerProfilePercent.kt b/plugins/automation/src/main/kotlin/app/aaps/plugins/automation/triggers/TriggerProfilePercent.kt index d13dcc9c49..a60d94c585 100644 --- a/plugins/automation/src/main/kotlin/app/aaps/plugins/automation/triggers/TriggerProfilePercent.kt +++ b/plugins/automation/src/main/kotlin/app/aaps/plugins/automation/triggers/TriggerProfilePercent.kt @@ -13,6 +13,7 @@ import app.aaps.plugins.automation.elements.StaticLabel import dagger.android.HasAndroidInjector import org.json.JSONObject import java.util.Optional +import kotlin.math.roundToInt class TriggerProfilePercent(injector: HasAndroidInjector) : Trigger(injector) { @@ -54,13 +55,13 @@ class TriggerProfilePercent(injector: HasAndroidInjector) : Trigger(injector) { return false } if (profile is ProfileSealed.EPS) { - if (comparator.value.check(profile.value.originalPercentage.toDouble(), pct.value)) { + if (comparator.value.check(profile.value.originalPercentage, pct.value.roundToInt())) { aapsLogger.debug(LTag.AUTOMATION, "Ready for execution: " + friendlyDescription()) return true } } if (profile is ProfileSealed.Pure) { - if (comparator.value.check(100.0, pct.value)) { + if (comparator.value.check(100, pct.value.roundToInt())) { aapsLogger.debug(LTag.AUTOMATION, "Ready for execution: " + friendlyDescription()) return true } diff --git a/plugins/automation/src/main/kotlin/app/aaps/plugins/automation/triggers/TriggerTempTargetValue.kt b/plugins/automation/src/main/kotlin/app/aaps/plugins/automation/triggers/TriggerTempTargetValue.kt index 4defa7c6eb..7c38fd3755 100644 --- a/plugins/automation/src/main/kotlin/app/aaps/plugins/automation/triggers/TriggerTempTargetValue.kt +++ b/plugins/automation/src/main/kotlin/app/aaps/plugins/automation/triggers/TriggerTempTargetValue.kt @@ -14,6 +14,7 @@ import app.aaps.plugins.automation.elements.StaticLabel import dagger.android.HasAndroidInjector import org.json.JSONObject import java.util.Optional +import kotlin.math.roundToInt class TriggerTempTargetValue(injector: HasAndroidInjector) : Trigger(injector) { @@ -51,7 +52,7 @@ class TriggerTempTargetValue(injector: HasAndroidInjector) : Trigger(injector) { aapsLogger.debug(LTag.AUTOMATION, "Ready for execution: " + friendlyDescription()) return true } - if (tt is ValueWrapper.Existing && comparator.value.check(tt.value.lowTarget, profileUtil.convertToMgdl(ttValue.value, ttValue.units))) { + if (tt is ValueWrapper.Existing && comparator.value.check(tt.value.lowTarget.roundToInt(), profileUtil.convertToMgdl(ttValue.value, ttValue.units).roundToInt())) { aapsLogger.debug(LTag.AUTOMATION, "Ready for execution: " + friendlyDescription()) return true }