Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return raw data used to calculate watering level #19

Merged
merged 1 commit into from
May 4, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions routes/weather.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ var http = require( "http" ),
time: /(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})([+-])(\d{2})(\d{2})/,
timezone: /^()()()()()()([+-])(\d{2})(\d{2})/
};

// If location does not match GPS or PWS/ICAO, then attempt to resolve
// location using Weather Underground autocomplete API
function resolveCoordinates( location, callback ) {
Expand Down Expand Up @@ -131,7 +131,7 @@ function getOWMWeatherData( location, callback ) {
callback( weather );
} );
} );
} );
} );
}

// Calculate timezone and sun rise/set information
Expand Down Expand Up @@ -308,7 +308,8 @@ exports.getWateringData = function( req, res ) {
tz: getTimezone( weather.timezone ),
sunrise: weather.sunrise,
sunset: weather.sunset,
eip: ipToInt( remoteAddress )
eip: ipToInt( remoteAddress ),
rawData: { h: weather.humidity, p: weather.precip, t: weather.temp }
};

// Return the response to the client in the requested format
Expand All @@ -320,7 +321,8 @@ exports.getWateringData = function( req, res ) {
"&tz=" + data.tz +
"&sunrise=" + data.sunrise +
"&sunset=" + data.sunset +
"&eip=" + data.eip
"&eip=" + data.eip +
"&rawData=" + JSON.stringify( data.rawData )
);
}
};
Expand Down