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 2ce0d5852e..9dc3f521b6 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 @@ -132,8 +132,8 @@ class OmnipodDashPumpPlugin @Inject constructor( history.updateFromState(podStateManager), podStateManager.updateActiveCommand() .map { handleCommandConfirmation(it) } - .map { checkPodKaput() } .ignoreElement(), + checkPodKaput() ) ).blockingGet() if (throwable != null) { @@ -143,12 +143,11 @@ class OmnipodDashPumpPlugin @Inject constructor( } } - private fun checkPodKaput() { - if (podStateManager.isPodKaput) { - val tbr = pumpSync.expectedPumpState().temporaryBasal - if (tbr?.rate == 0.0) { - return - } + private fun checkPodKaput(): Completable = Completable.defer { + val tbr = pumpSync.expectedPumpState().temporaryBasal + if (podStateManager.isPodKaput && + (tbr == null || tbr.rate != 0.0) + ) { pumpSync.syncTemporaryBasalWithPumpId( timestamp = System.currentTimeMillis(), rate = 0.0, @@ -160,6 +159,7 @@ class OmnipodDashPumpPlugin @Inject constructor( pumpSerial = serialNumber() ) } + Completable.complete() } override fun setNewBasalProfile(profile: Profile): PumpEnactResult { 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 423cd8f836..7d2df0242b 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 @@ -140,7 +140,7 @@ class OmnipodDashPodStateManagerImpl @Inject constructor( override val activeAlerts: EnumSet? get() = podState.activeAlerts - override val alarmType: AlarmType? + override val alarmType: AlarmType? get() = podState.alarmType override var tempBasal: OmnipodDashPodStateManager.TempBasal? diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/OmnipodDashOverviewFragment.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/OmnipodDashOverviewFragment.kt index 8ec1db4fa4..3d0099c1af 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/OmnipodDashOverviewFragment.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/OmnipodDashOverviewFragment.kt @@ -296,10 +296,12 @@ class OmnipodDashOverviewFragment : DaggerFragment() { } */ podStateManager.alarmType?.let { - errors.add(resourceHelper.gs( - R.string.omnipod_common_pod_status_pod_fault_description, - it.value, - it.toString()) + errors.add( + resourceHelper.gs( + R.string.omnipod_common_pod_status_pod_fault_description, + it.value, + it.toString() + ) ) }