fix rain data for wunderground

This commit is contained in:
2026-02-02 16:31:09 +11:00
parent 633bdcfacd
commit f014b86673

View File

@@ -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 {
if delta > 0.0009 {
l.mode = rainModeCumulative
if delta > 0.0009 {
return delta
}
// delta near zero but rainMM nonzero suggests incremental
l.mode = rainModeIncremental
return rainMM
}
return 0