Skip to content

Commit 2a4a056

Browse files
authored
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.
1 parent 96d3e87 commit 2a4a056

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ planned for 2026-01-01
2424
- feat: add ESlint rule `no-sparse-arrays` for config check to fix #3910 (#3911)
2525
- fixed eslint warnings shown in #3911 and updated npm publish docs (#3913)
2626
- [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.
27+
- fixed the Environment Canada weather URL (#3912) and now converts a windspeed of 'calm' to 0
2728

2829
### Updated
2930

modules/default/weather/providers/envcanada.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ WeatherProvider.register("envcanada", {
208208
* Fixed value + Prov code specified in Weather module Config.js + current hour as GMT
209209
*/
210210
getUrl () {
211-
let forecastURL = `https://dd.weather.gc.ca/citypage_weather/${this.config.provCode}`;
211+
let forecastURL = `https://dd.weather.gc.ca/today/citypage_weather/${this.config.provCode}`;
212212
const hour = this.getCurrentHourGMT();
213213
forecastURL += `/${hour}/`;
214214
return forecastURL;
@@ -244,7 +244,12 @@ WeatherProvider.register("envcanada", {
244244
currentWeather.temperature = this.cacheCurrentTemp;
245245
}
246246

247-
currentWeather.windSpeed = WeatherUtils.convertWindToMs(ECdoc.querySelector("siteData currentConditions wind speed").textContent);
247+
if (ECdoc.querySelector("siteData currentConditions wind speed").textContent === "calm") {
248+
currentWeather.windSpeed = "0";
249+
} else {
250+
currentWeather.windSpeed = WeatherUtils.convertWindToMs(ECdoc.querySelector("siteData currentConditions wind speed").textContent);
251+
}
252+
248253
currentWeather.windFromDirection = ECdoc.querySelector("siteData currentConditions wind bearing").textContent;
249254

250255
currentWeather.humidity = ECdoc.querySelector("siteData currentConditions relativeHumidity").textContent;

0 commit comments

Comments
 (0)