My main automagic use is to handle home/personal automation tasks like acting on voice commands, speaking aloud reminders/info, turning on/off things, and accessing the net for news/weather/misc info.
To achieve this I use a couple dozen flows (along with a python backend server). Most of the flows call other flows. Sometimes 3+ levels deep.
To handle error conditions (e.g. a target device isn't responding to a http get command) I have a generic "Ooops, an error occurred" flow that says (aloud) what flow caused the error. The Ooops flow gets called from the flow where the error occurred. To know which flow this was, I set a global variable (e.g. global_prev_flow) in every flow where I might end up calling the Ooops flow.
Having to set the global variable in each flow works, but it's a bit tedious and I wonder if I've missed a more obvious/elegant way to do this?
Also... I wonder whether there's already an internal flow stack/list that could be exposed as a builtin variable (hi Martin) which could be more readily available for use?
I just noticed there's a previous topic (viewtopic.php?f=4&t=3793) that seems to be onto the same thing.
Built-in flow stack variable
Moderator: Martin
Re: Built-in flow stack variable
+1 for calling stack.
BTW, what is the python backend server?
BTW, what is the python backend server?
Re: Built-in flow stack variable
Hi,
you do not necessarily need to use a global var (global_prev_flow).
Simply use prev_flow (non global var).
https://automagic4android.com/en/help/c ... cute_flows
you do not necessarily need to use a global var (global_prev_flow).
Simply use prev_flow (non global var).
https://automagic4android.com/en/help/c ... cute_flows
Although this is not your main issue, maybe it helps.The executed flow will inherit the execution context with all variables of the parent flow.
Re: Built-in flow stack variable
I use cherrypy.org. It's basic but is lightweight, very reliable and handles JSON.beelze wrote:what is the python backend server?
Yes, I could. I recall having an absolutely brilliant reason for using global when I first designed the system - tho it escapes me now!Helios wrote:you do not necessarily need to use a global var (global_prev_flow). Simply use prev_flow (non global var).