From 80701302a656f4473ae442790c3f289c85cde513 Mon Sep 17 00:00:00 2001 From: Pete ba Date: Sun, 10 Nov 2019 14:54:18 +0000 Subject: [PATCH] Initial commit --- routes/weatherProviders/WUnderground.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/routes/weatherProviders/WUnderground.ts b/routes/weatherProviders/WUnderground.ts index e83d41e..be30b5d 100644 --- a/routes/weatherProviders/WUnderground.ts +++ b/routes/weatherProviders/WUnderground.ts @@ -28,10 +28,12 @@ export default class WUnderground extends WeatherProvider { } const totals = { temp: 0, humidity: 0, precip: 0 }; + let lastPrecip = samples[0].imperial.precipTotal; for ( const sample of samples ) { totals.temp += sample.imperial.tempAvg; totals.humidity += sample.humidityAvg; - totals.precip += sample.imperial.precipRate; + totals.precip += ( sample.imperial.precipTotal - lastPrecip > 0 ) ? sample.imperial.precipTotal - lastPrecip : 0; + lastPrecip = sample.imperial.precipTotal } return {