mirror of
https://github.com/MichMich/MagicMirror.git
synced 2025-06-29 04:29:41 +00:00
Fixed precipitation unit conversion logic
Found an error that precipitation amount was not being calculated correctly when config.js is asking for Imperial units. This has been fixed.
This commit is contained in:
parent
af52b91799
commit
0ecb66c99e
@ -538,9 +538,20 @@ WeatherProvider.register("envcanada", {
|
||||
|
||||
setPrecipitation(weather, foreGroup, today) {
|
||||
if (foreGroup[today].querySelector("precipitation accumulation")) {
|
||||
weather.precipitationUnits = foreGroup[today].querySelector("precipitation accumulation amount").getAttribute("units");
|
||||
|
||||
weather.precipitation = foreGroup[today].querySelector("precipitation accumulation amount").textContent * 1.0;
|
||||
|
||||
weather.precipitationUnits = " " + foreGroup[today].querySelector("precipitation accumulation amount").getAttribute("units");
|
||||
|
||||
if (this.config.units === "imperial") {
|
||||
if (weather.precipitationUnits === " cm") {
|
||||
weather.precipitation = (weather.precipitation * 0.394).toFixed(2);
|
||||
weather.precipitationUnits = " in";
|
||||
}
|
||||
if (weather.precipitationUnits === " mm") {
|
||||
weather.precipitation = (weather.precipitation * 0.0394).toFixed(2);
|
||||
weather.precipitationUnits = " in";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Check Today element for POP
|
||||
@ -576,32 +587,6 @@ WeatherProvider.register("envcanada", {
|
||||
return kilo;
|
||||
}
|
||||
},
|
||||
//
|
||||
// Convert cm or mm to inches
|
||||
//
|
||||
convertPrecipAmt(amt, units) {
|
||||
if (this.config.units === "imperial") {
|
||||
if (units === "cm") {
|
||||
return amt * 0.394;
|
||||
}
|
||||
if (units === "mm") {
|
||||
return amt * 0.0394;
|
||||
}
|
||||
} else {
|
||||
return amt;
|
||||
}
|
||||
},
|
||||
|
||||
//
|
||||
// Convert ensure precip units accurately reflect configured units
|
||||
//
|
||||
convertPrecipUnits(units) {
|
||||
if (this.config.units === "imperial") {
|
||||
return null;
|
||||
} else {
|
||||
return " " + units;
|
||||
}
|
||||
},
|
||||
|
||||
//
|
||||
// Convert the icons to a more usable name.
|
||||
|
Loading…
x
Reference in New Issue
Block a user