Main Section
CodingFiction
Bookmarker · Google Search Ratings · GMail Encryptor
Key Generation

Tasker Weather for Android

As an avid user of Tasker on Android, I am always looking for new ways to use this extremely versatile program. Recently I discovered Scripting Layer for Android (SL4A) which allows me to pull in my other passion - Python and produce a weather icon (shown here full size): on my home screen. This icon is scaled down to the correct size for your device automatically.

My objective was to pull in local weather conditions and display it in an icon on the homescreen. Originally I had planned on creating an icon for the temperature along with a second one showing the conditions. This soon proved to be a nuisance as there are obviously a large number of temperatures to account for.

This is where SL4A came in. I kick off the python script from Tasker. This script then pulls the weather information from the various websites and builds up an icon showing the temperature and conditions. In addition it also writes out a file with the temperature, conditions and number of severe weather alerts for additional action by Tasker.

SL4A

This is achieved with a second script (pngmaker.py) which creates the PNG file for Tasker to display. This is a slight adaptation of Rui Carmo's script over at The Tao of Mac. This script combines pre-built PNG files for the temperature and some existing icons for the weather conditions . There is also an icon to indicate severe weather conditions . Note that some pre-built images have a green background. This is used as the alpha layer as the simple PNG format used in my script doesn't handle transparency. Save your files in 24bit format if you decide to create your own versions.

The main script (curr_weather.py) pulls in the location and then gets the weather information for processing. Note that I pull the weather in Celsius format and I display the "feels like" temperature rather than the actual values. If you wish to display temperatures in Fahrenheit then change all the XML references ending in _c to _f. Currently the script just shows a little icon to indicate severe conditions, I am still deciding how to handle audible notifications so that the user isn't constantly harrassed by repeating notifications.

Tasker

The tasker script runs every 30 minutes and kicks off the Python script and then updates the widget's (named weather) icon and label. (download script)

Here are the steps in regular language

Known Issues

Be careful when uploading the scripts to your phone as it is sensitive to the way it's uploaded and you could mess with the line endings and cause problems for Python.

Version control / Downloads

VersionReleasedComments
Version 1.12011/01/12Vastly improved graphics & temperature reading
Original version2011/01/08