diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/OmnipodDashPumpPlugin.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/OmnipodDashPumpPlugin.kt index 99133748f3..62d9d3748d 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/OmnipodDashPumpPlugin.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/OmnipodDashPumpPlugin.kt @@ -307,7 +307,7 @@ class OmnipodDashPumpPlugin @Inject constructor( return ret } - private fun observeNoActiveTempBasal(enforeNew: Boolean): Completable { + private fun observeNoActiveTempBasal(enforceNew: Boolean): Completable { return Completable.defer { val expectedState = pumpSync.expectedPumpState() when { @@ -315,7 +315,7 @@ class OmnipodDashPumpPlugin @Inject constructor( aapsLogger.info(LTag.PUMP, "No temporary basal to cancel") Completable.complete() } - !enforeNew -> + !enforceNew -> Completable.error( IllegalStateException( "Temporary basal already active and enforeNew is not set." @@ -335,7 +335,7 @@ class OmnipodDashPumpPlugin @Inject constructor( private fun observeActiveTempBasal(): Completable { return Completable.defer { - if (pumpSync.expectedPumpState().temporaryBasal != null) + if (podStateManager.tempBasalActive) Completable.complete() else Completable.error( diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/state/OmnipodDashPodStateManagerImpl.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/state/OmnipodDashPodStateManagerImpl.kt index f100620760..b84cf5eb13 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/state/OmnipodDashPodStateManagerImpl.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/state/OmnipodDashPodStateManagerImpl.kt @@ -148,7 +148,7 @@ class OmnipodDashPodStateManagerImpl @Inject constructor( get() = podState.tempBasal override val tempBasalActive: Boolean - get() = tempBasal != null && tempBasal!!.startTime + tempBasal!!.durationInMinutes * 60 * 1000 > System.currentTimeMillis() + get() = podState.deliveryStatus in arrayOf(DeliveryStatus.TEMP_BASAL_ACTIVE, DeliveryStatus.BOLUS_AND_TEMP_BASAL_ACTIVE) override var basalProgram: BasalProgram? get() = podState.basalProgram