Fix for envcanada Provider to use updated Env Canada URL (#3919)

The envcanada provider in the default Weather module was fixed in MM
v2.33.0 to use a new URL hierarchy that Environment Canada implemented
to access weather data for Canadian locations. Subsequent to this
provider update, Environment Canada has implemented one further update
to their URL hierarchy to make it easier to access 'current day' weather
data. Tis change was raised in Issue #3912 as a Bug, which is addressed
in this Provider update. There are no Magic Mirror UI changes from this
update.

The fix is to add one additional element to the URL used to access
Environment Canada XML-based weather data.

This PR is also taking the opportunity to make one further small fix to
how windspeed is handled in this Provider. Most of the time, Env Canada
provides an expected numeric value. There are instances, however, where
the value provided is 'calm', which the Weather module does not expect.
The Provider code has been changed to detect a 'calm' windspeed and
convert it to '0' for the purposes of the Weather module. Note that in
the world of weather/climate analysis, a windspeed of 'calm' is used as
a synonym for a windspeed of 0.

Note that a ChangeLog entry is included in this PR.
This commit is contained in:
Kevin G.
2025-10-19 13:06:44 -04:00
committed by GitHub
parent 96d3e8776d
commit 2a4a056c84
2 changed files with 8 additions and 2 deletions

View File

@@ -24,6 +24,7 @@ planned for 2026-01-01
- feat: add ESlint rule `no-sparse-arrays` for config check to fix #3910 (#3911)
- fixed eslint warnings shown in #3911 and updated npm publish docs (#3913)
- [core] refactor: replace `express-ipfilter` with lightweight custom middleware (#3917) - This fixes security issue [CVE-2023-42282](https://github.com/advisories/GHSA-78xj-cgh5-2h22), which is not very likely to be exploitable in MagicMirror² setups, but still should be fixed.
- fixed the Environment Canada weather URL (#3912) and now converts a windspeed of 'calm' to 0
### Updated

View File

@@ -208,7 +208,7 @@ WeatherProvider.register("envcanada", {
* Fixed value + Prov code specified in Weather module Config.js + current hour as GMT
*/
getUrl () {
let forecastURL = `https://dd.weather.gc.ca/citypage_weather/${this.config.provCode}`;
let forecastURL = `https://dd.weather.gc.ca/today/citypage_weather/${this.config.provCode}`;
const hour = this.getCurrentHourGMT();
forecastURL += `/${hour}/`;
return forecastURL;
@@ -244,7 +244,12 @@ WeatherProvider.register("envcanada", {
currentWeather.temperature = this.cacheCurrentTemp;
}
currentWeather.windSpeed = WeatherUtils.convertWindToMs(ECdoc.querySelector("siteData currentConditions wind speed").textContent);
if (ECdoc.querySelector("siteData currentConditions wind speed").textContent === "calm") {
currentWeather.windSpeed = "0";
} else {
currentWeather.windSpeed = WeatherUtils.convertWindToMs(ECdoc.querySelector("siteData currentConditions wind speed").textContent);
}
currentWeather.windFromDirection = ECdoc.querySelector("siteData currentConditions wind bearing").textContent;
currentWeather.humidity = ECdoc.querySelector("siteData currentConditions relativeHumidity").textContent;