Monday, June 10, 2013

[Tasker] How to make accurate location checks without GPS or WiFi

Tasker has a nice option build in to check for locations. I found, that this method was not very reliable when no GPS was activated. Here I want to present an idea of location checks only with GSM cell info, no internet connection, WiFi or GPS needed. In my opinion it is the most energy conserving method possible.

Create a new profile, name it Home GSM for example. As the trigger select State -> Phone -> Cell Near. Press scan and take a walk inside you domesticity. Take your time, your phone scans for near GSM cells and measures there signal strength, this information is used to triangulate your position. When you think you are done, go back and create a new Task, name it Home On. Inside of it set a new variable %HOME to 1. Exit the newly created profile and add en exit task, name it Home Off and set the global variable %HOME to 0. You are done. Your profile should look like this:
Profile: Home GSM
 State: Cell Near [ Cell Tower / Last Signal:
      GSM:1234.56789 / 0
      GSM:1234.57719 / 2
      Ignore Cells:* ]
Enter: Home On
 A1: Variable Set [ Name:%HOME To:1 Do Maths:Off Append:Off ] 

Exit: Home Off
 A1: Variable Set [ Name:%HOME To:0 Do Maths:Off Append:Off ] 

Now we create a second profile, this one will check whether you are home for sure. Create a profile Check Home, it should be activated when the variable %HOME is set to 1. Create a new task, name it Check Home, inside of it place a wait for 1 or 2 minutes. After that place an if clause and check, whether the variable %HOME is still set to 1. If so, you are probably at home! To be even more sure, place another wait for 1 minute and afterwards another if to check if the cells near you match the pattern at your home. Make sure to set the collision handling of the task to Abort new Task and the cool down time to, lets say, 120 seconds in the Task Properties. Your finished task could look like this:
Profile: Check Home
 Priority: 5 CoolDown: 120
 Event: Variable Set [ Variable:%HOME Value:1 ]
Enter: Check Home
 A1: Wait [ MS:0 Seconds:0 Minutes:1 Hours:0 Days:0 ] 
 A2: If [ %HOME ~ 1 ]
  A3: Variable Set [ Name:%OUTSIDE To:0 Do Maths:Off Append:Off ] 
  A4: Notify Sound [ Title:Home sweet home! Text: Icon:ipack:iconedenthemeshd:twitter_8 Number:0 Sound File:/system/media/audio/notifications/S_Knock.ogg Priority:3 ] 
  A5: Perform Task [ Name:WiFi On Stop:Off Priority:5 Parameter 1 (%par1): Parameter 2 (%par2): Return Value Variable: ] 
  A6: Perform Task [ Name:LOG write Stop:Off Priority:5 Parameter 1 (%par1):Home Parameter 2 (%par2): Return Value Variable: ] 
  A7: Mobile Data [ Set:Off ]
  A8: Ringer Volume [ Level:5 Display:Off Sound:Off ] 
  A9: Variable Query [ Title:Start PC? Variable:%pcstart Input Type:Numeric / Integer Default:3665 Background Image:Pictures/Wallpaper/hi_tech_texture-wallpaper-1920x1200.jpg Layout:Question Yes No Timeout (Seconds):60 Show Over Keyguard:On ] If [ %WIFII ~R MyHomeWiFiSSID ]
  A10: If [ %pcstart ~ 3665 ]
   A11: WoL Wake On Lan Wan Settings[ Configuration:Home Package:com.benfinnigan.wol Name:WoL Wake On Lan Wan Settings]
  A12: End If 
 A3: End If 

As you can see I placed various other tasks I want to be run when I come home inside the if clause. For example I get asked to turn my computer on. I used the free app Wol Wake on Lan Wan from Brobble to do this, as it offers a Tasker plugin. In my actual Check home profile I placed all the got-home-goodness in a separate task I call within the Check home task. This way I can place a 15 minutes wait before asking about booting the computer without interfering with the original Check home task.

To learn more about Wake-On-Lan Packages and how you can use them to turn your computer on remotely please read one of the numerous guides on the internet, for example the short and nice guide HowTo Wake-On-Lan from Brobble and the very good article Access Your Computer Anytime and Save Energy with Wake-on-LAN on lifehacker from Adam Pash.

I hope some of you find this location check method useful and improve there android experience with this trick :) What tasks do you run automatically when you come home? Leave your ideas in the comments!


  1. Nice info. I recently switch my Home profile from using Location Net, to Near Cell also. I also have the WOL plugin which I get prompted to run when I arrive home. Great Blog.

  2. Very useful! thanks a lot. So far I just set my wifi on when I come home and set it off when I leave. :P

    1. nice one :D

      I found, that a check if you are NOT connected to your home wifi ("IF %WIFII !~R ")before setting %HOME to 0 in the exit task can improve your experience with this task even more.

      Sometimes its useful to add some GSM cells to the ignore list too..

  3. Amazing blog man. Keep it up! It makes my imagination run wild!

    1. i would like to have more time for this stuff, man :'(

  4. It's because of this blog that I actually picked up tasker. Can't wait to read about the ideas you come up with next!!

    1. I will start posting again now, sorry for the big break :((

  5. Thanks for the article. Anyway @Benny Linnik,
    I tried your suggestion too by adding if %WIFI ~ off
    But how do I add only if my wifi is off or disconnected from my home wifi? Because my WIFI can be on in the internet cafe!

    1. You can do the following:
      Make an if statement where you check for the following:

      If "Wifi Info" contains "Your WiFi Name" then
      "Do what you want" f.e. switch to home mode

      in tasker it will look like this:
      If %WIFII ~R MyWifiName
      I'm connected to my home network
      I'm not connected to it

  6. So what happens when you leave home? Since there is no exit task in your 'Check Home' profile. Wondering why you chose to use Event Context instead of State Context.

  7. This post is written in a very good way and entails a lot of useful information for me. I am glad to find a good way of writing the post. Kindly also discuss with my website. Exit intent technology