From c78f1e15094abbd4d3898ef0b262d9ad8fb6ba8c Mon Sep 17 00:00:00 2001 From: Klagarge Date: Wed, 27 May 2026 15:23:13 +0200 Subject: [PATCH] fix(db): filter random value Signed-off-by: Klagarge --- db/src/main.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/db/src/main.go b/db/src/main.go index 926bc59..867bbb8 100644 --- a/db/src/main.go +++ b/db/src/main.go @@ -146,13 +146,19 @@ func main() { } } - // If CO2PPM value is present and over 1000000000 delete the field + // If CO2PPM value is present and over 1,000,000,000 delete the field, it's calibration value values := dp.GetValues() if values.CO2PPM > 1000000000 { - log.Printf("[Main] Warning: CO2PPM value %d is over threshold, setting to 0\n", values.CO2PPM) + log.Printf("[Main] Warning: CO2PPM value %d is calibrating, setting to 0\n", values.CO2PPM) values.CO2PPM = 0 } + // Still too high value, something wrong, dropping datapoint + if values.CO2PPM > 10000 { + log.Printf("[Main] Error: CO2PPM value %d is over threshold, dropping Datapoint\n", values.CO2PPM) + return + } + translatedDp := provenceMeasurement.CreateDataPoint(influxTags, values, dp.Timestamp()) if err := influxGateway.AddDatapoint(&translatedDp); err != nil {