Tutorial: include current weather information from openweathermap.org

Weather information can be collected from open weather sources which provide a free API to retrieve current weather information. An example of such a weather service is https://openweathermap.org

Create your own account on the portal and generate your API key.

With the help of following link you can get weather information in the below format ({city} has to be replaced by the city name and {API key} by your API key):

https://api.openweathermap.org/data/2.5/weather?q={city}&appid={API key}

The response of this weather data is in JSON format. Here is an example:

{
    "coord": {
        "lon": -122.08,
        "lat": 37.39
    },
    "weather": [
        {
            "id": 800,
            "main": "Clear",
            "description": "clear sky",
            "icon": "01d"
        }
    ],
    "base": "stations",
    "main": {
        "temp": 282.55,
        "feels_like": 281.86,
        "temp_min": 280.37,
        "temp_max": 284.26,
        "pressure": 1023,
        "humidity": 100
    }
}

To get the temperature from the weather data, the following JPath definition has to be used (the parameters {0} and {1} will later be replaced by concrete parameter values within the HTTP data point definition):

$.{0}.{1}

The resource definition looks as follows: this expression search for element that has the attribute main equal to parameter {0}, afterwards for temp and finally writes the value which is 296.63 in our example.

To use resource definition to integrate the parameters from weather station, you can use following data point definitions.

As shown here “main,temp” is used in polling parameters. This means that the server will replace {0} by main and {1} by actual temp function.

The item tree of this example looks as follows: