Merge pull request #2185 from Sub028/master

Weather config enhancement
This commit is contained in:
Michael Teeuw 2020-12-08 15:51:41 +01:00 committed by GitHub
commit d43679d59e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 1 deletions

View File

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

View File

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

View File

@ -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";
}