- The URL for weatheronline has changed to: free.worldweatheronline.com/feed/weather.ashx the querystring elements remain the same (?q=%LOC&…)
This profile (well, task) uses the %LOCN variable to get CSV weather data for your location from the web and notify you of it. It's pretty quick and works great: on my old and slow-as-hell G1 it gives a response in about 6 seconds. I'm sure it will be quicker still for the rest of you!
Note that you could easily replace %LOCN with %LOC, just where I am in the UK the network location seems fairly accurate; certainly it has a much finer resolution than that of weather reporting and forecasting. I made the task (and thus the example here) notify me of the current conditions, though you could (somewhat) easily adapt it to one of the forecasts provided by consulting the column description data provided in the header of the CSV file.
Prerequisites
You will need a free account with World Weather Online, who do the rather fantastic service of giving up to a 5 day forecast in CSV format from your provided latitude/longitude. Sign up here.
I think you have to click a link in the email they send you, so give your real address. I haven't had any junk from them so no worries there. Notice in the email that there is a long string of letters/numbers in bold, something like so:
Your API Key to access our weather forecast is 00000x0xxx000000000000
You will need this API key soon so keep it to hand! See here for more info about the service provided.
The basic task
The task, complete with a profile to run it at 0700 each day so long as battery level is > 15%. NB I don't actually use it this way usually, I tend to call it either on-demand from a home-screen icon or have it triggered by when my morning alarm goes off. Watch out for all the variable split's up ahead… if there is a better way to do this then please, edit and tell us all so!
So, create a task. Name it something along the lines of 'Weather Notification'. Add the following actions:
- Net / HTTP Get
- Server:Port = www.worldweatheronline.com/feed/weather.ashx?q=%LOCN&format=csv&num_of_days=2&key=00000x0xxx000000000000 [replace number of days with one of 2,3,4,5 to receive that many days of forecast. Paste your API key in here instead of that string of x's and zeroes.]
- Timeout = 10 [Your choice, I found the site responds quickly so a fairly low timeout value of 10 seconds could be used.]
- Variable / Variable Split
- Name = %HTTPD
- Splitter = esc,precipMM
- Variable / Variable Split
- Name = %HTTPD2
- Splitter = ,
- Alert / Notify
- Title = %HTTPD25
- Text = %HTTPD22 deg C
- Variable / Variable Split
- Name = %HTTPD24
- Splitter = //
- Variable / Variable Split
- Name = %HTTPD242
- Splitter = 64/
- Net / HTTP Get
- Server:Port = %HTTPD242
- Mime type = image/png
- Output File = weather_thumb.png [This saves an image to /sdcard/weather_thumb.png . If you like, hide it in a folder or something. I just left it on root for laziness and simplicity]
You may notice the notification is done and dusted in the middle, but still more actions are going on. These are prep work for later! I set it up so that tapping the notification produced a popup with further info. If you aren't interested in this then you can ignore actions 5-7 and just have a task which notifies with temperature and a brief description of overall conditions. The real meat is yet to come though!
The details profile
(I will upload the file for this soon)
This profile watches for a notification click from the first task, and then provides more info about the weather.
- Create a new profile called 'Weather Details'
- Context: Event / UI / Notification Click
- Title = %HTTPD25
- Add the action:
- Alert / Popup
- Text:
- Alert / Popup
Currently %HTTPD22 deg C
Wind %HTTPD26 mph
Raininess %HTTPD210
Visibility %HTTPD212 [Not sure of the units for these two]
# Center Text = tick
# Background Image = weather_thumb.png [This is really nice! :-D ]
Done!
Further considerations:
- Something I considered setting up was logging of the values for current temperature overnight, and issuing a warning in the morning if the temperature had dropped below zero, i.e. if there was a possibility of ice having formed on the roads.
- Variable split is a bit of a messy business: working out where all the data has gone and under what name can be a nightmare, so backup your working tasks & profiles before fiddling with one like this!
Get in touch at ung (at) gmx.com for queries!