Is it possible to use a variable in trigger's configuration?
Let's say in "Timer" trigger - right now it should be defined manually. Is it possible to put a variable there and then change the variable at some other place/flow to adjust the trigger? Currently it says "incorrect value".
The same is for "location" trigger for example - I want to be able to dynamically define a location when "location" trigger can start a flow.
Currently it does not seem to be possible - if I put a variable instead of real coordinates, the system converts it to 0.0;0.0 straight away.
Or may it be considered as a feature request?
Thanks.
use variables in triggers - is it possible?
Moderator: Martin
Re: use variables in triggers - is it possible?
You can use the trigger "variable" and define those variables on other flows.
Take a look on this example on time variables: http://automagic4android.com/flow.php?i ... 6f42ed2b58
Take a look on this example on time variables: http://automagic4android.com/flow.php?i ... 6f42ed2b58
Re: use variables in triggers - is it possible?
em... looks like you did not get me...
I want to be able to use a global_variable in a trigger's configuration, not as a trigger itself.
Let's say I have two flows - flow1 asks a user something like "how often you want to be notified ...?" and when the user put X minutes - then the second flow2 is being called by each X minutes.
And the second flow uses "Timer" trigger to start itself each X minutes with global_variable as a parameter that had been defined in flow 1 instead of being hardcoded into a trigger as it is now.
I want to be able to use a global_variable in a trigger's configuration, not as a trigger itself.
Let's say I have two flows - flow1 asks a user something like "how often you want to be notified ...?" and when the user put X minutes - then the second flow2 is being called by each X minutes.
And the second flow uses "Timer" trigger to start itself each X minutes with global_variable as a parameter that had been defined in flow 1 instead of being hardcoded into a trigger as it is now.
Re: use variables in triggers - is it possible?
Most triggers don't allow variables since the triggers would need to be re-registered in the system when the variable is modified which does not work well for some triggers.
There's a special trigger Global Variable Date/Time that executes a flow when the time stored in the variable is reached. You can use this trigger to build a flow that's executed periodically in a user defined interval by setting the global variable to the next point in time with a script.
There's a special trigger Global Variable Date/Time that executes a flow when the time stored in the variable is reached. You can use this trigger to build a flow that's executed periodically in a user defined interval by setting the global variable to the next point in time with a script.
Re: use variables in triggers - is it possible?
Thank you for the Explanation, Martin.
Timer was just an example. Actually I faced this challenge when I was trying to create a flow for GPS positioning.
My wife is often get lost in "urban jungles" so I decided to create a flow for her to notify her when she reaches some place.
I just wanted to make it as user-friendly for her as possible which means NOT to make her change triggers, settings or anything so I thought it would be me who would send coordinates to her phone remotely.
I was going to use "Location" trigger with "interesting" coordinates being setup/changed dynamically.
However if this is not possible - I could probably use different approach to achieve this goal?
But waking up the phone each 10 seconds (because a bus could pass a great distance in one minute) in order to obtain the current coordinates and then perform some computations to calculate a distance between the current coordinates and the destination - well, it does not seem to be a really great solution.
Am I probably missing something?
As you said that a trigger needs to be registered and that's why they need to have a "static" config - isn't it possible to temporarily de-register a trigger, change its settings and re-register it back in the system?
Probably not now but may be it is something that could be considered for future releases?
Regards.
Timer was just an example. Actually I faced this challenge when I was trying to create a flow for GPS positioning.
My wife is often get lost in "urban jungles" so I decided to create a flow for her to notify her when she reaches some place.
I just wanted to make it as user-friendly for her as possible which means NOT to make her change triggers, settings or anything so I thought it would be me who would send coordinates to her phone remotely.
I was going to use "Location" trigger with "interesting" coordinates being setup/changed dynamically.
However if this is not possible - I could probably use different approach to achieve this goal?
But waking up the phone each 10 seconds (because a bus could pass a great distance in one minute) in order to obtain the current coordinates and then perform some computations to calculate a distance between the current coordinates and the destination - well, it does not seem to be a really great solution.
Am I probably missing something?
As you said that a trigger needs to be registered and that's why they need to have a "static" config - isn't it possible to temporarily de-register a trigger, change its settings and re-register it back in the system?
Probably not now but may be it is something that could be considered for future releases?
Regards.
Re: use variables in triggers - is it possible?
Theoretically it would be possible to do this for the location trigger but I'm not sure if this would match the expectation of the users in all cases.
The location methods offered by Android usually execute the 'entering' trigger when a location trigger is registered and the current location is within the defined area. So when you send the same location or nearly the same location to the device it would execute the flow again.
Maybe it would be possible to do something like this by creating a generic flow that imports the location flow and enables the flow:
-trigger 'SMS Received: All containing IMPORT FLOW!'
-action 'Dropbox Download Files: /flow.xml to /sdcard/flow.xml'
-action 'Import Flows/Widget: /sdcard/flow.xml'
-action 'Set Flow State: Enable {imported_flow_names,listformat,comma}'
I've never tested this but it should allow to execute almost anything on the remote phone.
Regards,
Martin
The location methods offered by Android usually execute the 'entering' trigger when a location trigger is registered and the current location is within the defined area. So when you send the same location or nearly the same location to the device it would execute the flow again.
Maybe it would be possible to do something like this by creating a generic flow that imports the location flow and enables the flow:
-trigger 'SMS Received: All containing IMPORT FLOW!'
-action 'Dropbox Download Files: /flow.xml to /sdcard/flow.xml'
-action 'Import Flows/Widget: /sdcard/flow.xml'
-action 'Set Flow State: Enable {imported_flow_names,listformat,comma}'
I've never tested this but it should allow to execute almost anything on the remote phone.
Regards,
Martin