diff --git a/core/src/main/java/info/nightscout/androidaps/plugins/pump/PumpSyncImplementation.kt b/core/src/main/java/info/nightscout/androidaps/plugins/pump/PumpSyncImplementation.kt index 1a92af8ae6..4858bb1c43 100644 --- a/core/src/main/java/info/nightscout/androidaps/plugins/pump/PumpSyncImplementation.kt +++ b/core/src/main/java/info/nightscout/androidaps/plugins/pump/PumpSyncImplementation.kt @@ -51,7 +51,7 @@ class PumpSyncImplementation @Inject constructor( * @param serialNumber serial number of of pump * @return true if data is allowed */ - private fun confirmActivePump(timestamp: Long, type: PumpType, serialNumber: String): Boolean { + private fun confirmActivePump(timestamp: Long, type: PumpType, serialNumber: String, showNotification: Boolean = true): Boolean { val storedType = sp.getString(R.string.key_active_pump_type, "") val storedSerial = sp.getString(R.string.key_active_pump_serial_number, "") val storedTimestamp = sp.getLong(R.string.key_active_pump_change_timestamp, 0L) @@ -70,7 +70,7 @@ class PumpSyncImplementation @Inject constructor( return true } - if ((type.description != storedType || serialNumber != storedSerial) && timestamp >= storedTimestamp) + if (showNotification && (type.description != storedType || serialNumber != storedSerial) && timestamp >= storedTimestamp) rxBus.send(EventNewNotification(Notification(Notification.WRONG_PUMP_DATA, resourceHelper.gs(R.string.wrong_pump_data), Notification.URGENT))) aapsLogger.error(LTag.PUMP, "Ignoring pump history record Allowed: ${dateUtil.dateAndTimeAndSecondsString(storedTimestamp)} $storedType $storedSerial Received: $timestamp ${dateUtil.dateAndTimeAndSecondsString(timestamp)} ${type.description} $serialNumber") return false @@ -397,7 +397,8 @@ class PumpSyncImplementation @Inject constructor( } override fun createOrUpdateTotalDailyDose(timestamp: Long, bolusAmount: Double, basalAmount: Double, totalAmount: Double, pumpId: Long?, pumpType: PumpType, pumpSerial: String): Boolean { - if (!confirmActivePump(timestamp, pumpType, pumpSerial)) return false + // there are probably old data in pump -> do not show notification, just ignore + if (!confirmActivePump(timestamp, pumpType, pumpSerial, showNotification = false)) return false val tdd = TotalDailyDose( timestamp = timestamp, bolusAmount = bolusAmount,