From 69e8d64f41f9ecd3a6e1a6d6ba88fa9791b627ad Mon Sep 17 00:00:00 2001 From: Matthew Oslan Date: Wed, 12 Jun 2019 11:02:10 -0400 Subject: [PATCH] Register ETo AdjustmentMethod --- routes/weather.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/routes/weather.ts b/routes/weather.ts index 1401c77..27e24a6 100644 --- a/routes/weather.ts +++ b/routes/weather.ts @@ -11,6 +11,7 @@ import { AdjustmentMethod, AdjustmentMethodResponse, AdjustmentOptions } from ". import ManualAdjustmentMethod from "./adjustmentMethods/ManualAdjustmentMethod"; import ZimmermanAdjustmentMethod from "./adjustmentMethods/ZimmermanAdjustmentMethod"; import RainDelayAdjustmentMethod from "./adjustmentMethods/RainDelayAdjustmentMethod"; +import EToAdjustmentMethod from "./adjustmentMethods/EToAdjustmentMethod"; const weatherProvider: WeatherProvider = new ( require("./weatherProviders/" + ( process.env.WEATHER_PROVIDER || "OWM" ) ).default )(); // Define regex filters to match against location @@ -26,7 +27,8 @@ const filters = { const ADJUSTMENT_METHOD: { [ key: number ] : AdjustmentMethod } = { 0: ManualAdjustmentMethod, 1: ZimmermanAdjustmentMethod, - 2: RainDelayAdjustmentMethod + 2: RainDelayAdjustmentMethod, + 3: EToAdjustmentMethod }; /** @@ -187,6 +189,11 @@ export const getWateringData = async function( req: express.Request, res: expres // the string is split against a comma and the first value is selected remoteAddress = remoteAddress.split( "," )[ 0 ]; + if ( !adjustmentMethod ) { + res.send( "Error: Unknown AdjustmentMethod ID" ); + return; + } + // Parse weather adjustment options try {