From 7ea1824048e4b3292bbc0efe1ebf469bdd080c5b Mon Sep 17 00:00:00 2001 From: Matthew Oslan Date: Fri, 5 Jul 2019 22:47:07 -0400 Subject: [PATCH] Improve PWS support The previous implementation would have required a firmware update --- routes/adjustmentMethods/AdjustmentMethod.ts | 5 ++++- routes/weather.ts | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/routes/adjustmentMethods/AdjustmentMethod.ts b/routes/adjustmentMethods/AdjustmentMethod.ts index 3416a2a..2e5e051 100644 --- a/routes/adjustmentMethods/AdjustmentMethod.ts +++ b/routes/adjustmentMethods/AdjustmentMethod.ts @@ -56,4 +56,7 @@ export interface AdjustmentMethodResponse { wateringData: BaseWateringData; } -export interface AdjustmentOptions {} +export interface AdjustmentOptions { + /** Information about the PWS to use in the format "pws:API_KEY@PWS_ID". */ + pws?: string; +} diff --git a/routes/weather.ts b/routes/weather.ts index b41e00e..c0e7d21 100644 --- a/routes/weather.ts +++ b/routes/weather.ts @@ -185,7 +185,6 @@ export const getWateringData = async function( req: express.Request, res: expres location: string | GeoCoordinates = getParameter(req.query.loc), outputFormat: string = getParameter(req.query.format), remoteAddress: string = getParameter(req.headers[ "x-forwarded-for" ]) || req.connection.remoteAddress, - pwsString: string = getParameter( req.query.pws ), adjustmentOptions: AdjustmentOptions; // X-Forwarded-For header may contain more than one IP address and therefore @@ -219,6 +218,7 @@ export const getWateringData = async function( req: express.Request, res: expres let timeData: TimeData = getTimeData( coordinates ); // Parse the PWS information. + const pwsString: string | undefined = adjustmentOptions.pws; let pws: PWS | undefined = undefined; if ( pwsString ) { try {