Closed ghost-ps closed 2 years ago
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.
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!
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!