Thursday, March 28, 2013

Find your phone with Tasker and Pushover




Tasker is a tool to automate almost anything on Android. I use it to adjust volumes on a schedule, turn off pattern lock screen at home, etc. I will write more posts about Tasker, but if you want to try it out there's a 7-day trial version on the Tasker site, and a full, paid version on Play Store. I can recommend the Pocketables Beginner's Guide to Tasker series, the Userguide on Taskers web site and this Tasker Wiki

I already mentioned Pushover in a previous post, but essentially it's a tool to send notification to mobile devices (Android and iOS).

I wanted a way to locate my mobile phone in case it's lost. There are many apps that can do this already, but with Tasker you can do it yourself. I didn't even have to figure out how to do it myself, as a good recipe  is already available on a Tasker Wiki. There are some variants on that site and I ended up with the tasker code below.
To find your phone, send a text message to your lost from from any other mobile phone with <your keyword> in the message. Tasker will trigger, get the phone location using any of the methods available (GPS or WiFi positioning) and send back a text message with a Google Maps URL with your lost phones position mapped out.

Tasker Profile
Profile: LocateSMS (2)
Event: Received Text [ Type:Any Sender:* Content:<your keyword> ]
Enter: LocationPushover (3)

Tasker Task
LocationPushover (3)
A1: Get Location [ Source:Any Timeout (Seconds):120 Continue Task Immediately:Off Keep Tracking:Off ]
A2: Variable Set [ Name:%LOCATION To:%LOCN Do Maths:Off Append:Off ] If [ %LOC ! Set ]
A3: Variable Set [ Name:%LOCATION To:%LOC Do Maths:Off Append:Off ] If [ %LOC Is Set ]
A4: Send SMS [ Number:%SMSRF Message:http://maps.google.com/maps?q=%LOCATION Store In Messaging App:Off ]
A5: Variable Clear [ Name:%LOCATION Pattern Matching:Off ]

This is nice, but since I've started to use Pushover for notifications I wanted to try that out as well. Reading up on the Pushover API I figured the easiest way is to do a HTTP Post from Tasker with a properly formatted Path. Since I want to send a URL in the notification message I need to URL encode it, otherwise Pushover API would try to interpret the /, ? and & as part of the API URI. I URL encoded the Google Maps 

URL part and ended up with a new step four in the Tasker Task.

A4: HTTP Post [ Server:Port:https://api.pushover.net Path:/1/messages.json?user=<user token>&token=<app token>&title=Phone+location&message=http%3A%2F%2Fmaps.google.com%2Fmaps%3Fq%3D%LOCATION Data / File: Cookies: Timeout:10 Content Type:application/x-www-form-urlencoded Output File: ]
URL Encoding is easy. A good guide is available at the w3schools.com website. This URL:
http://maps.google.com/maps?q=%LOCATION
is turned into this:
http%3A%2F%2Fmaps.google.com%2Fmaps%3Fq%3D%LOCATION

In addition to the Tasker script, I created a new Pushover application, added a Google Maps icon and that was it. When I send a text with my keyword I get the following Pushover notification on all my devices.


If you want to use the code above, you just need to change <your keyword> to a keyword of your choice. This is the word you need to text to your lost phone to trigger the Tasker Profile and Task. In the code you also need to replace <user token> and <app token> if you want to use Pushover.

4 comments:

  1. Hm, I think I will try this Tasker. Thank you! Last time I used a free mobile tracker https://snoopza.com/ I can tell it works perfectly and it has a very nice design. This is why I decided to use it.

    ReplyDelete
  2. In this article, you will have some valuable data about cellular phone tracking gadgets. telefon takip

    ReplyDelete
  3. This sort of assistance could be valued because it is difficult for nearby police to trace location without a proper assist.is the truth spy legit

    ReplyDelete