MagicMirror icon indicating copy to clipboard operation
MagicMirror copied to clipboard

Weather module (yr) stops after a while

Open Jessendelft opened this issue 2 years ago • 9 comments

Running the latest MM v2.25.00 with the YR weather fix from https://github.com/MichMich/MagicMirror/issues/3227 I have 2 weather modules, 1 which shows the current weather and 1 that shows the forecast with the following config:

// Weather now { module: "weather", position: "top_right", config: { weatherProvider: "yr", type: "current", initialLoadDelay: 1000, updateInterval: 60000, appendLocationNameToHeader: false, onlyTemp: false, showWindDirection: false, showSun: false, lat: xx.xxxx, lon: xx.xxxx, altitude: 111 } }, // Daily forecast { module: "weather", position: "top_right", config: { weatherProvider: "yr", type: "daily", initialLoadDelay: 3000, updateInterval: 120630, appendLocationNameToHeader: false, maxNumberOfDays: 7, fade: true, fadepoint: 0.25, lat: xx.xxxx, lon: xx.xxxx, altitude: 111 }, },

After the module starts it stalls after a while, unsure how long after but within the same day. I looked at the dev_tools, and this is the error log:

image

For some reason it gets an error response from YR, which causes the module to stop updating.

Jessendelft avatar Dec 20 '23 13:12 Jessendelft

For some reason it gets an error response from YR, which causes the module to stop updating.

as you already suggests "error response from YR" this sounds like problems on their side or they may restrict access if there are to many requests. You can try with an increased update interval.

@rejas is it possible to improve the code so that the weather module starts working again after such errors?

khassel avatar Dec 20 '23 17:12 khassel

other weather providers and calendar module have the same problem. limited error recovery

sdetweil avatar Dec 20 '23 18:12 sdetweil

@rejas is it possible to improve the code so that the weather module starts working again after such errors?

probably :-) but since I am still recovering from surgery I dont think I can cook something up until the next release.

rejas avatar Dec 21 '23 09:12 rejas

as you already suggests "error response from YR" this sounds like problems on their side or they may restrict access if there are to many requests. You can try with an increased update interval.

Yes, I agree it's from their side. Their API says they reply with a 429 error message if they feel like you're sending too often. I already tried limiting my api calls by lowering the forecast api calls (updateInterval: 120630), but it might still be too much. Still, it would be nice if the module is a bit more robust and doesn't crash immediately when it receives a reply that it doesn't expect.

Jessendelft avatar Dec 21 '23 14:12 Jessendelft

@Jessendelft your delay is only 120 seconds

the delay is milliseconds

5 or 10 minutes might be better unlikely the forecast will change significantly

10 * 60 * 1000

sdetweil avatar Dec 21 '23 14:12 sdetweil

Well I'll be damned... That was supposed to be 10 and ~20 minutes. Forgot a 0, and that should hopefully fix my issue of too many requests. I'll let you know.

Jessendelft avatar Dec 21 '23 14:12 Jessendelft

other weather providers and calendar module have the same problem. limited error recovery

no, tested this, all other providers and calendar will recover with next update interval if there were fetch problems.

The yr provider is special, it caches data in local storage in the browser. I deactivated my internet connection and even after browser restart (cached) yr data is displayed.

Will not look deeper into this, its a nightmare to debug.

khassel avatar Dec 22 '23 22:12 khassel

5 or 10 minutes might be better unlikely the forecast will change significantly

Just to confirm, the error still pops up even with my intended delays of 10 and ~20 minutes for my two weather modules. So it's still an issue, and I'd appreciate a fix that recovers from an empty response.

Jessendelft avatar Dec 23 '23 10:12 Jessendelft

10 min cycle gives 144 API calls per day, assuming no suspend/resume

yr is particularly sensitive

Screenshot_20231223_080809_Chrome

Screenshot_20231223_081013_Chrome

sdetweil avatar Dec 23 '23 14:12 sdetweil