Showing posts with label world community grid. Show all posts
Showing posts with label world community grid. Show all posts

Thursday, 19 February 2015

Tasker - making use of javascript

Yesterday I posted about using WatchMaker with Tasker for automation, and I built a watch face that used Tasker to update variables which were displayed on screen.  Here it is...


World Community Grid - 20 downloads


However, it bugged me that I couldn't quite get it to look right, I wanted to add thousand markers to the rank (#215,027) and points (181,052).  I couldn't figure out a way to do this in WatchMaker, or in Tasker, until I discovered the javascript option.  In Tasker you can add a step in the task which runs javascript, which can access the global variable that you've already set, re-format it, and then set the global variable again.  Here's what I did...




I'm not going to explain the javascript, because that's not really the point, but you can find out more about the javascript API and what's available in Tasker here... http://tasker.wikidot.com/userguide-en:javascript.

The end result is this...


It's a small difference, but I think it looks much better.  And I love that I found a way to make the watch display exactly the way I wanted.

Wednesday, 18 February 2015

WatchMaker with Tasker for automation

Tasker is a very popular app for automation, in fact it describes itself as "Total Automation, From Settings to SMS".  I'm only just starting to use it, and I can already see that there's loads of potential.  In short, you create profiles, which get activated by certain conditions, and tasks, which are a series of actions and can be run when these profiles activate or de-activate.  I'm not going to go into too much detail though, as this is an Android Wear blog, and not an Android blog.  

Having said that, here's a WearTasker app, which allows you to trigger tasks directly from your watch, which could prove to be very handy!  There's also integration with WatchMaker, allowing you add a "tap action" to any element of the watch face, and the action can be to trigger a task.

What really interested me initially though was the ability for Tasker to set global variables, which can then be passed through to WatchMaker, allowing you to display values on your watch face which the phone can update.  

I was interested in doing a World Community Grid watch face.  World Community Grid enables anyone with a computer, smartphone or tablet to donate their unused computing power to advance cutting-edge scientific research on topics related to health, poverty and sustainability.  For all the work that you process, you are rewarded with points.  I wanted to see my points, and my current rank, right there on my watch!  This is what I came up with...

World Community Grid - 20 downloads

So I've already said that I don't want to do a full on Tasker review, but here's roughly what I did...

  1. Create a new task in Tasker
  2. Set Tasker variable %WCGUserName to "rik_lewis" (my username)
  3. Get my statistics as an xml stream from https://secure.worldcommunitygrid.org/stat/viewMemberInfo.do?userName=%WCGUserName&format=xml
  4. Split the results to get the bit between "<Points>" and "</Points>"
  5. Set Tasker variable %WCGPoints to the points value
  6. Split the results to get the bit between "<PointsRank>" and "</PointsRank>"
  7. Set Tasker variable %WCGPointsRank to the rank value
  8. Send both variables to WatchMaker
Here are some screenshots with more details...


Then create a new profile in Tasker which is triggered by time, repeating every hour, which runs your task...


This means that every hour the task will run and fetch the values, and send them through to the watch face.  To reference these variables in WatchMaker you use the tags {twcgpoints} and {twcgpointsrank} respectively.  In fact any Tasker variable is reference with the tag {t...}, which is nice and simple to remember.

All in all this works very well, and is so powerful when it comes to customising your watch.  Regularly fetching up-to-date data from the web is just one idea, you could also send the current wifi network name each time you connect, or hundreds of other things.