OpenWeatherMap forecast

OpenWeatherMap is a web that provides multiple weather services through a HTTP API.

This brain4it module uses the OpenWeatherMap API to show the weather forecast for a given location.

First of all, you must obtain an API key (appid) to use the API. For doing that, you must create an account in OpenWeatherMap but it has no cost.

Once you have the appid, choose your location_id from and put both in the setup list:

  "location_id" => "<your_location_id>"
  "app_id" => "<your_app_id>"
  "read_interval_hours" => 1

The read_weather and read_forecast functions of this module read the current weather data and the weather forecast data respectivelly. These functions make a HTTP call to the corresponding OpenWeatherMap service and save the result in a variable:

(function ()
  (set weather
        "output-format" => "json"
  (module-notify "@display")

These functions are called at regular intervals inside the loop code block:

(while true
      (for-each rules rule (eval rule))
      "*" =>
      (set error (list ex (format-date (date))))
  (sleep (* setup/read_interval_hours 3600000))

After getting the weather and forecast data the rules contained in the rules list are executed to perform the tasks that you desire.

The dashboard of this module has a display widget that shows the current weather data (temperature, humidity and pressure) and the forecast for the next 9 hours:

Download module