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

[Feature request] Support for call current weather data by city ID #36

Closed
ghost-ps opened this issue Jul 11, 2021 · 2 comments
Closed
Labels
enhancement New feature or request

Comments

@ghost-ps
Copy link

Support for calling current weather data by city ID instead of city name would be very nice.

Very often there are several same name of cities in different places, unfortunately there is no possibility to specify them exactly by name.

Information about call weather by city ID.

Thanks for your excellent plugins and the many extension and updates!

@ebaauw ebaauw added the enhancement New feature or request label Jul 11, 2021
@ebaauw
Copy link
Owner

ebaauw commented Jul 11, 2021

The plugin actually uses the One Call API to retrieve the weather for latitude/longitude coordinates. The Weather API call is only made once, to get the coordinates for the location. You might be able to disambiguate the location by using "City,State,Country".

As mentioned in #13, the issue is not so much using the city id (just need to do a different lookup call) or coordinates directly (no lookup needed), but more how to specify these in config.json.

Could you try beta v2.5.6-0? It has a new cityIds config.json key for a list of (integer) city IDs. I had to change the startup logic somewhat: I now check the location or city id, before creating the accessory. The accessory won't be created when you specify an unknown location or city ID:

[7/11/2021, 7:37:36 PM] [Weather] openweathermap request 2: GET weather?q=Minas Tirith
[7/11/2021, 7:37:36 PM] [Weather] warning: openweathermap request 2: openweathermap status: 404 city not found
[7/11/2021, 7:37:36 PM] [Weather] warning: Minas Tirith: ignore unknown location

Also added a log message with the location, city ID, and coordinates.

[7/11/2021, 7:37:36 PM] [Weather] openweathermap request 1: GET weather?q=London
[7/11/2021, 7:37:36 PM] [Weather] openweathermap request 1: 200 OK
[7/11/2021, 7:37:36 PM] [Weather] London [2643743]: 51.5085°N, 0.1257°W

And a check to filter duplicate locations when specifying both the location and city ID:

[7/11/2021, 7:37:36 PM] [Weather] openweathermap request 3: GET weather?id=2643743
[7/11/2021, 7:37:36 PM] [Weather] openweathermap request 3: 200 OK
[7/11/2021, 7:37:36 PM] [Weather] warning: 2643743: ignore duplicate location London

I think I should probably base the accessory ID on the city ID, rather than the location, but that would be a breaking change, causing HomeKit to see them as new, different accessories.

@ghost-ps
Copy link
Author

ghost-ps commented Jul 11, 2021

I have just installed your new beta v2.5.6-0 and what can I say, it works perfectly only with the city ID!

If you use city name and city ID, however, again another other location is used than the specified ID.

It is now perfect for me as you have programmed it now, thank you very much for your efforts and the quick implementation!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants