diff --git a/plugins/smoothing/src/main/java/info/nightscout/smoothing/AvgSmoothingPlugin.kt b/plugins/smoothing/src/main/java/info/nightscout/smoothing/AvgSmoothingPlugin.kt index a930c1eb6e..f9e0791bbb 100644 --- a/plugins/smoothing/src/main/java/info/nightscout/smoothing/AvgSmoothingPlugin.kt +++ b/plugins/smoothing/src/main/java/info/nightscout/smoothing/AvgSmoothingPlugin.kt @@ -34,6 +34,11 @@ class AvgSmoothingPlugin @Inject constructor( @Suppress("LocalVariableName") override fun smooth(data: MutableList): MutableList { + if (data.lastIndex < 4) + { + aapsLogger.debug(LTag.GLUCOSE, "Not enough value's to smooth!") + return data + } for (i in data.lastIndex -1 downTo 1) { // Check if value's are in a valid range