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

Change default for weatherEndpoint according to API 3.0 #3583

Merged
merged 8 commits into from
Oct 11, 2024

Conversation

HeikoGr
Copy link
Contributor

@HeikoGr HeikoGr commented Oct 9, 2024

since API 3.0 is default, weatherEndpoint should be set to "/onecall"
Fixes #3574

ATTENTION: since lat / lon defaults to 0 / 0, the weather plugins works after this patch, but shows the weather from https://de.wikipedia.org/wiki/Null_Island if lat / lon is not manually set.

@sdetweil
Copy link
Collaborator

sdetweil commented Oct 9, 2024

as weather is all in browser we could log a message there about default lat/lon

@khassel
Copy link
Collaborator

khassel commented Oct 9, 2024

@HeikoGr the tests are failing because the / before onecall, must be weatherEndpoint: "onecall",

I fixed the merge conflicts in changelog so you should fetch your master locally before working on this ... (can do that too if you want)

@sdetweil
Copy link
Collaborator

sdetweil commented Oct 9, 2024

funny, on the module side its "/onecall"

@khassel
Copy link
Collaborator

khassel commented Oct 9, 2024

funny, on the module side its "/onecall"

upsi, I tested this without and test works

as weather is all in browser we could log a message there about default lat/lon

we should think about more changes, e.g.

  • removing openweathermap as default provider (leave empty or choose another)
  • update code so weatherEndpoint works with and without leading slash
  • ...

remove leading slash
@khassel
Copy link
Collaborator

khassel commented Oct 9, 2024

will fail again, now e2e tests, will check why ...

@HeikoGr
Copy link
Contributor Author

HeikoGr commented Oct 9, 2024

ok, i will wait for your response

@khassel
Copy link
Collaborator

khassel commented Oct 9, 2024

question: is onecall the new default for all weather types, for current weather, for hourly weather and for forecast?

@sdetweil
Copy link
Collaborator

sdetweil commented Oct 9, 2024

openweather says /onecall is only

@HeikoGr
Copy link
Contributor Author

HeikoGr commented Oct 9, 2024

Except for pro customers. This is why i didn‘t remove the other endpoint functions

@sdetweil
Copy link
Collaborator

sdetweil commented Oct 9, 2024

but our users are mostly not pro. so does onecall
pull back everything and you can sort it out

@khassel
Copy link
Collaborator

khassel commented Oct 9, 2024

so now I know what is happening. First thing /onecall is correct (with /).

Problem is, that if no weatherEndpoint is specified we have this function in the code:

	/**
	 * Overrides method for setting config to check if endpoint is correct for hourly
	 * @param {object} config The configuration object
	 */
	setConfig (config) {
		this.config = config;
		if (!this.config.weatherEndpoint) {
			switch (this.config.type) {
				case "hourly":
					this.config.weatherEndpoint = "/onecall";
					break;
				case "daily":
				case "forecast":
					this.config.weatherEndpoint = "/forecast";
					break;
				case "current":
					this.config.weatherEndpoint = "/weather";
					break;
				default:
					Log.error("weatherEndpoint not configured and could not resolve it based on type");
			}
		}
	},

So with a new default "/onecall" instead of "" some tests fail because their configs have no weatherEndpoint and no weatherProvider and the above function is not called anymore.

To discuss:

  • all weather tests and (mock data?) are based on provider openweathermap. Is this correct @rejas ?
  • if the tests are bound to the above provider we should update their configs with weatherEndpoint and weatherProvider
  • do we need the function setConfig if we set a default weatherEndpoint? I think not, pro users can still set weatherEndpoint in the config

@sdetweil
Copy link
Collaborator

sdetweil commented Oct 9, 2024

we should test without the endpoint set too
should not be required

pick a provider, it should work

@rejas
Copy link
Collaborator

rejas commented Oct 10, 2024

all weather tests and (mock data?) are based on provider openweathermap. Is this correct @rejas ?

correct, we only test against openweathermap, so the mock data is specific to that provider too.

@khassel
Copy link
Collaborator

khassel commented Oct 10, 2024

@HeikoGr I have a fix for the tests now, is it o.k. to push this on your branch?

@HeikoGr
Copy link
Contributor Author

HeikoGr commented Oct 10, 2024

absolutely

@khassel khassel requested a review from rejas October 10, 2024 20:20
@rejas rejas merged commit 7489e51 into MagicMirrorOrg:develop Oct 11, 2024
8 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.

5 participants