Weather Dependent Background Image

This will be a profile that will update your background image every hour to be a weather based image, when your battery is < 70% full.

01-complete%20profile%20overview

Download:

Tasker Profile (raw .xml file)
Wallpaper images


Steps:

Contexts

  • Create a new profile, name it whatever you want and set the first context to be State->Battery Level (you can do the time check first, it just depends on which check you want to run first. I think)
03-battery%20level%20selection
  • Set it to be Time; from 00.00 (or whenever you want to start checking) to 23.00 and repeating every hour.
04-time%20selection

Tasks

  • In the Task Edit window, add a new Variable->Variable Set where you create a %ZIPCODE variable, and set it to be whatever the zipcode of you want the background to be set for. You can skip this step, and manually add the zipcode to the URL in the next step, but I want to try to change this if your zip changes automatically so I'm leaving it as is.
05-variable%20zipcode
  • Back in the Task Edit window, add a Net->HTTP Get with port="rss.accuweather.com/rss/liveweather_rss.asp?metric=1&locCode=%ZIPCODE" without the quotes. Leave the path, attributes, and output file blank, the timeout I left at 10 and the Mime Type to be text/xml.
  • Add a Variable->Split Variable to split the returned variable, which is stored in %HTTPD, on the phrase "Currently:" without the quotes. The "Delete Base" checkbox simply deletes %HTTPD from memory once the split is done, this isn't too important either way it is set. But I'm picky like that.
06-variable%20split
  • Here I added a stop event, if the variable %HTTPD2 is not set ("! set" for you non programmers) because if that is not set, the rest of the task will cause errors and I just don't want to deal with those popping up. You can alternately use an if block (add task, Tasker->If; make sure you add a closing Tasker->End If) here, and do another null check for the first split, but I don't have a problem with that so I went with just the one.
07-stop
  • Add another Variable->Split Variable to split the second item in the "array" left over from the first split (HTTPD was split into two variables last time: HTTPD1 containing from the start to "Currently:" and HTTPD2 containing from right after that to the end) but this time split on a simple ":". This will end up with two more variables: HTTPD21 and HTTPD22 (or more, depending if a colon is encountered more)
08-split%202
  • After the two splits, %HTTPD21 contains a string similar to "Sunny", "Mostly Cloudy", "Thunderstorms", etc which would require many, many different images to cover all options. So we will set the variable to be one of a known selection to simplify our lives. We will use a number of Variable->Variable Set commands designed to ensure that the resulting weather fits our desired patterns. They all follow the formula of using an If check to see if the contents of %HTTPD21 match something like *Sunny*; where the * are wildcards to catch Mostly Sunny, Sunny or Not, or anything containing Sunny. We then set it to be just Sunny. I've created ones for Sunny, Cloudy, Storms (where I check if it is *Storm*/*storm* since it is case sensitive), Rain, and Clear. This will catch any phrase that fits this pattern.
10-rename%20variable
11-rename%20variable%202
  • Next I used the File->Write Line to output just what the weather I got for this time was so I can see it for myself, and also if there was one that was outside my expected parameters. This is optional.
12-write%20to%20file
  • A final Variable->Variable Set is used to catch any unexpected weather strings. So far the only time I've had this was two hours when Fog was predicted for my zip code. You set the %HTTPD21 to Default if the value is not equal to Sunny/Storms/Rain/Cloudy/Clear.
13-default%20check
  • A final thing I did because it looked cool was to add a Variable Set where I check the time, and if the time is greater than 19 (%TIME is system variable, in format 15.45 = 3:45pm) I append the phrase "Night" to the end of the %HTTPD21. Make sure the Append check box is checked.
14-night%20time
  • Now, to finally set the Wallpaper use Display->Set Wallpaper with the value of wallpapers/%HTTPD21.jpg and it will set the wallpaper to your current weather.
15-set%20wallpaper
  • Before this runs, make sure that you download the zip folder called wallpaper, or otherwise find images that suit your personal desires. This profile will expect there to be a folder called wallpapers in the root of your SD card, and the images contained therein to be .jpg formatted. If you use the Night activity, make sure you have two of everything that could be set, one with Night appended to the end (ie RainNight.jpg and Rain.jpg)

If you follow these steps, or download the attached .xml file it should work fine for you. Enjoy!

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License