From 198525f2ce47be182968fd35392af46f81c1122e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Veillard?= Date: Sat, 7 Nov 2020 09:54:13 +0100 Subject: [PATCH 1/2] Weather config enhancement Add new parameter 'useKmh' to display wind speed in km/h instead of m/s. --- modules/default/weather/current.njk | 6 +++++- modules/default/weather/weather.js | 1 + modules/default/weather/weatherobject.js | 5 +++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/modules/default/weather/current.njk b/modules/default/weather/current.njk index c838c1e9..240dcdc5 100755 --- a/modules/default/weather/current.njk +++ b/modules/default/weather/current.njk @@ -9,7 +9,11 @@ {% if config.useBeaufort %} {{ current.beaufortWindSpeed() | round }} {% else %} - {{ current.windSpeed | round }} + {% if config.useKmh %} + {{ current.kmhWindSpeed() | round }} + {% else %} + {{ current.windSpeed | round }} + {% endif %} {% endif %} {% if config.showWindDirection %} diff --git a/modules/default/weather/weather.js b/modules/default/weather/weather.js index b5a68a52..c195e7af 100644 --- a/modules/default/weather/weather.js +++ b/modules/default/weather/weather.js @@ -18,6 +18,7 @@ Module.register("weather", { location: false, locationID: false, units: config.units, + useKmh: false, tempUnits: config.units, windUnits: config.units, diff --git a/modules/default/weather/weatherobject.js b/modules/default/weather/weatherobject.js index 0ee42123..602dcd4d 100755 --- a/modules/default/weather/weatherobject.js +++ b/modules/default/weather/weatherobject.js @@ -77,6 +77,11 @@ class WeatherObject { return 12; } + kmhWindSpeed() { + const windInKmh = this.windUnits === "imperial" ? this.windSpeed * 1.609344 : (this.windSpeed * 60 * 60) / 1000; + return windInKmh; + } + nextSunAction() { return moment().isBetween(this.sunrise, this.sunset) ? "sunset" : "sunrise"; } From 43b33cb6de8673406e2a3df6e0c9fc2a7bc4c806 Mon Sep 17 00:00:00 2001 From: Michael Teeuw Date: Tue, 8 Dec 2020 15:42:01 +0100 Subject: [PATCH 2/2] Fix prettier issue. --- modules/default/weather/weatherobject.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/default/weather/weatherobject.js b/modules/default/weather/weatherobject.js index 602dcd4d..3b145b3d 100755 --- a/modules/default/weather/weatherobject.js +++ b/modules/default/weather/weatherobject.js @@ -81,7 +81,7 @@ class WeatherObject { const windInKmh = this.windUnits === "imperial" ? this.windSpeed * 1.609344 : (this.windSpeed * 60 * 60) / 1000; return windInKmh; } - + nextSunAction() { return moment().isBetween(this.sunrise, this.sunset) ? "sunset" : "sunrise"; }