Add new parameter "useKmh" to weather module

Add new parameter "useKmh" to weather module for displaying wind speed as km/h instead of m/s when windUnits is set to metric.
This commit is contained in:
Aurélien Veillard
2020-11-08 14:01:02 +01:00
parent 0d6f736c2c
commit 1460f002ab
8 changed files with 40 additions and 29 deletions

View File

@@ -108,7 +108,7 @@ WeatherProvider.register("ukmetofficedatahub", {
// Create a WeatherObject using current weather data (data for the current hour)
generateWeatherObjectFromCurrentWeather(currentWeatherData) {
const currentWeather = new WeatherObject(this.config.units, this.config.tempUnits, this.config.windUnits);
const currentWeather = new WeatherObject(this.config.units, this.config.tempUnits, this.config.windUnits, this.config.useKmh);
// Extract the actual forecasts
let forecastDataHours = currentWeatherData.features[0].properties.timeSeries;
@@ -189,7 +189,7 @@ WeatherProvider.register("ukmetofficedatahub", {
// Go through each day in the forecasts
for (day in forecastDataDays) {
const forecastWeather = new WeatherObject(this.config.units, this.config.tempUnits, this.config.windUnits);
const forecastWeather = new WeatherObject(this.config.units, this.config.tempUnits, this.config.windUnits, this.config.useKmh);
// Get date of forecast
let forecastDate = moment.utc(forecastDataDays[day].time);
@@ -254,7 +254,7 @@ WeatherProvider.register("ukmetofficedatahub", {
return windInMpS;
}
if (this.config.windUnits == "kph" || this.config.windUnits == "metric") {
if (this.config.windUnits == "kph" || this.config.windUnits == "metric" || this.config.useKmh ) {
return windInMpS * 3.6;
}