Replying SMS with pre-determined location name based on GPS

wyxeroid

New member
I am a newbie with MacroDroid and I am impressed with its capabilities. Just started with my journey.
To start a more serious and useful macro, I would like to create one with the following requirements:

1. Mobile number of a family member will send me an SMS message: Ex: WRU?
2. The macro will receive the message and check or get my current GPS location (my mobile device)
3. It will verify the GPS location by comparing it to a pre-determined list of locations (array variable)
4. If found from the list, the macro will send the corresponding location name and not the coordinates
5. If it is not found it will use the GPS info and send a Google Map link instead.

What I have started so far:
Variables:
Text_msg (string) - stores the msg and checks if it matched the exact msg; If matched will trigger the action
Source_no (string) - stores the contact number of the sender
Auth_source (2-dimensional array) - predetermined values; reference matrix table to check the Source_no if it is included in the list;
Ex:
Auth_source(0)(0) = 1st mobile number
Auth_source(0)(1) = 1st family member name
Auth_source(1)(0) = 2nd mobile number
Auth_source(1)(1) = 2nd family member name
.. and so on and so forth.
If sender's number is found in the list. proceed to next action.

GPS_coords (string) - stores the current GPS location
Listed_loc (2-dimensional array) - predetermine values; reference matrix table to check the GPS_coords' value
Ex:
Listed_loc(0)(0) = 1st GPS coordinates entry
Listed_loc(0)(1) = 1st location description
Listed_loc(1)(0) = 2nd GPS coordinates entry
Listed_loc(1)(1) = 2nd location description
.. and so on and so forth.

The goal is for the macro to send back a reply to the sender reflecting the value taken from the second item of the Listed_loc variable.
If there's no match for the sender number, No response or action will be generated/executed.
If sender's mobile number matched but the GPS_loc is not yet listed in the table, send a Google Maps link instead based on the coordinates.

Triggers:
SMS from {v=Auth_source}
Matches: WRU?


Actions:
Share Location
GPS_coords
....
....
I'm stuck. Not familiar yet how the comparison will take place..


Hope someone can lead me or assist me in accomplishing the task.

Thanks in advance.
 
Last edited:

Dm114

Well-known member
I am a newbie with MacroDroid and I am impressed with its capabilities. Just started with my journey.
To start a more serious and useful macro, I would like to create one with the following requirements:

1. Mobile number of a family member will send me an SMS message: Ex: WRU?
2. The macro will receive the message and check or get my current GPS location (my mobile device)
3. It will verify the GPS location by comparing it to a pre-determined list of locations (array variable)
4. If found from the list, the macro will send the corresponding location name and not the coordinates
5. If it is not found it will use the GPS info and send a Google Map link instead.

What I have started so far:
Variables:
Text_msg (string) - stores the msg and checks if it matched the exact msg; If matched will trigger the action
Source_no (string) - stores the contact number of the sender
Auth_source (2-dimensional array) - predetermined values; reference matrix table to check the Source_no if it is included in the list;
Ex:
Auth_source(0)(0) = 1st mobile number
Auth_source(0)(1) = 1st family member name
Auth_source(1)(0) = 2nd mobile number
Auth_source(1)(1) = 2nd family member name
.. and so on and so forth.
If sender's number is found in the list. proceed to next action.

GPS_coords (string) - stores the current GPS location
Listed_loc (2-dimensional array) - predetermine values; reference matrix table to check the GPS_coords' value
Ex:
Listed_loc(0)(0) = 1st GPS coordinates entry
Listed_loc(0)(1) = 1st location description
Listed_loc(1)(0) = 2nd GPS coordinates entry
Listed_loc(1)(1) = 2nd location description
.. and so on and so forth.

The goal is for the macro to send back a reply to the sender reflecting the value taken from the second item of the Listed_loc variable.
If there's no match for the sender number, No response or action will be generated/executed.
If sender's mobile number matched but the GPS_loc is not yet listed in the table, send a Google Maps link instead based on the coordinates.

Triggers:
SMS from {v=Auth_source}
Matches: WRU?


Actions:
Share Location
GPS_coords
....
....
I'm stuck. Not familiar yet how the comparison will take place..


Hope someone can lead me or assist me in accomplishing the task.

Thanks in advance.
The detailed way you described your needs and solution to achieve is interesting. You obviously have a good idea of how to write your macro. On what specific point(s) would you need help?

According to the point of matching your current location with a list of predefined locations, I would just suggest to store them with a not too great precision by rounding them to avoid difficulties in matching (if you move a few meters away from the stored one).
 

wyxeroid

