Page 1 of 1

Can I run a flow from within a script?

Posted: 07 Nov 2016 22:41
by Philip
I've written a simplistic flow to flash the LED on my Nexus 6 (Flashlight On / Sleep 1s / Flashlight Off).

I would like to call this flow from within a loop in a script - the script would take the number of flashes as a parameter, and use the loop to call the flow that number of times (so I could, for example, get the LED to flash 5 times if a particular event occurred).

I've not tried writing any scripts in Automagic before, and I can't see how to call a flow from within a While loop. Any assistance appreciated.

(Also interested in any better ways to achieve what I'm trying to do, but this is primarily a learning exercise for me...)

Re: Can I run a flow from within a script?

Posted: 08 Nov 2016 03:33
by natong
I love and prefer these commands too. Ability to Execuse/Stop/Enable/Disable Flows in the script.

Re: Can I run a flow from within a script?

Posted: 08 Nov 2016 19:53
by Martin
Hi,

Scripts can not execute/stop/enable/disable flows. Scripts are mostly meant to modify variables but not to completely replace regular actions.

Regards,
Martin

Re: Can I run a flow from within a script?

Posted: 09 Nov 2016 10:22
by Philip
Thanks, Martin.

So to achieve my aim, I need to explicitly code the For/While loop within my flow (e.g. use an Action to set a counter to zero, then test its value in a Condition, use an Action to increment it within the loop and then go back to the Condition until it reaches its final value)?

Re: Can I run a flow from within a script?

Posted: 10 Nov 2016 20:30
by Martin
Yes, that's the way. You can also check out an example like 'Countdown' in the Menu->Catalog in section 'Scripting'.

Regards,
Martin