diff --git a/config/config.js.sample b/config/config.js.sample index 814471c3..f775f941 100644 --- a/config/config.js.sample +++ b/config/config.js.sample @@ -83,7 +83,6 @@ var config = { config: { weatherProvider: "openweathermap", type: "forecast", - weatherEndpoint: "/forecast", location: "New York", locationID: "5128581", //ID from http://bulk.openweathermap.org/sample/city.list.json.gz; unzip the gz file and find your city apiKey: "YOUR_OPENWEATHER_API_KEY" diff --git a/modules/default/weather/providers/openweathermap.js b/modules/default/weather/providers/openweathermap.js index 66f31703..c71dbd87 100755 --- a/modules/default/weather/providers/openweathermap.js +++ b/modules/default/weather/providers/openweathermap.js @@ -18,7 +18,7 @@ WeatherProvider.register("openweathermap", { defaults: { apiVersion: "2.5", apiBase: "https://api.openweathermap.org/data/", - weatherEndpoint: "/weather", + weatherEndpoint: "", locationID: false, location: false, lat: 0, @@ -96,8 +96,21 @@ WeatherProvider.register("openweathermap", { */ setConfig(config) { this.config = config; - if (this.config.type === "hourly") { - this.config.weatherEndpoint = "/onecall"; + if (!this.config.weatherEndpoint) { + switch (this.config.type) { + case "hourly": + this.config.weatherEndpoint = "/onecall"; + break; + case "daily": + case "forecast": + this.config.weatherEndpoint = "/forecast"; + break; + case "current": + this.config.weatherEndpoint = "/weather"; + break; + default: + Log.error("weatherEndpoint not configured and could not resolve it based on type"); + } } },