diff --git a/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/data/MedtronicHistoryData.kt b/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/data/MedtronicHistoryData.kt index f43372a488..b8a2d50dee 100644 --- a/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/data/MedtronicHistoryData.kt +++ b/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/data/MedtronicHistoryData.kt @@ -406,7 +406,8 @@ class MedtronicHistoryData @Inject constructor( if (lastPrimeRecord != null) { uploadCareportalEventIfFoundInHistory(lastPrimeRecord, MedtronicConst.Statistics.LastPrime, - DetailedBolusInfo.EventType.CANNULA_CHANGE) + DetailedBolusInfo.EventType.CANNULA_CHANGE + ) } } @@ -889,17 +890,23 @@ class MedtronicHistoryData @Inject constructor( "pumpId=${tempBasalProcess.itemOne.pumpId}, " + "pumpSerial=${medtronicPumpStatus.serialNumber}]") - val result = pumpSync.syncTemporaryBasalWithPumpId( - tryToGetByLocalTime(tempBasalProcess.itemOne.atechDateTime), - 0.0, - tempBasalProcess.durationAsSeconds * 1000L, - true, - PumpSync.TemporaryBasalType.PUMP_SUSPEND, - tempBasalProcess.itemOne.pumpId, - medtronicPumpStatus.pumpType, - medtronicPumpStatus.serialNumber) + if (tempBasalProcess.durationAsSeconds <= 0) { + rxBus.send(EventNewNotification(Notification(Notification.MDT_INVALID_HISTORY_DATA, rh.gs(R.string.invalid_history_data), Notification.URGENT))) + aapsLogger.debug(LTag.PUMP, "syncTemporaryBasalWithPumpId - Skipped") + } else { + val result = pumpSync.syncTemporaryBasalWithPumpId( + tryToGetByLocalTime(tempBasalProcess.itemOne.atechDateTime), + 0.0, + tempBasalProcess.durationAsSeconds * 1000L, + true, + PumpSync.TemporaryBasalType.PUMP_SUSPEND, + tempBasalProcess.itemOne.pumpId, + medtronicPumpStatus.pumpType, + medtronicPumpStatus.serialNumber + ) - aapsLogger.debug(LTag.PUMP, "syncTemporaryBasalWithPumpId: Result: $result") + aapsLogger.debug(LTag.PUMP, "syncTemporaryBasalWithPumpId: Result: $result") + } } }