Clear invalid measurements
All checks were successful
Build and Publish / release (push) Successful in 3m34s

This commit is contained in:
Ryan McGuire 2025-01-28 19:26:40 -05:00
parent f2f160b112
commit ce0ef7d291

View File

@ -15,11 +15,21 @@ func (u *WeatherUpdate) Enrich(weatherStations ...*config.WeatherStation) {
return
}
// Clear invalid measurements
if u.BaromAbsoluteIn != nil && *u.BaromAbsoluteIn < 20 {
u.BaromAbsoluteIn = nil
}
if u.BaromRelativeIn != nil && *u.BaromRelativeIn < 20 {
u.BaromRelativeIn = nil
}
// Calculate Wind Chill
if u.WindChillF == nil && u.TempOutdoorF != nil && u.WindSpeedMPH != nil {
wc := CalculateWindChill(*u.TempOutdoorF, *u.WindSpeedMPH)
u.WindChillF = &wc
}
// Calculate Dew Point
if u.DewPointF == nil && (u.TempOutdoorF != nil && u.HumidityOudoor != nil) {
if *u.TempOutdoorF != 0 || *u.HumidityOudoor != 0 {
dp := CalculateDewPoint(*u.TempOutdoorF, float64(*u.HumidityOudoor))
@ -27,6 +37,7 @@ func (u *WeatherUpdate) Enrich(weatherStations ...*config.WeatherStation) {
}
}
// Use relative pressure if absolute isn't provided
if u.BaromAbsoluteIn == nil && u.BaromRelativeIn != nil {
u.BaromAbsoluteIn = u.BaromRelativeIn
}