diff --git a/CHANGELOG.md b/CHANGELOG.md index d3acbcc4..0acfecc9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -29,6 +29,7 @@ This project adheres to [Semantic Versioning](http://semver.org/). - Added option `address` to set bind address. - Added option `onlyTemp` for currentweather module to show show only current temperature and weather icon. - Added option `remoteFile` to compliments module to load compliment array from filesystem. +- Added option `roundTemp` for currentweather and weatherforecast modules to display temperatures rounded to nearest integer. ### Updated - Modified translations for Frysk. diff --git a/modules/default/currentweather/README.md b/modules/default/currentweather/README.md index 35c03404..335dc0de 100644 --- a/modules/default/currentweather/README.md +++ b/modules/default/currentweather/README.md @@ -64,6 +64,13 @@ The following properties can be configured:
Default value: config.units + + roundTemp + Round temperature value to nearest integer.
+
Possible values: true (round to integer) or false (display exact value with decimal point) +
Default value: false + + updateInterval How often does the content needs to be fetched? (Milliseconds)
diff --git a/modules/default/currentweather/currentweather.js b/modules/default/currentweather/currentweather.js index a379332d..ab48b911 100644 --- a/modules/default/currentweather/currentweather.js +++ b/modules/default/currentweather/currentweather.js @@ -36,7 +36,8 @@ Module.register("currentweather",{ calendarClass: "calendar", onlyTemp: false, - + roundTemp: false, + iconTable: { "01d": "wi-day-sunny", "02d": "wi-day-cloudy", @@ -385,14 +386,6 @@ Module.register("currentweather",{ return 12; }, - /* function(temperature) - * Rounds a temperature to 1 decimal. - * - * argument temperature number - Temperature. - * - * return number - Rounded Temperature. - */ - deg2Cardinal: function(deg) { if (deg>11.25 && deg<=33.75){ return "NNE"; @@ -429,8 +422,15 @@ Module.register("currentweather",{ } }, - + /* function(temperature) + * Rounds a temperature to 1 decimal or integer (depending on config.roundTemp). + * + * argument temperature number - Temperature. + * + * return number - Rounded Temperature. + */ roundValue: function(temperature) { - return parseFloat(temperature).toFixed(1); + var decimals = this.config.roundTemp ? 0 : 1; + return parseFloat(temperature).toFixed(decimals); } }); diff --git a/modules/default/weatherforecast/README.md b/modules/default/weatherforecast/README.md index 6b88d21e..0cc3e46b 100644 --- a/modules/default/weatherforecast/README.md +++ b/modules/default/weatherforecast/README.md @@ -64,6 +64,13 @@ The following properties can be configured:
Default value: config.units + + roundTemp + Round temperature values to nearest integer.
+
Possible values: true (round to integer) or false (display exact value with decimal point) +
Default value: false + + maxNumberOfDays How many days of forecast to return. Specified by config.js
diff --git a/modules/default/weatherforecast/weatherforecast.js b/modules/default/weatherforecast/weatherforecast.js index 51c3f56e..5078c9b6 100644 --- a/modules/default/weatherforecast/weatherforecast.js +++ b/modules/default/weatherforecast/weatherforecast.js @@ -34,6 +34,8 @@ Module.register("weatherforecast",{ appendLocationNameToHeader: true, calendarClass: "calendar", + roundTemp: false, + iconTable: { "01d": "wi-day-sunny", "02d": "wi-day-cloudy", @@ -342,13 +344,15 @@ Module.register("weatherforecast",{ }, /* function(temperature) - * Rounds a temperature to 1 decimal. + * Rounds a temperature to 1 decimal or integer (depending on config.roundTemp). * * argument temperature number - Temperature. * * return number - Rounded Temperature. */ roundValue: function(temperature) { - return parseFloat(temperature).toFixed(1); + var decimals = this.config.roundTemp ? 0 : 1; + return parseFloat(temperature).toFixed(decimals); } }); +