Tasker Script for OpenWeatherMap.org API


After relentless searching for a current, working script to query any of the major weather servers for integration in tasker apps (and in my case, autocast), I couldn’t find one that worked perfectly for my needs.

Below, I have made available the tasker scripts that I created for this project. My script makes use of the OpenWeatherMap.org API with JSON data. Tasker uses javascript to interact with the raw data and import into global tasker variables.

Tasker task description below:

Fetch Weather (89)
 A1: Get Location [ Source:Net Timeout (Seconds):100 Continue Task Immediately:Off Keep Tracking:Off ] 
 A2: Variable Set [ Name:%locationsplit To:%LOCN Do Maths:Off Append:Off ] 
 A3: Variable Split [ Name:%locationsplit Splitter:, Delete Base:Off ] 
 A4: Variable Section [ Name:%locationsplit1 From:1 Length:5 Adapt To Fit:Off Store Result In:%Lat ] 
 A5: Variable Section [ Name:%locationsplit2 From:1 Length:5 Adapt To Fit:Off Store Result In:%Lon ] 
 <Current Weather>
 A6: HTTP Get [ Server:Port:api.openweathermap.org Path:data/2.5/weather?lat=%Lat&lon=%Lon&units=imperial Attributes: Cookies: Timeout:10 Mime Type: Output File: Trust Any Certificate:Off ] 
 A7: JavaScriptlet [ Code:var now = JSON.parse(global("HTTPD"));

setGlobal("WeatherLocation",now.name); Libraries: Auto Exit:On Timeout (Seconds):45 ] 
 <Today's Forecast>
 A8: HTTP Get [ Server:Port:api.openweathermap.org Path:/data/2.5/forecast/daily?lat=%Lat&lon=%Lon&cnt=1&mode=json&units=imperial Attributes: Cookies: Timeout:10 Mime Type: Output File: Trust Any Certificate:Off ] 
 A9: JavaScriptlet [ Code:var forecast = JSON.parse(global("HTTPD"));

setGlobal("Forecast",forecast.list[0].weather[0].description); Libraries: Auto Exit:On Timeout (Seconds):45 ]

Note: This¬†thread was used as a reference to acquiring the GPS coordinates in order to tell the OpenWeatherMap.org API the device’s current location.

Script available here: Fetchweather.xml

7 thoughts on “Tasker Script for OpenWeatherMap.org API

  1. Hello,

    Thanks for you share.
    How to use the rain data?
    I tried this code:

    But Tasker gives this error: “unexpected token ILLEGAL”.
    (in the array the data is: “rain”:{“3h”:2.005}, )

    What’s the problem??


  2. Hi, I’m looking for information on how to get the Open Weather Map data in my Tasker. I guess I’m interested in your script, but the zip file is not available… Perhaps you could make the zip file available again? Thank you!

Leave a Reply

Your email address will not be published. Required fields are marked *