This will only work if you are inside 1 geofence at a time.
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.
STEP 1 - GET GEOFENCE INFO
For every geofence you are currently inside of, you will see an element value of Inside within the %alstatusdesc() array. Notice that of my named geofences, I am currently inside the 5th element in that array. The name of THAT element is what we will be retrieving. The flash action was for testing purposes and will be deleted before starting the next step.
- Create a task and title it Query Geofence Name
- Add an AutoLocation Info task
- Select Geofence Statuses and make sure the Geofence Status box is checked
- Add a Flash action, select the tag icon and input %alstatusdesc()
- Run it
STEP 2 - DETERMINE GEOFENCE NUMBER
The value of %geofence_number should be the element number within the %alstatusdesc() array. The flash action was for testing purposes and will be deleted before starting the next step.
- Add a Variable Set action
- Use %geofence_number for the Name field
- Use %alstatusdesc(#?Inside) for the To field
- Add a Flash action and input %geofence_number and %alstatusdesc() with a space between the variable and array.
- Run it
STEP 3 - ESTABLISHING IF CONSTRAINTS
These If statements will check if the user is or is not inside a geofence. In the next step, we will fill in the actions for each condition.
- Add an IF action with %geofence_number in the left parameter, the = symbol as the operator, and 0 in the right parameter
- (Optional) Add a label and input: if User is NOT inside a geofence
- Add an Else action and tap the +
- Use %geofence_number in the left parameter, the != symbol as the operator, and 0 in the right parameter
- (Optional) Add a label and input: if User IS inside a geofence
- Add an End If action
STEP 4 - IF NOT INSIDE A GEOFENCE
Make sure that these two actions are between the If and Else If actions.
- Add a Flash action with the text: You are NOT inside a geofence!
- Add a Stop action
These actions will notify, via a flash action, that they are NOT inside a geofence and stop the rest of the task
STEP 5 - FIND AND RETURN GEOFENCE NAME
Make sure that these two actions are between the Else If and End If actions.
- Add a Variable Set action
- Use %geofence_name in the Name field
- Use %algeofences(%geofence_number) in the To field
- Add a Return action
- Use %geofence_name in the Value field
- (Optional) Add a label and input: Return Geofence Name to Parent Task
These actions will return the name of the geofence the User is inside of.
STEP 6 - CREATE THE PARENT TASK
You should see the name of the geofence you are currently inside of OR if you are not inside of a geofence, you will be told so with a flash action from the child task.
- Back out and re-open Tasker
- Create a task and title it Geofence Name Caller
- Add a Perform Task action
- Find and use the previously made task: Query Geofence Name for the Name field
- Use %name in the Return Value Variable field
- Add a Flash action and use %name in the Text field
- Run it
Get Geofence Name 1.0
Query the geofence name that you are current inside of within an android task.