Tasker Tutorial: Have your phone tell you today's weather and forecast.


I've been using Tasker for years now. For me, I've found this app to be the more diverse tool to this day - and there are a lot of automation apps out there for Android now.

Recently, Martin from Android Coliseum here asked me if I had any "tasks" on my phone that may be of interest to him, other than the classic ones out there, such as having the phone mute when at work, etc.

I'd happened to work on one profile/task a few months ago where my phone will audibly read me the weather report each morning at 6:45am.

"Good morning Danielle and Rob. The temperature in Winnipeg is 0 degrees Celsius with cloudy skies. Later, rain with high of 12 degrees Celsius."

FYI, Danielle is my wife. I wouldn't my phone to be rude and ignore her each morning!

On to the tutorial.

Sign Up On Wunderground


So for Tasker to retrieve any weather information, the app needs to obtain it from somewhere. I used Wunderground for this. You'll have to go sign up at http://www.wunderground.com/weather/api/ in order to get an API key. This API key is what you'll use later within Tasker.


One you get to their website, click on the orange button with "Sign Up for FREE". Don't worry, this won't cause you to have your email spammed to the ground. It's fine.

Once you've signed up, make up a project name, verify your email, and write down the API key they provide you.

Create the Task


Now, back to Tasker. Create a new task. I called mine Weather Report, but you can call yours whatever you'd like. 

Since my weather report occurs first thing in the morning, my Media Volume is muted, so we need to make sure that is turned up so you can actually hear the report. So the first action you'll add within the task is Audio > Media Volume. Then set the Level to where you'd like it. I have mine set to 4, but this will vary depending on your phone and other noise that make be around you. 

Now we want to actually retrieve the weather from Wunderground. To do this, add another action to the task - Net > HTTP Get. Here is where a tiny bit of trial and error will come into play. (Took me a while to figure this out.) For the Server:Port type in api.wunderground.com. For Path, type in /api/YOURAPIKEYHERE/conditions/forecast/q/Canada/YOURCITYNAME.json.

So in my case, my path is /api/xxxxxxxxxxxxxxxx/conditions/forecast/q/Canada/Winnipeg.json. (Sorry, I'm not sharing my API key, hence all the x's there.)

Now, before we get too far, let us add a temporary action to show that the HTTP Get worked. Add an action Alert > Flash and in the Text field, simply add %HTTPD. You should see a really big popup show with a lot of weather information. If you don't, go back and be sure your API key and your spelling are all correct.

If you succeeded, then continue on!

Remember, we're still within the same task here within the Tasker app. You're adding all of these actions to one task!

Now we will begin to take bits and pieces of the %HTTPD array that we had created. Make another action by going to Code > JavaScriptlet. In the Code field, enter the following; var temp_f = JSON.parse(global('HTTPD')).current_observation.temp_c; 

Next, add another JavaScriptlet action. In the Code field, enter; var skies = JSON.parse(global('HTTPD')).current_observation.weather;

Once more, add the third and last JavaScriptlet action. In Code, enter; var city = JSON.parse(global('HTTPD')).current_observation.display_location.city;

What we just did here was take bit and pieces of the %HTTPD array and add those pieces to temp_f, skies, and city. Now we can add actions to have Tasker read out the info!

I separated my Say actions just so the wording would sound more paced and realistic. This is up to you though and your own preferences.

Add another action to the task - Alert > Say. In the Text field I have, "Good morning, Danielle and Rob." Without the quotes. Obviously, you'd type in your name(s).

Now we add our second Say action, and in the Text field, add, "The temperature in %city is %temp_f and %skies." Again, ignore the quotes.

I added a Wait action at this point for 30 MS. This is up to you.

The last step is the final action which is a Say action again. In the Text field, "Later, %high" - no quotes.

Now text out your task by tapping the play button in the bottom-right corner. If all went well, you should hear your phone say a friendly greeting and tell you today's weather.

Create the Profile


If you want the task to run automatically, you'll need to create a profile which will activate it. In my case, I have a profile that runs my task every day at 6:45am.

Create a new profile and select Time. Then edit the time From: to whatever time you'd like. For To:, I just put the time to one minute later. I know we can shut off the To: option, but I've had my task run at odd times. Having mine run from 06:45am - 06:46 daily has worked perfectly fine for months now.

You're done!

That's it! Your phone can now read you the weather daily, hourly, weekly... Whenever you'd like! Just adjust your Profile accordingly. 

Comments