Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix frozen Yr weather-module #3706

Merged
merged 4 commits into from
Jan 27, 2025
Merged

Conversation

MagMar94
Copy link
Contributor

Fixes #3296

The problem was that the fetch-methods threw errors when something went wrong instead of calling updateAvailable(). updateAvailable() must be called in order to schedule the next update.

I added some filtering for the hourly forecast that removes hours in the past. If the API call fails we use the cached data, but we should only display hours in the future.

updateAvailable must be called to schedule the next update. If we just return or throw an error the fetch-methods will not be called from weather.js.
If the forecast is fetched from the cache we should remove the entries that no longer provide any value to the user.
This is probably due to a HTTP 429 (Too many requests). If the MagicMirror is throttled we should fall back to the cached data.
@khassel
Copy link
Collaborator

khassel commented Jan 26, 2025

I tried setting the updateInterval in the start-method with this.config.updateInterval = 600000 and this.setConfig({ ...config, updateInterval: 600000 }), but the setInterval still used the original value.

can confirm this, so we live with the error message instead. Or may @rejas has an idea how to change config.updateInterval within a provider?

@khassel khassel requested a review from rejas January 26, 2025 18:53
@khassel
Copy link
Collaborator

khassel commented Jan 26, 2025

after some digging in the code I found in weatherprovider.js this part

WeatherProvider.initialize = function (providerIdentifier, delegate) {
	const pi = providerIdentifier.toLowerCase();

	const provider = new WeatherProvider.providers[pi]();
	const config = Object.assign({}, provider.defaults, delegate.config);

	provider.delegate = delegate;
	provider.setConfig(config);
...

which explains the behavior.

So I tested this.delegate.config.updateInterval = 123456; inside the provider (in setConfig) which works. So if you are willing to change it again for better user experience ...

Some users get HTTP 429 from the API. This indicates too many request. In the terms of service, yr says "don't make more than one poll every 10 mins".

We now increase the updateInterval-value to 600000 if a smaller value is set by the user.
@khassel khassel merged commit d6f2e71 into MagicMirrorOrg:develop Jan 27, 2025
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants