Improve PWS support

The previous implementation would have required a firmware update
This commit is contained in:
Matthew Oslan
2019-07-05 22:47:07 -04:00
parent 94681e9f03
commit 7ea1824048
2 changed files with 5 additions and 2 deletions

View File

@@ -56,4 +56,7 @@ export interface AdjustmentMethodResponse {
wateringData: BaseWateringData; wateringData: BaseWateringData;
} }
export interface AdjustmentOptions {} export interface AdjustmentOptions {
/** Information about the PWS to use in the format "pws:API_KEY@PWS_ID". */
pws?: string;
}

View File

@@ -185,7 +185,6 @@ export const getWateringData = async function( req: express.Request, res: expres
location: string | GeoCoordinates = getParameter(req.query.loc), location: string | GeoCoordinates = getParameter(req.query.loc),
outputFormat: string = getParameter(req.query.format), outputFormat: string = getParameter(req.query.format),
remoteAddress: string = getParameter(req.headers[ "x-forwarded-for" ]) || req.connection.remoteAddress, remoteAddress: string = getParameter(req.headers[ "x-forwarded-for" ]) || req.connection.remoteAddress,
pwsString: string = getParameter( req.query.pws ),
adjustmentOptions: AdjustmentOptions; adjustmentOptions: AdjustmentOptions;
// X-Forwarded-For header may contain more than one IP address and therefore // 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 ); let timeData: TimeData = getTimeData( coordinates );
// Parse the PWS information. // Parse the PWS information.
const pwsString: string | undefined = adjustmentOptions.pws;
let pws: PWS | undefined = undefined; let pws: PWS | undefined = undefined;
if ( pwsString ) { if ( pwsString ) {
try { try {