Add support for fallback WeatherProviders

This commit is contained in:
Matthew Oslan
2019-05-21 22:14:46 -04:00
parent 0297341670
commit 0e23e56817
2 changed files with 50 additions and 1 deletions

View File

@@ -7,7 +7,11 @@ import * as geoTZ from "geo-tz";
import * as local from "./local";
import { AdjustmentOptions, GeoCoordinates, TimeData, WateringData, WeatherData, WeatherProvider } from "../types";
const weatherProvider: WeatherProvider = require("./weatherProviders/" + ( process.env.WEATHER_PROVIDER || "OWM" ) ).default;
import CompositeWeatherProvider from "./weatherProviders/CompositeWeatherProvider";
const weatherProvider: WeatherProvider = new CompositeWeatherProvider(
( process.env.WEATHER_PROVIDER || "OWM" ).split( "," ).map( ( id ) => require( "./weatherProviders/" + id ).default )
);
// Define regex filters to match against location
const filters = {