I originally created this task a long time ago out of annoyance. Whether I was home or not I was receiving a separate notification every time one of my lights would turn on/off, due to my home automation system. I had to do something about this because it was driving me nuts so I created a get geofence child task. With it, I configure larger projects like my workout log, and my daily report. I also configure smaller ones such as my home automation lighting notifications.
After a bit of thought there was no reason to be notified of a light’s status change while I was at home, for obvious reasons. I would however like to receive the notification when I’m NOT at home. Multiple geofences were already established, one of them named “Home”, for different Tasker Projects so I knew that if I could get that name into a variable, I’d be one step closer. I would then only have to use an if-statement to evaluate its value before either notifying me or not.
The “set of actions” provide a local variable “%geofence_name” to use within the aforementioned if-statement. I inserted them ahead of the actions that yielded the notification. I placed the notification bearing actions within the if-statement, meaning they would only execute if the argument evaluated to true and otherwise do nothing.
Get Geofence Name
The task ran smoothly and I never received notifications while at home again. I then copied that same set of actions into other tasks to use for other geofence-based Tasker profiles. It was bad programming practice to have duplicates of code in separate locations so I transferred this “set of actions” into its own task appropriately titled “Get Geofence Name”. I used the Tasker action “Perform Task” -> “Get Geofence Name”. The child task would return the geofence name to its parent task. I also made provisions for the situations when I’m not inside a geofence. Here are some simple pseudo code examples:
- This will only work if you are inside ONE (1) geofence.
- This task was created with the intention of being a child task. It would be called upon using the Perform Task action in the parent task.
- Does not require root access.
- Plugins/Extensions Required:
See my tutorial post with project XML HERE and see my video demonstration below. Enjoy!