mirror of
https://github.com/MichMich/MagicMirror.git
synced 2025-08-25 07:06:49 +00:00
Tidy up precipitation (#3023)
Fixes #2953 This is an attempt to fix the issue with precipitation amount and percentage mixup. I have created a separate `precipitationPercentage`-variable where the probability of rain can be stored. The config options now has the old `showPrecipitationAmount` in addition to a new setting: `showPrecipitationProbability` (shows the likelihood of rain). <details> <summary>Examples</summary> ### Yr I tested the Yr weather provider for a Norwegian city Bergen that has a lot of rain. I have removed properties that are irrelevant for this demo from the config-samples below. Config: ```js { module: "weather", config: { weatherProvider: "yr", type: "current", showPrecipitationAmount: true, showPrecipitationProbability: true } }, { module: "weather", config: { weatherProvider: "yr", type: "hourly", showPrecipitationAmount: true, showPrecipitationProbability: true } }, { module: "weather", config: { weatherProvider: "yr", type: "daily", showPrecipitationAmount: true, showPrecipitationProbability: true } } ``` Result:<br/> <img width="444" alt="screenshot" src="https://user-images.githubusercontent.com/34011212/216775423-4e37345c-f915-47e5-8551-7c544ebd24b1.png"> </details> --------- Co-authored-by: Magnus Marthinsen <magmar@online.no> Co-authored-by: Veeck <github@veeck.de>
This commit is contained in:
@@ -367,7 +367,7 @@ WeatherProvider.register("openmeteo", {
|
||||
* `current_weather` object.
|
||||
*/
|
||||
const h = moment().hour();
|
||||
const currentWeather = new WeatherObject(this.config.units, this.config.tempUnits, this.config.windUnits);
|
||||
const currentWeather = new WeatherObject();
|
||||
|
||||
currentWeather.date = weather.current_weather.time;
|
||||
currentWeather.windSpeed = weather.current_weather.windspeed;
|
||||
@@ -381,7 +381,7 @@ WeatherProvider.register("openmeteo", {
|
||||
currentWeather.humidity = parseFloat(weather.hourly[h].relativehumidity_2m);
|
||||
currentWeather.rain = parseFloat(weather.hourly[h].rain);
|
||||
currentWeather.snow = parseFloat(weather.hourly[h].snowfall * 10);
|
||||
currentWeather.precipitation = parseFloat(weather.hourly[h].precipitation);
|
||||
currentWeather.precipitationAmount = parseFloat(weather.hourly[h].precipitation);
|
||||
|
||||
return currentWeather;
|
||||
},
|
||||
@@ -391,7 +391,7 @@ WeatherProvider.register("openmeteo", {
|
||||
const days = [];
|
||||
|
||||
weathers.daily.forEach((weather, i) => {
|
||||
const currentWeather = new WeatherObject(this.config.units, this.config.tempUnits, this.config.windUnits);
|
||||
const currentWeather = new WeatherObject();
|
||||
|
||||
currentWeather.date = weather.time;
|
||||
currentWeather.windSpeed = weather.windspeed_10m_max;
|
||||
@@ -404,7 +404,7 @@ WeatherProvider.register("openmeteo", {
|
||||
currentWeather.weatherType = this.convertWeatherType(weather.weathercode, currentWeather.isDayTime());
|
||||
currentWeather.rain = parseFloat(weather.rain_sum);
|
||||
currentWeather.snow = parseFloat(weather.snowfall_sum * 10);
|
||||
currentWeather.precipitation = parseFloat(weather.precipitation_sum);
|
||||
currentWeather.precipitationAmount = parseFloat(weather.precipitation_sum);
|
||||
|
||||
days.push(currentWeather);
|
||||
});
|
||||
@@ -422,7 +422,7 @@ WeatherProvider.register("openmeteo", {
|
||||
return;
|
||||
}
|
||||
|
||||
const currentWeather = new WeatherObject(this.config.units, this.config.tempUnits, this.config.windUnits);
|
||||
const currentWeather = new WeatherObject();
|
||||
const h = Math.ceil((i + 1) / 24) - 1;
|
||||
|
||||
currentWeather.date = weather.time;
|
||||
@@ -437,7 +437,7 @@ WeatherProvider.register("openmeteo", {
|
||||
currentWeather.humidity = parseFloat(weather.relativehumidity_2m);
|
||||
currentWeather.rain = parseFloat(weather.rain);
|
||||
currentWeather.snow = parseFloat(weather.snowfall * 10);
|
||||
currentWeather.precipitation = parseFloat(weather.precipitation);
|
||||
currentWeather.precipitationAmount = parseFloat(weather.precipitation);
|
||||
|
||||
hours.push(currentWeather);
|
||||
});
|
||||
|
Reference in New Issue
Block a user