Weather config enhancement

Add new parameter 'useKmh' to display wind speed in km/h instead of m/s.
This commit is contained in:
Aurélien Veillard 2020-11-07 09:54:13 +01:00
parent 3dbe8bfbbf
commit 198525f2ce
3 changed files with 11 additions and 1 deletions

View File

@ -8,9 +8,13 @@
<span> <span>
{% if config.useBeaufort %} {% if config.useBeaufort %}
{{ current.beaufortWindSpeed() | round }} {{ current.beaufortWindSpeed() | round }}
{% else %}
{% if config.useKmh %}
{{ current.kmhWindSpeed() | round }}
{% else %} {% else %}
{{ current.windSpeed | round }} {{ current.windSpeed | round }}
{% endif %} {% endif %}
{% endif %}
{% if config.showWindDirection %} {% if config.showWindDirection %}
<sup> <sup>
{% if config.showWindDirectionAsArrow %} {% if config.showWindDirectionAsArrow %}

View File

@ -18,6 +18,7 @@ Module.register("weather", {
location: false, location: false,
locationID: false, locationID: false,
units: config.units, units: config.units,
useKmh: false,
tempUnits: config.units, tempUnits: config.units,
windUnits: config.units, windUnits: config.units,

View File

@ -77,6 +77,11 @@ class WeatherObject {
return 12; return 12;
} }
kmhWindSpeed() {
const windInKmh = this.windUnits === "imperial" ? this.windSpeed * 1.609344 : (this.windSpeed * 60 * 60) / 1000;
return windInKmh;
}
nextSunAction() { nextSunAction() {
return moment().isBetween(this.sunrise, this.sunset) ? "sunset" : "sunrise"; return moment().isBetween(this.sunrise, this.sunset) ? "sunset" : "sunrise";
} }