New member
The detailed way you described your needs and solution to achieve is interesting. You obviously have a good idea of how to write your macro. On what specific point(s) would you need help?

According to the point of matching your current location with a list of predefined locations, I would just suggest to store them with a not too great precision by rounding them to avoid difficulties in matching (if you move a few meters away from the stored one).
Yes, I'll check the MacroDroid Wiki. Thanks for the suggestion.
When approximating a predefined location using latitude and longitude coordinates, what is the typical and acceptable number of decimal places to use?

While I have a basic understanding of the concept of arrays, I'm struggling to apply it in MacroDroid. Specifically, I need help with checking a given value against an array list (such as item(0)(0)) and assigning the corresponding item(0)(1) as the target value to another variable. The task I assume will include the use of loop. These are the areas where I may require significant assistance.

Before asking for further help, I'll take a look at the MacroDroid Wiki to see if I can find the information I need. If I still have questions after reviewing it, I'll get back to you.
 

Dm114

Well-known member
When approximating a predefined location using latitude and longitude coordinates, what is the typical and acceptable number of decimal places to use?
I think the best way could be:
1⁰) Write down the right location (lat0,lon0)
2⁰) Move away eastward or westward from this location at a distance that seems acceptable to you (lat0,lon1)
3⁰) Same as 2⁰ but northward or southward (lat1,lon0)
4⁰) Deduce the appropriate rounding to apply to latitude and longitude.

According to arrays it's simple enough to use them: every item name is of the form Array_name[[n][m]]
 
Last edited:

MacroDroidDev

Administrator
Staff member
You could set up a number of geofences and then when you have obained a location use a series of IF ELSE such as

IF (Geofence in Area1)
Set variable text = Area1
ELSE IF (Geofence in Area2)
Set variable text = Area2
ELSE
Set varable text = location link (from magic text)
ENDIF
 

Dm114

Well-known member
You could set up a number of geofences and then when you have obained a location use a series of IF ELSE such as

IF (Geofence in Area1)
Set variable text = Area1
ELSE IF (Geofence in Area2)
Set variable text = Area2
ELSE
Set varable text = location link (from magic text)
ENDIF
I thought about Geofences but it seems that they don't always work fine (according to some threads on the forum -I personally don't need and don't use them). And, maybe, due the expectations of @wyxeroid, he needs some narrower and more accurate location...

Anyway, if Geofences fit his requirements, it'll be the simplest way for @wyxeroid
 

wyxeroid

New member
I'm currently in the process of refining this macro, and I want to express my gratitude to both Dm114 and MacroDroidDev for offering their assistance.

I agree that Geofences would be a viable option for me. I don't necessarily require a very precise location, but rather a broader area for tagging. For instance, I plan on tagging locations such as office buildings, malls, parks, hospitals, transport terminals, restaurants, and so on. Additionally, I'd like to include well-known landmarks that I may pass by while driving on the road. Therefore, Geofences seem like the best option to achieve this level of tagging.

Your willingness to help me not only speeds up my learning process but also encourages me to keep going. It's truly fulfilling to be a part of this forum, and I appreciate the inputs you are sharing to the members.

Thanks.
 

wyxeroid

New member
You could set up a number of geofences and then when you have obained a location use a series of IF ELSE such as

IF (Geofence in Area1)
Set variable text = Area1
ELSE IF (Geofence in Area2)
Set variable text = Area2
ELSE
Set varable text = location link (from magic text)
ENDIF
Thanks for the suggestion.
 

wyxeroid

New member
I have tried using the Share Location approach without applying Geofences for now, and I am already satisfied with the initial outcome.
While it may not be the most efficient solution, it meets my basic requirements.

Rather than filtering the mobile number of the sender, I opted to allow an SMS messaging from any number instead.
Will observe and see how it can still be improved.

This is my first MacroDroid macro, indeed.

WRU.png
 

Attachments

  • WRU_MacroDroid.pdf
    635.1 KB · Views: 4

Dm114

Well-known member
I have tried using the Share Location approach without applying Geofences for now, and I am already satisfied with the initial outcome.
While it may not be the most efficient solution, it meets my basic requirements.

Rather than filtering the mobile number of the sender, I opted to allow an SMS messaging from any number instead.
Will observe and see how it can still be improved.

This is my first MacroDroid macro, indeed.

View attachment 5011
Glad if it meets your requirements. Not bad at all for a 1st MD macro! 👍

For your loop, you could use Iterate Dictionary/Array action and replace your last 3 Set variable actions by 1 Clear variables action (it sets variables to 0, false or empty depending on variable types).
 
Top