willasm / obsidian-open-weather

Obsidian plugin for OpenWeather API
MIT License
47 stars 3 forks source link

More than one city with the same name? #19

Closed Lash-Morningstar closed 7 months ago

Lash-Morningstar commented 7 months ago

I added my city and country but the app consistently pulls the information for the wrong city and there does not seem to be a way to be more specific?

When I search in the OpenWeather site with the same city, country style it does show two options, the first of which the information being supplied by the plugin matches, so its not pulling the wrong info, just the wrong city.

Is there a way to fix this? Maybe allow [lat, log] or city, state, country?

Screenshot 2024-02-17 221213

Screenshot 2024-02-17 221246

willasm commented 7 months ago

I will add the option of entering lattitude and longitude coordinates to handle cases like this. It is actually now the preferred method to use the API so I need to add that option anyways. In the meantime try entering the following for South Bend city.

South Bend, WA (This is for Washington. Note that the comma after Bend is required) or South Bend, WA, US

I just looked at the city json file list and I see that the entry for South Bend, IN appears in the list first, so that is what is being returned. Adding the state should fix this. I will add this information to the readme file as well as adding the latitude and longitude options. I will try to get this done this weekend.

Thanks for letting me know about this issue, William.

willasm commented 7 months ago

I just tested this and using South Bend, WA, US does work, South Bend, WA however does not work.

I have completed adding the Latitude and Longitude settings to the plugin. I still have things I want to do before creating a new release but if you really need it you can get the updated Main.js here on Github. Just view the file and select the raw button, then select all and copy the contents. Save the clipboard contents to a file named Main.js and move it into the plugins folder inside your vault. Rename the original file first to back it up. The path is {Your vault folder name}\.obsidian\plugins\obsidian-open-weather. I hope to set a new release in the next day or two if you just want to wait. Setting the location to South Bend, WA, US I can confirm does work.

Here is the new settings... SettingsOpenWeather

And a sample of South Bend weather... SouthBend

Lash-Morningstar commented 7 months ago

First off: Thank you so much for responding so quickly and not only working to implement the correction suggested but also provide other working solutions and test them on top. Truly noteworthy dev behavior.

I will go test this ASAP. After posting the less preferable solution (that honestly should have occurred to me first) of inputting a near enough city that did pull accurately was used as a stopgap solution, which while serviceable is improved upon by this.

Thank you!

willasm commented 7 months ago

First off, thanks for the compliment, that is always greatly appreciated! Just want to let you know I just uploaded a new version that fixes a couple of bugs that affected a few people. It also now returns a properly formatted error message for any errors returned from the API. If you already downloaded the Main.js file I strongly suggest doing so again as the fix for the error messages alone is a huge help in diagnosing any issues. Also, let me know if you are getting correct data back now. Thanks again, William.

willasm commented 7 months ago

I have just created the release v1.7.0 and it should be available in Obsidian shortly. I have added quite a lot to this release. There is now a button in the settings that will use the Geocoding API to get a list of up to 5 cities matching your search query. This will fix the issue you have and anyone else in this position has. See the changelog for a list of the new features.

Thanks, William.

Lash-Morningstar commented 7 months ago

Sorry about the delay, it's fixed. Thanks again for responding and now also for finishing the job and solving the problem. 10/10 would recommend.