OpenWeather icon indicating copy to clipboard operation
OpenWeather copied to clipboard

OpenWeather's One Call 3.0 API change

Open grm1209 opened this issue 1 year ago • 2 comments

OpenWeather's One Call 3.0 API changed element "timezone_offset" to "timezone". The changes to OpenWeather.cpp are:

62,62c61,62 < String url = "https://api.openweathermap.org/data/3.0/onecall?lat=" + latitude + "&lon=" + longitude + "&exclude=minutely" + exclude + "&units=" + units + "&lang=" + language + "&appid=" + api_key;

String url = "https://api.openweathermap.org/data/2.5/onecall?lat=" + latitude + "&lon=" + longitude + "&exclude=minutely" + exclude + "&units=" + units + "&lang=" + language + "&appid=" + api_key; 519c518 < if (currentKey == "timezone") timezone = value;


if (currentKey == "timezone_offset") timezone = value;

grm1209 avatar Nov 10 '24 00:11 grm1209

I made this changes and it gives errors on ESP32-S3

The connection to server is secure (https). Certificate not checked.

Sending GET request to api.openweathermap.org port 443
Header end found

Parsing JSON
[  8670][E][NetworkClient.cpp:319] setSocketOption(): fail on 0, errno: 9, "Bad file number"

Done in 4018 ms

gamebox13 avatar Nov 11 '24 11:11 gamebox13

I also had to change the URL String on line 61 in OpenWeather.cpp to reflect the latest version of the Onecall API, I changed 2.5 to 3.0.

 // One call API now subscription
  String url = "https://api.openweathermap.org/data/3.0/onecall?lat=" + latitude + "&lon=" + longitude + "&exclude=minutely" + exclude + "&units=" + units + "&lang=" + language + "&appid=" + api_key;

The URL string on line 91 should also be changed from 2.5 to 3.0.

tbirdrv avatar Apr 08 '25 18:04 tbirdrv