mirror of
https://github.com/MichMich/MagicMirror.git
synced 2025-06-28 09:42:21 -04:00
feat(weather/smhi): calculate apparent temperature
This commit is contained in:
parent
4915ad8fc7
commit
48756e8774
1 changed files with 11 additions and 0 deletions
|
@ -108,6 +108,16 @@ WeatherProvider.register("smhi", {
|
||||||
return `https://opendata-download-metfcst.smhi.se/api/category/pmp3g/version/2/geotype/point/lon/${lon}/lat/${lat}/data.json`;
|
return `https://opendata-download-metfcst.smhi.se/api/category/pmp3g/version/2/geotype/point/lon/${lon}/lat/${lat}/data.json`;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/** Calculates the apparent temperature based on known atmospheric data. */
|
||||||
|
calculateApparentTemperature(weatherData) {
|
||||||
|
const Ta = this.paramValue(weatherData, "t");
|
||||||
|
const rh = this.paramValue(weatherData, "r");
|
||||||
|
const ws = this.paramValue(weatherData, "ws");
|
||||||
|
const p = (rh / 100) * 6.105 * Math.E * ((17.27 * Ta) / (237.7 + Ta))
|
||||||
|
|
||||||
|
return Ta + 0.33 * p - 0.7 * ws - 4
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts the returned data into a WeatherObject with required properties set for both current weather and forecast.
|
* Converts the returned data into a WeatherObject with required properties set for both current weather and forecast.
|
||||||
* The returned units is always in metric system.
|
* The returned units is always in metric system.
|
||||||
|
@ -128,6 +138,7 @@ WeatherProvider.register("smhi", {
|
||||||
currentWeather.windSpeed = this.paramValue(weatherData, "ws");
|
currentWeather.windSpeed = this.paramValue(weatherData, "ws");
|
||||||
currentWeather.windDirection = this.paramValue(weatherData, "wd");
|
currentWeather.windDirection = this.paramValue(weatherData, "wd");
|
||||||
currentWeather.weatherType = this.convertWeatherType(this.paramValue(weatherData, "Wsymb2"), currentWeather.isDayTime());
|
currentWeather.weatherType = this.convertWeatherType(this.paramValue(weatherData, "Wsymb2"), currentWeather.isDayTime());
|
||||||
|
currentWeather.feelsLikeTemp = this.calculateAT(weatherData);
|
||||||
|
|
||||||
// Determine the precipitation amount and category and update the
|
// Determine the precipitation amount and category and update the
|
||||||
// weatherObject with it, the valuetype to use can be configured or uses
|
// weatherObject with it, the valuetype to use can be configured or uses
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue