Compare commits

..

1 Commits

Author SHA1 Message Date
abacon118 ced860a0b7
Merge 40abdb6939 into bd8422b228 2024-12-22 22:44:09 -05:00
1 changed files with 310 additions and 308 deletions

View File

@ -43,7 +43,7 @@ void OpenWeatherMapClient::updateLanguage(String language) {
void OpenWeatherMapClient::updateWeather() { void OpenWeatherMapClient::updateWeather() {
WiFiClient weatherClient; WiFiClient weatherClient;
String apiGetData = "GET /data/2.5/weather?id=" + myCityIDs + "&units=" + units + "&cnt=1&APPID=" + myApiKey + "&lang=" + lang + " HTTP/1.1"; String apiGetData = "GET /data/2.5/group?id=" + myCityIDs + "&units=" + units + "&cnt=1&APPID=" + myApiKey + "&lang=" + lang + " HTTP/1.1";
Serial.println("Getting Weather Data"); Serial.println("Getting Weather Data");
Serial.println(apiGetData); Serial.println(apiGetData);
@ -106,33 +106,35 @@ void OpenWeatherMapClient::updateWeather() {
} }
int count = root["cnt"]; int count = root["cnt"];
weathers[0].lat = (const char*)root["coord"]["lat"]; for (int inx = 0; inx < count; inx++) {
weathers[0].lon = (const char*)root["coord"]["lon"]; weathers[inx].lat = (const char*)root["list"][inx]["coord"]["lat"];
weathers[0].dt = (const char*)root["dt"]; weathers[inx].lon = (const char*)root["list"][inx]["coord"]["lon"];
weathers[0].city = (const char*)root["name"]; weathers[inx].dt = (const char*)root["list"][inx]["dt"];
weathers[0].country = (const char*)root["sys"]["country"]; weathers[inx].city = (const char*)root["list"][inx]["name"];
weathers[0].temp = (const char*)root["main"]["temp"]; weathers[inx].country = (const char*)root["list"][inx]["sys"]["country"];
weathers[0].humidity = (const char*)root["main"]["humidity"]; weathers[inx].temp = (const char*)root["list"][inx]["main"]["temp"];
weathers[0].condition = (const char*)root["weather"][0]["main"]; weathers[inx].humidity = (const char*)root["list"][inx]["main"]["humidity"];
weathers[0].wind = (const char*)root["wind"]["speed"]; weathers[inx].condition = (const char*)root["list"][inx]["weather"][0]["main"];
weathers[0].weatherId = (const char*)root["weather"][0]["id"]; weathers[inx].wind = (const char*)root["list"][inx]["wind"]["speed"];
weathers[0].description = (const char*)root["weather"][0]["description"]; weathers[inx].weatherId = (const char*)root["list"][inx]["weather"][0]["id"];
weathers[0].icon = (const char*)root["weather"][0]["icon"]; weathers[inx].description = (const char*)root["list"][inx]["weather"][0]["description"];
weathers[inx].icon = (const char*)root["list"][inx]["weather"][0]["icon"];
Serial.println("lat: " + weathers[inx].lat);
Serial.println("lat: " + weathers[0].lat); Serial.println("lon: " + weathers[inx].lon);
Serial.println("lon: " + weathers[0].lon); Serial.println("dt: " + weathers[inx].dt);
Serial.println("dt: " + weathers[0].dt); Serial.println("city: " + weathers[inx].city);
Serial.println("city: " + weathers[0].city); Serial.println("country: " + weathers[inx].country);
Serial.println("country: " + weathers[0].country); Serial.println("temp: " + weathers[inx].temp);
Serial.println("temp: " + weathers[0].temp); Serial.println("humidity: " + weathers[inx].humidity);
Serial.println("humidity: " + weathers[0].humidity); Serial.println("condition: " + weathers[inx].condition);
Serial.println("condition: " + weathers[0].condition); Serial.println("wind: " + weathers[inx].wind);
Serial.println("wind: " + weathers[0].wind); Serial.println("weatherId: " + weathers[inx].weatherId);
Serial.println("weatherId: " + weathers[0].weatherId); Serial.println("description: " + weathers[inx].description);
Serial.println("description: " + weathers[0].description); Serial.println("icon: " + weathers[inx].icon);
Serial.println("icon: " + weathers[0].icon);
Serial.println(); Serial.println();
}
} }
String OpenWeatherMapClient::roundValue(String value) { String OpenWeatherMapClient::roundValue(String value) {