Tasker And MyTracks

As part of my Constant Struggle To Simplify, I wanted to track my cycling miles without having to jump through hoops or do anything crazy. Up until recently, I was using Endomondo to track miles (and before that I used MapMyRide). These programs promise all sorts of features; social commentary, audio coaching, ANT+ and Bluetooth connectivity, route planning, etc. etc. But really, I found I didn’t use any of these extra features. I just wanted a simple, automated way to track my mileage that I could keep in digital form. And with Endomondo’s recent feature creep I was having to tap 3-4 menu items just to get to where I could record a ride! Nothing wrong with my Cyclecomputer, either, but I like analyzing numbers and stats.

Keeping with my wanting to use Tasker to automate stuff, I found a Tasker Plugin that allows it to start and stop Google MyTracks recording. MyTracks doesn’t have all the fru-fru social stuff, but it supports ANT+ and Bluetooth if I decide to go that route later (and Tasker can automatically connect to them). Plus it automatically syncs with Google Drive, so the potential for 100% complete automation is there. Let’s get busy!

There’s a couple of plugins I use to do this: AutoActivity, and the MyTracks Tasker Plugin.

AutoActivity is a service that runs in the background that guesses what you’re doing (walking, cycling, driving, still) based on GPS and inertia input, and assigns it a “confidence” score percentage of how sure it is you’re doing that. You can use it both as a trigger (i.e. “when you detect me driving, do this”) or an active variable (i.e. “Do this only IF activity=xxx”)

Tasker is so ridiculously flexible, it takes some playing around to figure out the best way to accomplish something. Sometimes the “best” solution isn’t immediately obvious. This is definitely the case with this problem. So, let’s look at what we want to accomplish, and how we can go about it.

When I first started looking at this, I didn’t trust AutoActivity enough for it to solely control starting and stopping MyTracks based on cycling activity. I had several rules made to where it detected what WiFi networks were near, what the time of day was, and so on. This technically worked for 99% of my rides, but if I took a trip to the store, it didn’t work, because the stop/start point wasn’t known. Once I was outside one of my predetermined scenarios, it didn’t know what to do.

I was originally running GPS apps with a Samsung Galaxy Tab 2 (7″) but man that thing is huge, and I recently upgraded to a Motorola Moto G phone. The problem is, I can’t root my phone! So Tasker has limited access to the system options.

Now, if I wanted to, I could add the Mytracks widget to my phone’s lock screen, and that lets me start/stop a ride with a single touch, without having to even unlock the phone. That’s awesome! But say I wanted it to start/stop automatically without having to do anything?

This will take some coding. First, if I’m only commuting, this mkaes it a lot easier. I can use Tasker to automate my commute recordings based on time, starting and stopping point, and mode of transportation.

Every time I ride to work, I start from home… that’s a fairly good assumption. I also usually start riding a lot earlier than I drive, but not always, so I can’t use that as a condition except to determine if I’m going to work or coming home.

So, let’s say: I set a GPS radius around my home, and if I leave that radius AND my wifi connection is down, then it assumes I’m leaving home (can’t do just one condition, in case GPS or wifi hiccups and triggers a recording). I could also add a condition for the time of day, or day of the week. So the flow would look like this:

WHEN NOT within 100m of home, Run task “Start Mytracks” IF not near home WiFi AND IF Time% < 5:30am
Start Mytracks:
Turn GPS on IF GPS = off
Open MyTracks
Start Recording IF Activity% = cycling

I also have a condition that detects when I’m within 100M of work, so the script basically runs like this:

IF within 100M of work, AND IF near Work WiFi, AND Activity% = cycling
THEN stop MyTracks recording

And this finished the record for my work-bound commute. I’ve added several other modifiers to it, i.e. a Boolean variable “Riding%” that I can use to check if I’m running a script on the bike. I can also have it play music from my Google Play music playlists, I can add conditions to record the ride home, and several other things if I want.

Ultimately, the flexibility is there to do just about any kind of automated task you can think of, though with MyTracks, the lockscreen widget makes it practically unnecessary. Experiment with it and see what you come up with!

6 Replies to “Tasker And MyTracks”

  1. I note you’re doing this in 2015 – which version of MyTracks are you using – because Google has killed the capacity to run the Tasker plugin?

  2. I’ll have to look and see, it was working the last time I tried it. Looking at it now, it seems they’ve removed all ability to have third-party apps use the API to start/stop recording.

    Well that sucks. Wrote that whole thing for nothing. This is why I’m having a hard time with Google lately… they seem to randomly be killing things people actually use, for no apparent reason.

  3. Hey Jeff, I’ve created a solution, phone needs to be rooted, and needs xposed framework. If you want more info, let me know!

  4. I’m rather bothered by this, really, but it fits in with Google’s habit of developing something and then removing all or part of its functionality “because nobody was using it” i.e. thousands of people.

    I guess this article will stand as a monument to Google’s insanely annoying rationale. But at least you can still use an older version, and/or use the lockscreen widget. There are plenty of other apps to use, I reviewed several of them here:
    http://jeffhendricks.net/?p=1278

Comments are closed.