Export flow with variable as target

General discussions about Automagic and automation in general

Moderator: Martin

yxd0018
Posts: 85
Joined: 05 Dec 2018 15:14

Export flow with variable as target

Post by yxd0018 » 12 Jan 2019 00:00

Hi, I have difficulty to export flow with variable as target. Hard-coded string works though. The docs say it support variable.

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

Re: Export flow with variable as target

Post by Desmanto » 12 Jan 2019 11:18

I try the variable and it is working fine. Probably your variable path is not valid. Try to check it using condition debug dialog.

Action : Script

Code: Select all

file = "/storage/emulated/0/Automagic/a.xml"
Condition : Debug Dialog
True, goto
Action : Export Flows/Widgets
Flow pattern list : pick your flow
Target File : {file}

Run the flow and check the {file} value in the debug dialog, to make sure it is valid. You can check yours too.
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.

yxd0018
Posts: 85
Joined: 05 Dec 2018 15:14

Re: Export flow with variable as target

Post by yxd0018 » 12 Jan 2019 12:48

I found the cause. Thanks, debug dialogue is very good. I wish someday I can run some pure language, like python or Java/JavaScript inside.

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

Re: Export flow with variable as target

Post by Desmanto » 12 Jan 2019 17:34

After last week diving deep trying to decipher some javascript, so I can mimic the HTTP post in Automagic; I would say running pure python/javascript language seems unlikely. Because those 2 are OOP, while Automagic scripting isn't. I am trying to create function using eval() and that already takes a lot of try and error to make it work.
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.

yxd0018
Posts: 85
Joined: 05 Dec 2018 15:14

Re: Export flow with variable as target

Post by yxd0018 » 14 Jan 2019 18:57

Thanks, is there a page to list all built-in variables? I try to use connected wifi condition. even I defined global var as list, but the condition doesn't get satisfied. The help page doesn't say much how to get connected ssid name out.

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

Re: Export flow with variable as target

Post by Desmanto » 15 Jan 2019 17:28

You mean to list all the variables names or the variable's values? Example, {ssid} or do you mean the wifi name? (hotspot1, office_1st, google_wifi).

To list all available but not used variable, simply tap the 3 dot menu at any element editing, Select variable and uncheck only available. By default, this is checked and only show available variable until this point of the flow.
To check the value, use debug dialog, that is the best way. But sometimes debug dialog is not practical for quick and unattended flow, that's why I made my variable logger flow : viewtopic.php?f=3&t=7285

While for certain menu, you can select any default or exisiting value. For example, wifi connected trigger, you can uncheck "all" and tap the ellipsis to pick any of the connected wifi in the past.
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.

yxd0018
Posts: 85
Joined: 05 Dec 2018 15:14

Re: Export flow with variable as target

Post by yxd0018 » 21 Jan 2019 17:42

I know the vars I defined. Is there a built-in variables? such as when wifi is connect, var {connected_wifi_name} means the AP name by default?
For your geofencing flow and my wifi flow, I extract some global list vars out to define home, office wifi names so I don't need to hard code it in every flow. ex:
global_home_wifi = newList("ap1", "ap2")
But when I use wifi connected condition, it always goes to false. I see nothing wrong in debug condition.
It works when I define var as string. In the docs, it says condition support var and list should work.

Also, in regular component, is it possible to use + to concatenate 2 string vars together as input argument? It seems not working that I have to use script component.
ex: existsFile() can only accept one var, no expression inside function. In export flow, the target can mix vars and string literals.
Last edited by yxd0018 on 21 Jan 2019 17:59, edited 1 time in total.

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

Re: Export flow with variable as target

Post by Desmanto » 21 Jan 2019 17:53

Built-in variables produced by the action? For condition wifi connected, there is {ssid} to give you the name of connected wifi name. You can find the the detail by tapping the help (question symbol), all provided variable will be there. Or more detail by using debug dialog.

Yes, you can predefine the wifi name somewhere. How do you use the global_home_wifi in the wifi connected? Since it is list, it must be put as comma delimited format.
{global_home_wifi,listformat,comma} at the SSID list field. And if your wifi name has comma inside, you have to quote it also
"{global_home_wifi,listformat,comma}"
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.

yxd0018
Posts: 85
Joined: 05 Dec 2018 15:14

Re: Export flow with variable as target

Post by yxd0018 » 25 Jan 2019 15:28

Sorry for late reply.
I guess there is no web page listing all built-in variable coming with automagic w/o any flow. I can figure out from debug condition. Thx.

I define list in a script which initialize all global vars like bleow.
global_home_wifi = newList("ap1", "ap2")
Then I use {global_home_wifi} in the target of wifi connected condition. But it always go to false. Debug shows the right value. If the var is a string, then it works. Are you able to use single list var in the wifi connected condition?

yxd0018
Posts: 85
Joined: 05 Dec 2018 15:14

Re: Export flow with variable as target

Post by yxd0018 » 25 Jan 2019 15:55

Another question is I have many flows running, each has one line in the notification bar. I heard for android 6+ the notification need to be persisted to make flow work. Is that true?

Post Reply