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 ) : "" ) ); } 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": {