Release 2.24.0 (#3141)

Signed-off-by: naveen <172697+naveensrinivasan@users.noreply.github.com>
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: Karsten Hassel <hassel@gmx.de>
Co-authored-by: Malte Hallström <46646495+SkySails@users.noreply.github.com>
Co-authored-by: Veeck <github@veeck.de>
Co-authored-by: veeck <michael@veeck.de>
Co-authored-by: dWoolridge <dwoolridge@charter.net>
Co-authored-by: Johan <jojjepersson@yahoo.se>
Co-authored-by: Dario Mratovich <dario_mratovich@hotmail.com>
Co-authored-by: Dario Mratovich <dario.mratovich@outlook.com>
Co-authored-by: Magnus <34011212+MagMar94@users.noreply.github.com>
Co-authored-by: Naveen <172697+naveensrinivasan@users.noreply.github.com>
Co-authored-by: buxxi <buxxi@omfilm.net>
Co-authored-by: Thomas Hirschberger <47733292+Tom-Hirschberger@users.noreply.github.com>
Co-authored-by: Kristjan ESPERANTO <35647502+KristjanESPERANTO@users.noreply.github.com>
Co-authored-by: Andrés Vanegas Jiménez <142350+angeldeejay@users.noreply.github.com>
Co-authored-by: Dave Child <dave@addedbytes.com>
Co-authored-by: grenagit <46225780+grenagit@users.noreply.github.com>
Co-authored-by: Grena <grena@grenabox.fr>
Co-authored-by: Magnus Marthinsen <magmar@online.no>
Co-authored-by: Patrick <psieg@users.noreply.github.com>
Co-authored-by: Piotr Rajnisz <56397164+rajniszp@users.noreply.github.com>
Co-authored-by: Suthep Yonphimai <tomzt@users.noreply.github.com>
Co-authored-by: CarJem Generations (Carter Wallace) <cwallacecs@gmail.com>
Co-authored-by: Nicholas Fogal <nfogal.misc@gmail.com>
Co-authored-by: JakeBinney <126349119+JakeBinney@users.noreply.github.com>
Co-authored-by: OWL4C <124401812+OWL4C@users.noreply.github.com>
Co-authored-by: Oscar Björkman <17575446+oscarb@users.noreply.github.com>
Co-authored-by: Ismar Slomic <ismar@slomic.no>
Co-authored-by: Jørgen Veum-Wahlberg <jorgen.wahlberg@amedia.no>
Co-authored-by: Eddie Hung <6740044+eddiehung@users.noreply.github.com>
Co-authored-by: Bugsounet - Cédric <github@bugsounet.fr>
Co-authored-by: bugsounet <bugsounet@bugsounet.fr>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
This commit is contained in:
Michael Teeuw
2023-07-01 21:17:31 +02:00
committed by GitHub
parent abe5c08a52
commit e87f50e64a
74 changed files with 2570 additions and 2437 deletions

View File

@@ -28,6 +28,12 @@
{% endif %}
</span>
{% endif %}
{% if config.showUVIndex %}
<td class="align-right bright uv-index">
<div class="wi dimmed wi-hot"></div>
{{ current.uv_index }}
</td>
{% endif %}
</div>
{% endif %}
<div class="large light">
@@ -61,12 +67,12 @@
{{ "FEELS" | translate({DEGREE: current.feelsLike() | roundValue | unit("temperature") | decimalSymbol }) }}
</span><br/>
{% endif %}
{% if config.showPrecipitationAmount and current.precipitationAmount %}
{% if config.showPrecipitationAmount and current.precipitationAmount %}
<span class="dimmed">
<span class="precipitationLeadText">{{ "PRECIP_AMOUNT" | translate }}</span> {{ current.precipitationAmount | unit("precip", current.precipitationUnits) }}
</span><br/>
{% endif %}
{% if config.showPrecipitationProbability and current.precipitationProbability %}
{% if config.showPrecipitationProbability and current.precipitationProbability %}
<span class="dimmed">
<span class="precipitationLeadText">{{ "PRECIP_POP" | translate }}</span> {{ current.precipitationProbability }}%
</span>

View File

@@ -32,6 +32,12 @@
{{ f.precipitationProbability | unit("precip", "%") }}
</td>
{% endif %}
{% if config.showUVIndex %}
<td class="align-right dimmed uv-index">
{{ f.uv_index }}
<span class="wi dimmed weathericon wi-hot"></span>
</td>
{% endif %}
</tr>
{% set currentStep = currentStep + 1 %}
{% endfor %}

View File

@@ -10,6 +10,14 @@
<td class="align-right bright">
{{ hour.temperature | roundValue | unit("temperature") }}
</td>
{% if config.showUVIndex %}
<td class="align-right bright uv-index">
{% if hour.uv_index!=0 %}
{{ hour.uv_index }}
<span class="wi weathericon wi-hot"></span>
{% endif %}
</td>
{% endif %}
{% if config.showPrecipitationAmount %}
<td class="align-right bright precipitation-amount">
{{ hour.precipitationAmount | unit("precip", hour.precipitationUnits) }}

View File

@@ -384,7 +384,7 @@ WeatherProvider.register("envcanada", {
const foreTime = moment(hourGroup[stepHour].getAttribute("dateTimeUTC"), "YYYYMMDDhhmmss");
const currTime = foreTime.add(hourOffset, "hours");
weather.date = moment.unix(currTime);
weather.date = moment(currTime);
// Capture the temperature
@@ -505,9 +505,9 @@ WeatherProvider.register("envcanada", {
}
// Check Today element for POP
if (foreGroup[today].querySelector("abbreviatedForecast pop").textContent > 0) {
weather.precipitationProbability = foreGroup[today].querySelector("abbreviatedForecast pop").textContent;
const precipPOP = foreGroup[today].querySelector("abbreviatedForecast pop").textContent * 1.0;
if (precipPOP > 0) {
weather.precipitationProbability = precipPOP;
}
},

View File

@@ -76,6 +76,10 @@ WeatherProvider.register("openmeteo", {
"et0_fao_evapotranspiration",
// Total precipitation (rain, showers, snow) sum of the preceding hour
"precipitation",
// Precipitation Probability
"precipitation_probability",
// UV index
"uv_index",
// Snowfall amount of the preceding hour in centimeters. For the water equivalent in millimeter, divide by 7. E.g. 7 cm snow = 10 mm precipitation water equivalent
"snowfall",
// Rain from large scale weather systems of the preceding hour in millimeter
@@ -130,6 +134,8 @@ WeatherProvider.register("openmeteo", {
"winddirection_10m_dominant",
// The sum of solar radiation on a given day in Megajoules
"shortwave_radiation_sum",
//UV Index
"uv_index_max",
// Daily sum of ET₀ Reference Evapotranspiration of a well watered grass field
"et0_fao_evapotranspiration"
],
@@ -194,7 +200,6 @@ WeatherProvider.register("openmeteo", {
/**
* Overrides method for setting config to check if endpoint is correct for hourly
*
* @param {object} config The configuration object
*/
setConfig(config) {
@@ -382,6 +387,8 @@ WeatherProvider.register("openmeteo", {
currentWeather.rain = parseFloat(weather.hourly[h].rain);
currentWeather.snow = parseFloat(weather.hourly[h].snowfall * 10);
currentWeather.precipitationAmount = parseFloat(weather.hourly[h].precipitation);
currentWeather.precipitationProbability = parseFloat(weather.hourly[h].precipitation_probability);
currentWeather.uv_index = parseFloat(weather.hourly[h].uv_index);
return currentWeather;
},
@@ -405,6 +412,8 @@ WeatherProvider.register("openmeteo", {
currentWeather.rain = parseFloat(weather.rain_sum);
currentWeather.snow = parseFloat(weather.snowfall_sum * 10);
currentWeather.precipitationAmount = parseFloat(weather.precipitation_sum);
currentWeather.precipitationProbability = parseFloat(weather.precipitation_probability);
currentWeather.uv_index = parseFloat(weather.uv_index_max);
days.push(currentWeather);
});
@@ -438,6 +447,8 @@ WeatherProvider.register("openmeteo", {
currentWeather.rain = parseFloat(weather.rain);
currentWeather.snow = parseFloat(weather.snowfall * 10);
currentWeather.precipitationAmount = parseFloat(weather.precipitation);
currentWeather.precipitationProbability = parseFloat(weather.precipitation_probability);
currentWeather.uv_index = parseFloat(weather.uv_index);
hours.push(currentWeather);
});

View File

@@ -90,7 +90,6 @@ WeatherProvider.register("openweathermap", {
/**
* Overrides method for setting config to check if endpoint is correct for hourly
*
* @param {object} config The configuration object
*/
setConfig(config) {
@@ -435,6 +434,7 @@ WeatherProvider.register("openweathermap", {
} else if (this.firstEvent && this.firstEvent.location) {
params += `q=${this.firstEvent.location}`;
} else {
// TODO hide doesnt exist!
this.hide(this.config.animationSpeed, { lockString: this.identifier });
return;
}

View File

@@ -69,7 +69,6 @@ WeatherProvider.register("smhi", {
/**
* Overrides method for setting config with checks for the precipitationValue being unset or invalid
*
* @param {object} config The configuration object
*/
setConfig(config) {
@@ -82,7 +81,6 @@ WeatherProvider.register("smhi", {
/**
* Of all the times returned find out which one is closest to the current time, should be the first if the data isn't old.
*
* @param {object[]} times Array of time objects
* @returns {object} The weatherdata closest to the current time
*/
@@ -100,7 +98,6 @@ WeatherProvider.register("smhi", {
/**
* Get the forecast url for the configured coordinates
*
* @returns {string} the url for the specified coordinates
*/
getURL() {
@@ -115,7 +112,6 @@ WeatherProvider.register("smhi", {
/**
* Calculates the apparent temperature based on known atmospheric data.
*
* @param {object} weatherData Weatherdata to use for the calculation
* @returns {number} The apparent temperature
*/
@@ -132,7 +128,6 @@ WeatherProvider.register("smhi", {
* 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.
* Requires coordinates to determine if its daytime or nighttime to know which icon to use and also to set sunrise and sunset.
*
* @param {object} weatherData Weatherdata to convert
* @param {object} coordinates Coordinates of the locations of the weather
* @returns {WeatherObject} The converted weatherdata at the specified location
@@ -178,7 +173,6 @@ WeatherProvider.register("smhi", {
/**
* Takes all the data points and converts it to one WeatherObject per day.
*
* @param {object[]} allWeatherData Array of weatherdata
* @param {object} coordinates Coordinates of the locations of the weather
* @param {string} groupBy The interval to use for grouping the data (day, hour)
@@ -230,7 +224,6 @@ WeatherProvider.register("smhi", {
/**
* Resolve coordinates from the response data (probably preferably to use
* this if it's not matching the config values exactly)
*
* @param {object} data Response data from the weather service
* @returns {{lon, lat}} the lat/long coordinates of the data
*/
@@ -241,7 +234,6 @@ WeatherProvider.register("smhi", {
/**
* The distance between the data points is increasing in the data the more distant the prediction is.
* Find these gaps and fill them with the previous hours data to make the data returned a complete set.
*
* @param {object[]} data Response data from the weather service
* @returns {object[]} Given data with filled gaps
*/
@@ -263,7 +255,6 @@ WeatherProvider.register("smhi", {
/**
* Helper method to get a property from the returned data set.
*
* @param {object} currentWeatherData Weatherdata to get from
* @param {string} name The name of the property
* @returns {*} The value of the property in the weatherdata
@@ -276,7 +267,6 @@ WeatherProvider.register("smhi", {
* Map the icon value from SMHI to an icon that MagicMirror² understands.
* Uses different icons depending on if its daytime or nighttime.
* SMHI's description of what the numeric value means is the comment after the case.
*
* @param {number} input The SMHI icon value
* @param {boolean} isDayTime True if the icon should be for daytime, false for nighttime
* @returns {string} The icon name for the MagicMirror

View File

@@ -189,7 +189,6 @@ WeatherProvider.register("ukmetoffice", {
/**
* Generates an url with api parameters based on the config.
*
* @param {string} forecastType daily or 3hourly forecast
* @returns {string} url
*/

View File

@@ -65,7 +65,6 @@ WeatherProvider.register("weatherbit", {
/**
* Overrides method for setting config to check if endpoint is correct for hourly
*
* @param {object} config The configuration object
*/
setConfig(config) {

View File

@@ -110,13 +110,15 @@ WeatherProvider.register("yr", {
this.getWeatherDataFromYr(weatherData?.downloadedAt)
.then((weatherData) => {
Log.debug("Got weather data from yr.");
let data;
if (weatherData) {
this.cacheWeatherData(weatherData);
data = weatherData;
} else {
//Undefined if unchanged
weatherData = this.getWeatherDataFromCache();
data = this.getWeatherDataFromCache();
}
resolve(weatherData);
resolve(data);
})
.catch((err) => {
Log.error(err);
@@ -266,14 +268,14 @@ WeatherProvider.register("yr", {
this.getStellarDataFromYr(today, 2)
.then((stellarData) => {
if (stellarData) {
stellarData = {
const data = {
today: stellarData
};
stellarData.tomorrow = Object.assign({}, stellarData.today);
stellarData.today.date = today;
stellarData.tomorrow.date = tomorrow;
this.cacheStellarData(stellarData);
resolve(stellarData);
data.tomorrow = Object.assign({}, data.today);
data.today.date = today;
data.tomorrow.date = tomorrow;
this.cacheStellarData(data);
resolve(data);
} else {
Log.error(`Something went wrong when fetching stellar data. Responses: ${stellarData}`);
reject(stellarData);

View File

@@ -30,7 +30,8 @@
}
.weather .precipitation-amount,
.weather .precipitation-prob {
.weather .precipitation-prob,
.weather .uv-index {
padding-left: 20px;
padding-right: 0;
}

View File

@@ -1,4 +1,4 @@
/* global WeatherProvider, WeatherUtils */
/* global WeatherProvider, WeatherUtils, formatTime */
/* MagicMirror²
* Module: Weather
@@ -27,6 +27,7 @@ Module.register("weather", {
showPeriodUpper: false,
showPrecipitationAmount: false,
showPrecipitationProbability: false,
showUVIndex: false,
showSun: true,
showWindDirection: true,
showWindDirectionAsArrow: false,
@@ -211,50 +212,37 @@ Module.register("weather", {
this.nunjucksEnvironment().addFilter(
"formatTime",
function (date) {
date = moment(date);
if (this.config.timeFormat !== 24) {
if (this.config.showPeriod) {
if (this.config.showPeriodUpper) {
return date.format("h:mm A");
} else {
return date.format("h:mm a");
}
} else {
return date.format("h:mm");
}
}
return date.format("HH:mm");
return formatTime(this.config, date);
}.bind(this)
);
this.nunjucksEnvironment().addFilter(
"unit",
function (value, type, valueUnit) {
let formattedValue;
if (type === "temperature") {
value = `${this.roundValue(WeatherUtils.convertTemp(value, this.config.tempUnits))}°`;
formattedValue = `${this.roundValue(WeatherUtils.convertTemp(value, this.config.tempUnits))}°`;
if (this.config.degreeLabel) {
if (this.config.tempUnits === "metric") {
value += "C";
formattedValue += "C";
} else if (this.config.tempUnits === "imperial") {
value += "F";
formattedValue += "F";
} else {
value += "K";
formattedValue += "K";
}
}
} else if (type === "precip") {
if (value === null || isNaN(value) || value === 0 || value.toFixed(2) === "0.00") {
value = "";
formattedValue = "";
} else {
value = WeatherUtils.convertPrecipitationUnit(value, valueUnit, this.config.units);
formattedValue = WeatherUtils.convertPrecipitationUnit(value, valueUnit, this.config.units);
}
} else if (type === "humidity") {
value += "%";
formattedValue = `${value}%`;
} else if (type === "wind") {
value = WeatherUtils.convertWind(value, this.config.windUnits);
formattedValue = WeatherUtils.convertWind(value, this.config.windUnits);
}
return value;
return formattedValue;
}.bind(this)
);

View File

@@ -75,7 +75,6 @@ class WeatherObject {
/**
* Determines if the sun sets or rises next. Uses the current time and not
* the date from the weather-forecast.
*
* @param {Moment} date an optional date where you want to get the next
* action for. Useful only in tests, defaults to the current time.
* @returns {string} "sunset" or "sunrise"
@@ -93,7 +92,6 @@ class WeatherObject {
/**
* Checks if the weatherObject is at dayTime.
*
* @returns {boolean} true if it is at dayTime
*/
isDayTime() {
@@ -105,7 +103,6 @@ class WeatherObject {
* Update the sunrise / sunset time depending on the location. This can be
* used if your provider doesn't provide that data by itself. Then SunCalc
* is used here to calculate them according to the location.
*
* @param {number} lat latitude
* @param {number} lon longitude
*/
@@ -121,7 +118,6 @@ class WeatherObject {
*
* Before being handed to other modules, mutable values must be cloned safely.
* Especially 'moment' object is not immutable, so original 'date', 'sunrise', 'sunset' could be corrupted or changed by other modules.
*
* @returns {object} plained object clone of original weatherObject
*/
simpleClone() {

View File

@@ -113,7 +113,6 @@ const WeatherProvider = Class.extend({
/**
* A convenience function to make requests.
*
* @param {string} url the url to fetch from
* @param {string} type what contenttype to expect in the response, can be "json" or "xml"
* @param {Array.<{name: string, value:string}>} requestHeaders the HTTP headers to send
@@ -138,7 +137,6 @@ WeatherProvider.providers = [];
/**
* Static method to register a new weather provider.
*
* @param {string} providerIdentifier The name of the weather provider
* @param {object} providerDetails The details of the weather provider
*/
@@ -148,23 +146,22 @@ WeatherProvider.register = function (providerIdentifier, providerDetails) {
/**
* Static method to initialize a new weather provider.
*
* @param {string} providerIdentifier The name of the weather provider
* @param {object} delegate The weather module
* @returns {object} The new weather provider
*/
WeatherProvider.initialize = function (providerIdentifier, delegate) {
providerIdentifier = providerIdentifier.toLowerCase();
const pi = providerIdentifier.toLowerCase();
const provider = new WeatherProvider.providers[providerIdentifier]();
const provider = new WeatherProvider.providers[pi]();
const config = Object.assign({}, provider.defaults, delegate.config);
provider.delegate = delegate;
provider.setConfig(config);
provider.providerIdentifier = providerIdentifier;
provider.providerIdentifier = pi;
if (!provider.providerName) {
provider.providerName = providerIdentifier;
provider.providerName = pi;
}
return provider;

View File

@@ -7,7 +7,6 @@
const WeatherUtils = {
/**
* Convert wind (from m/s) to beaufort scale
*
* @param {number} speedInMS the windspeed you want to convert
* @returns {number} the speed in beaufort
*/
@@ -25,30 +24,30 @@ const WeatherUtils = {
/**
* Convert a value in a given unit to a string with a converted
* value and a postfix matching the output unit system.
*
* @param {number} value - The value to convert.
* @param {string} valueUnit - The unit the values has. Default is mm.
* @param {string} outputUnit - The unit system (imperial/metric) the return value should have.
* @returns {string} - A string with tha value and a unit postfix.
*/
convertPrecipitationUnit(value, valueUnit, outputUnit) {
if (outputUnit === "imperial") {
if (valueUnit && valueUnit.toLowerCase() === "cm") value = value * 0.3937007874;
else value = value * 0.03937007874;
valueUnit = "in";
} else {
valueUnit = valueUnit ? valueUnit : "mm";
}
if (valueUnit === "%") return `${value.toFixed(0)} ${valueUnit}`;
return `${value.toFixed(2)} ${valueUnit}`;
let convertedValue = value;
let conversionUnit = valueUnit;
if (outputUnit === "imperial") {
if (valueUnit && valueUnit.toLowerCase() === "cm") convertedValue = convertedValue * 0.3937007874;
else convertedValue = convertedValue * 0.03937007874;
conversionUnit = "in";
} else {
conversionUnit = valueUnit ? valueUnit : "mm";
}
return `${convertedValue.toFixed(2)} ${conversionUnit}`;
},
/**
* Convert temp (from degrees C) into imperial or metric unit depending on
* your config
*
* @param {number} tempInC the temperature in celsius you want to convert
* @param {string} unit can be 'imperial' or 'metric'
* @returns {number} the converted temperature
@@ -59,7 +58,6 @@ const WeatherUtils = {
/**
* Convert wind speed into another unit.
*
* @param {number} windInMS the windspeed in meter/sec you want to convert
* @param {string} unit can be 'beaufort', 'kmh', 'knots, 'imperial' (mph)
* or 'metric' (mps)