Can I run a flow from within a script?

Post your questions and help other users.

Moderator: Martin

Post Reply
User avatar
Philip
Posts: 82
Joined: 08 Jun 2015 19:20
Location: Hampshire, UK

Can I run a flow from within a script?

Post by Philip » 07 Nov 2016 22:41

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...)
--
Philip

natong
Posts: 80
Joined: 29 Aug 2015 05:24

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

Post by natong » 08 Nov 2016 03:33

I love and prefer these commands too. Ability to Execuse/Stop/Enable/Disable Flows in the script.

User avatar
Martin
Posts: 4468
Joined: 09 Nov 2012 14:23

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

Post by Martin » 08 Nov 2016 19:53

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

User avatar
Philip
Posts: 82
Joined: 08 Jun 2015 19:20
Location: Hampshire, UK

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

Post by Philip » 09 Nov 2016 10:22

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)?
--
Philip

User avatar
Martin
Posts: 4468
Joined: 09 Nov 2012 14:23

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

Post by Martin » 10 Nov 2016 20:30

Yes, that's the way. You can also check out an example like 'Countdown' in the Menu->Catalog in section 'Scripting'.

Regards,
Martin

Post Reply