From 10c3a6738799ef6d18bdee63da32bfea46f7ad5c Mon Sep 17 00:00:00 2001 From: Samer Albahra Date: Thu, 23 May 2019 11:08:27 -0500 Subject: [PATCH] Hide raw data when not used --- routes/weather.ts | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/routes/weather.ts b/routes/weather.ts index f24f5f9..be4f644 100644 --- a/routes/weather.ts +++ b/routes/weather.ts @@ -312,14 +312,17 @@ export const getWateringData = async function( req: express.Request, res: expres sunrise: timeData.sunrise, sunset: timeData.sunset, eip: ipToInt( remoteAddress ), - // TODO this may need to be changed (https://github.com/OpenSprinkler/OpenSprinkler-Weather/pull/11#issuecomment-491037948) - rawData: { + rawData: undefined + }; + + if ( adjustmentMethod > 0 ) { + data.rawData = { h: wateringData ? Math.round( wateringData.humidity * 100) / 100 : null, p: wateringData ? Math.round( wateringData.precip * 100 ) / 100 : null, t: wateringData ? Math.round( wateringData.temp * 10 ) / 10 : null, raining: wateringData ? ( wateringData.raining ? 1 : 0 ) : null } - }; + } if ( local.useLocalWeather() ) { console.log( "OpenSprinkler Weather Response: %s", JSON.stringify( data ) ); @@ -335,7 +338,7 @@ export const getWateringData = async function( req: express.Request, res: expres "&sunrise=" + data.sunrise + "&sunset=" + data.sunset + "&eip=" + data.eip + - "&rawData=" + JSON.stringify( data.rawData ) + ( adjustmentMethod > 0 ? "&rawData=" + JSON.stringify( data.rawData ) : "" ) ); }