diff --git a/internal/mqttingest/latest.go b/internal/mqttingest/latest.go index 7109344..d29d726 100644 --- a/internal/mqttingest/latest.go +++ b/internal/mqttingest/latest.go @@ -121,20 +121,13 @@ func (l *Latest) computeRainIncrement(rainMM float64) float64 { } // Decide mode (unknown): - // If delta is consistently positive when rainMM > 0, cumulative is likely. - // If delta is ~0 while rainMM occasionally > 0, incremental is likely. - // - // Single-sample heuristic: - // - if rainMM > 0 and delta > 0 => lean cumulative - // - if rainMM > 0 and delta ~ 0 => lean incremental + // Default to cumulative once we see any non-zero rain value. This avoids + // wildly overcounting when the service starts and rain_mm is a cumulative counter. if rainMM > 0 { + l.mode = rainModeCumulative if delta > 0.0009 { - l.mode = rainModeCumulative return delta } - // delta near zero but rainMM nonzero suggests incremental - l.mode = rainModeIncremental - return rainMM } return 0