How do I create "Zones", "Areas", whatever you would like to

General discussions about Automagic and automation in general

Moderator: Martin

Post Reply
Mikey1969
Posts: 3
Joined: 12 Mar 2019 17:47

How do I create "Zones", "Areas", whatever you would like to

Post by Mikey1969 » 12 Mar 2019 19:42

Hi all,
So I am migrating from using Llama for ringer profile control, since it is now apparently abandonware, and I've decided that from the reviews Automagic may be an even better tool.

I have figured out how to set up a ringer profile(I think) based on WiFi access points. I prefer this over cell tower location because I don't want my phone going silent just because I'm near work, or the movie theater, etc. In Llama, I just scanned all of the available WiFis and chose 'Add to Area', and then named the area. I had a 'Quiet Spaces' one for the movies, the doctor's office, church, etc., and I had a 'Home' one for, well, home. I also had a 'Work' one so that I could have it quieter than at home, but louder than the silent mode I used in 'Quiet Spaces'.

Anyway, is there an easy way to set this up, where I can add new WiFi SSIDs to each of these three areas as needed, to build my list?

Also, is there a way to see WiFi APs by their mac address? The University here also runs to medical clinics we use. They have the core parts of their Wireless network named the same, so I would add by mac address if I wanted a profile to apply one way at the University, but still go quiet at the doctor's office.

So I hope this all makes sense. Let me know if anything is unclear, and thank you!

User avatar
Desmanto
Posts: 1757
Joined: 21 Jul 2017 17:50

Re: How do I create "Zones", "Areas", whatever you would lik

Post by Desmanto » 14 Mar 2019 01:37

There is no similar function to scan and add to area in Automagic. But you can build a flow to do so.

Use trigger shortcut. Then add condition wifi available, the result of this are list of AP name including the bssid. You can then pop a input dialog to choose each of these wifi+bssid and assign them to each area tag. For the database, I thought about nested map-list. Sorry if this is quite confusing directly, but it seems that llama also use similar method, that you add each wifi one by one to the area you want, it just doesn't show the user what happen in the background.

The mapped result will be something like the script declaration of map-list

Code: Select all

wifidb = newMapFromValues(
"00-11-22-33-44-55", newList("Office", "Work"),
"66-77-88-99-11-22", newList("4th avenue", "Home"),
"aa-bb-cc-dd-ee-ff", newList("Surgery", "Quiet") );
Where the map key is the bssid of the wifi. Map value 0 is the wifi name, map value 1 is the area tag.

Later, when wifi connected, you can check based on the bssid, and see what is the tag. If it is work, then switch to certain profile, home switch to home and so on. Wifi name actually not need to be save, but better save it for future reference.
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), Resurrection Remix Official 7.0.2 20190512, Pie 9.0, Rooted.

Mikey1969
Posts: 3
Joined: 12 Mar 2019 17:47

Re: How do I create "Zones", "Areas", whatever you would lik

Post by Mikey1969 » 14 Mar 2019 01:51

OK, I'll give that a go. Thanks for this, it gives me a starting point. :-)

And yeah, that's how Llama worked. I would open up the 'Areas' tab, and a list of Wifi APs would populate, both by Mac address and by SSID name. I could then click on one, it would say 'Add to area' and list the areas, plus a "create" option. The mac address option was nice, because my wife works at a University that also runs our medical clinics and our hospital, so I would have it on "vibrate" at the doctor's office, and normal at her work(All of the SSIDs are named the same).

Hopefully I'll be able to build this, thanks for the hints.

lm089
Posts: 12
Joined: 22 Mar 2019 10:07

Re: How do I create "Zones", "Areas", whatever you would lik

Post by lm089 » 28 Mar 2019 16:22

Desmanto wrote:There is no similar function to scan and add to area in Automagic. But you can build a flow to do so.
Also coming from good old Llama I'm currently planing a similar flow. Thanks for your idea!
I'm currently wondering how I could store collected info in form of a map list, json file or whatever, and then later on read that info in etc.
I found an action allowing me to write to a simple text file, so probably I could use that.
But I can't find a way to open and read an existing file. Any hints?
OnePlus 6 (root, Stock Android Pie / OOS 9.x)

User avatar
Desmanto
Posts: 1757
Joined: 21 Jul 2017 17:50

Re: How do I create "Zones", "Areas", whatever you would lik

Post by Desmanto » 28 Mar 2019 17:03

You can save the info in global variable (glovar) for easier access. The data is not so big, so it is still ok to save in glovar.

But if you still need to keep it as file, you can save it in json format. Use toJSON()

Code: Select all

write = toJSON(wifidb);
then use {write} in action Write to File, uncheck append. Choose the file path to save the database, example /storage/emulated/0/Automagic/loc.txt

To read/load it up later in another execution, use Init Variable Text File. Choose the file path of the previously saved json. Then use script fromJSON() to convert it back to map object.

Code: Select all

wifidb = fromJSON(file_text);
You can reuse the {wifidb} then to check for the location/mac address of the wifi router.
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), Resurrection Remix Official 7.0.2 20190512, Pie 9.0, Rooted.

lm089
Posts: 12
Joined: 22 Mar 2019 10:07

Re: How do I create "Zones", "Areas", whatever you would lik

Post by lm089 » 28 Mar 2019 18:00

Great, that was exactly what I was looking for! Many thanks, once again ;)
OnePlus 6 (root, Stock Android Pie / OOS 9.x)

Post Reply