From 10c3a6738799ef6d18bdee63da32bfea46f7ad5c Mon Sep 17 00:00:00 2001 From: Samer Albahra Date: Thu, 23 May 2019 11:08:27 -0500 Subject: [PATCH 1/2] 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 ) : "" ) ); } From 509f9d5b7cb346fcebbf070f978e19942c1dcbae Mon Sep 17 00:00:00 2001 From: Samer Albahra Date: Thu, 23 May 2019 11:13:11 -0500 Subject: [PATCH 2/2] Fix unit testing --- test/expected.json | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/test/expected.json b/test/expected.json index 07816b5..4b78b25 100644 --- a/test/expected.json +++ b/test/expected.json @@ -6,13 +6,7 @@ "tz": 32, "sunrise": 332, "sunset": 1203, - "eip": 2130706433, - "rawData": { - "h": 98.5, - "p": 1.09, - "t": 70.8, - "raining": 1 - } + "eip": 2130706433 } }, "adjustment1": {