currentweather - temperature (minimum and maximum)



  • Hi everyone =)

    I mostly finished my own Mirror and I’m having some trouble with the currentweather. I would like to display the minimum and maximum temperature of the day in the currentweather API and I seriously have no idea how to fix that problem. I was trying to fix it on my own but all I was able to display on the mirror was “undefined” for minimum and maximum tempereture. Could anyone explain to me what I actually have to do to get the data to the currentweather API?

    Kind regards from Germany,
    Keromida



  • Okay, I was able to write the code correctly and it is able t display the temperature on the right position but I still have the problem to get the data for the temperature information from openweathermap.org and connect it to the written code. All I can see on the screen is null°. I guess the data is missing and also the connection to the data from openweathermap.org.

    This is how it looks like at the moment
    Bild Text

    Edit: I can’t locate the part of the code where the data of openweathermap.org is connected to the currentweather.js code. Can anyone help me where to find it?


  • Module Developer

    @Keromida The request url is assembled here:

    		var url = this.config.apiBase + this.config.apiVersion + "/" + this.config.weatherEndpoint + '/' + this.getParams();
    

    The deafults are:

    		apiVersion: "2.5",
    		apiBase: "http://api.openweathermap.org/data/",
    		weatherEndpoint: "weather"
    

    Which makes:

    http://api.openweathermap.org/data/2.5/weather/
    

    Then getParams() adds id or q depending on your config, units, lang and APPID ultimately making (example):

    http://api.openweathermap.org/data/2.5/weather/?q='Dusseldorf,DE'&lang=DE&units=metric&APPID=
    

    They returned JSON will oook like this:

    {"coord":{"lon":6.78,"lat":51.22},"weather":[{"id":803,"main":"Clouds","description":"überwiegend bewölkt","icon":"04d"}],"base":"stations","main":{"temp":12.27,"pressure":1011,"humidity":63,"temp_min":10.56,"temp_max":14.44},"wind":{"speed":2.12,"deg":94.501},"clouds":{"all":76},"dt":1471496164,"sys":{"type":3,"id":192509,"message":0.0438,"country":"DE","sunrise":1471494283,"sunset":1471546042},"id":2934246,"name":"Dusseldorf","cod":200}
    


  • Thank you for your help RedNax! The JSON Code really helped me out to fix it! I chose the wrong names for temp_min and temp_max. That’s why i couldn’t receive the data.

    Could you tell me where to find those JSON codes for the weather?


  • Module Developer

    @Keromida Do you mean the forecast?

    http://api.openweathermap.org/data/2.5/forecast?q='Dusseldorf,DE'&lang=DE&units=metric&APPID=
    

    You can also have a look here: http://openweathermap.org/api


Log in to reply
 

Looks like your connection to MagicMirror Forum was lost, please wait while we try to reconnect.