From 3f040e77443b8561c24511cd50c6978f77e66bfc Mon Sep 17 00:00:00 2001 From: "Ashley M. Kirchner" Date: Fri, 29 Apr 2016 12:52:10 -0600 Subject: [PATCH 1/2] Update weatherforecast.js Added the option to change the amount of forecasted days returned by the OpenWeatherAPI. --- modules/default/weatherforecast/weatherforecast.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/modules/default/weatherforecast/weatherforecast.js b/modules/default/weatherforecast/weatherforecast.js index c1e79828..c5b8762b 100644 --- a/modules/default/weatherforecast/weatherforecast.js +++ b/modules/default/weatherforecast/weatherforecast.js @@ -14,6 +14,7 @@ Module.register("weatherforecast",{ location: "", appid: "", units: config.units, + maxNumberOfDays: 7, updateInterval: 10 * 60 * 1000, // every 10 minutes animationSpeed: 1000, timeFormat: config.timeFormat, @@ -189,6 +190,12 @@ Module.register("weatherforecast",{ params += "q=" + this.config.location; params += "&units=" + this.config.units; params += "&lang=" + this.config.lang; + /* + * Submit a specific number of days to forecast, between 1 to 16 days. + * The OpenWeatherMap API properly handles values outside of the 1 - 16 range and returns 7 days by default. + * This is simply being pedantic and doing it ourselves. + */ + params += "&cnt=" + (((this.config.maxNumberOfDays < 1) || (this.config.maxNumberOfDays > 16)) ? 7 : this.config.maxNumberOfDays); params += "&APPID=" + this.config.appid; return params; From 4d0a93fc3b2e6a4d1aeb3768216a8bee87639532 Mon Sep 17 00:00:00 2001 From: "Ashley M. Kirchner" Date: Fri, 29 Apr 2016 12:58:03 -0600 Subject: [PATCH 2/2] Update README.md Added the maxNumberOfDays config option to change the amount of forecasted days returned by the OpenWeatherAPI. --- modules/default/weatherforecast/README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/modules/default/weatherforecast/README.md b/modules/default/weatherforecast/README.md index c5be33ce..9e93bd14 100644 --- a/modules/default/weatherforecast/README.md +++ b/modules/default/weatherforecast/README.md @@ -55,6 +55,14 @@ The following properties can be configured:
Default value: config.units + + maxNumberOfDays + How many days of forecast to return. Specified by config.js
+
Possible values: 1 - 16 +
Default value: 7 (7 days) +
This value is optional. By default the weatherforecast module will return 7 days. + + updateInterval How often does the content needs to be fetched? (Milliseconds)