Webhook ... Read all the documentation but still having issues

I use openweathermap too, webhook isn’t needed at all.

this my snippet, I don’t know if it can help :thinking:

void forecast(){
    HTTPClient http;  //Declare an object of class HTTPClient
    http.begin("http://api.openweathermap.org/data/2.5/weather?id=YourId&APPID=YourKeyHere&   units=metric&lang=fr");  //Specify request destination
    int httpCode = http.GET();     //Send the request
    if (httpCode > 0) { //Check the returning code
      payload = http.getString();   //Get the request response payload
        }
    http.end();   //Close connection
      JsonRequest();//call Json to decript weather
} 


void JsonRequest() {

  DynamicJsonDocument doc(976);
  deserializeJson(doc, payload);

  float coord_lon = doc["coord"]["lon"]; 
  float coord_lat = doc["coord"]["lat"];

  JsonObject weather_0 = doc["weather"][0];
  int weather_0_id = weather_0["id"]; 
  const char* weather_0_main = weather_0["main"];
  const char* weather_0_description = weather_0["description"]; 
  const char* weather_0_icon = weather_0["icon"]; 
  const char* base = doc["base"]; // "stations"


  JsonObject weather_1 = doc["weather"][1];
  int weather_1_id = weather_1["id"]; 
  const char* weather_1_description = weather_1["description"];

  JsonObject main = doc["main"];
  float main_temp = main["temp"]; 
  float main_feels_like = main["feels_like"];
  float main_temp_min = main["temp_min"]; 
  int main_temp_max = main["temp_max"]; 
  int main_pressure = main["pressure"];
  int main_humidity = main["humidity"]; 
  int visibility = doc["visibility"];
  float wind_speed = doc["wind"]["speed"];
  int wind_deg = doc["wind"]["deg"]; 
  int clouds_all = doc["clouds"]["all"]; 
  long dt = doc["dt"]; // 1587889504

  JsonObject sys = doc["sys"];
  int sys_type = sys["type"]; 
  int sys_id = sys["id"]; 
  const char* sys_country = sys["country"]; 

  char buff[32];

  long sys_sunrise = sys["sunrise"]; // 1587875670
  String Sunrise = String(hour(sys_sunrise))+ ":" +String(MyPrintDigits(minute(sys_sunrise)));
  sendToNextion(1, "home.Sunrise", Sunrise);

  long sys_sunset = sys["sunset"]; // 1587926436
  String Sunset = String(hour(sys_sunset))+ ":" + String(MyPrintDigits(minute(sys_sunset)));
  sendToNextion(1, "home.Sunset", Sunset);

  int timezone = doc["timezone"];
  long id = doc["id"]; 
  const char* name = doc["name"]; 
  int cod = doc["cod"];

  // temp Ext
  String T_Ext = String(main_temp);
  T_Ext = T_Ext.substring(0, 2);
  sendToNextion(1, "home.T_Ext", T_Ext);

  String D_Ext = String(main_temp);
  D_Ext = D_Ext.substring(2, 4);
  sendToNextion(1, "home.D_Ext", D_Ext);

  //Hum ext
  String H_Ext = String(main_humidity);
  sendToNextion(1, "home.H_Ext", H_Ext);
 
  String description = weather_0_description;
  sendToNextion(1, "home.weather_desc", description);
  setWeatherPicture(weather_0_id);
}
2 Likes