Page 1 of 1

Waiting for a condition to become true, new flow needed?

Posted: 30 Jul 2015 14:55
by snovvman
I created a flow that automatically turns on WiFi when power is plugged in, then waits a bit, then checks to see if the device is connected to the specified WiFi APs. If not, it turns off WiFi. This part works fine.

If it successfully connects to my specified AP, then goes to an action block to check if the power is *unplugged*, if yes, then it will turn off WiFi.

The intent is that, when I plug in my phone at night, WiFi will be turned on so the device can sync, etc. When I unplug in the morning, WiFi will be turned off.

The problem is that when it goes to the block that checks to see if the power is unplugged, it does not wait for the condition, but rather it simply checks and exits. Is there a "wait" or "wait until condition becomes true" function? Or, do I need to create a new flow that is triggered by power unplugged in order to turn off the WiFi?

Thanks.

Re: Waiting for a condition to become true, new flow needed?

Posted: 31 Jul 2015 06:09
by kintrupf
You'll need a new flow!

Re: Waiting for a condition to become true, new flow needed?

Posted: 31 Jul 2015 07:37
by Wibbly
If you want to do this in one flow, try a flow that uses the Power Source trigger, but have both the Connected and Disconnected versions of that trigger in the trigger block. It will fire when the selected power sources are connected OR disconnected - i.e. every time there is a change in power source. The flow can then determine the detail and act accordingly by using the Power Source Connected condition to test what's actually connected.

Re: Waiting for a condition to become true, new flow needed?

Posted: 31 Jul 2015 15:09
by snovvman
Wibbly wrote:If you want to do this in one flow, try a flow that uses the Power Source trigger, but have both the Connected and Disconnected versions of that trigger in the trigger block. It will fire when the selected power sources are connected OR disconnected - i.e. every time there is a change in power source. The flow can then determine the detail and act accordingly by using the Power Source Connected condition to test what's actually connected.
Your suggestion caused me to learn something new. The Power Source trigger was in fact what I previously used. When I select it, the Connected/Disconnected were exclusively selectable via radio buttons. I then realized that I can select both triggers via a checkbox in a different menu, which enacts the scenario you described. I'll give it a try. Thanks!

Re: Waiting for a condition to become true, new flow needed?

Posted: 31 Jul 2015 15:18
by snovvman
Follow up to my previous post, I was able to create a trigger with both Connected and Disconnected, but how do I branch from the trigger so that each condition will perform different tasks? As far as I can tell, I can create actions using the + coming off of the trigger, but there is no way for me to define whether the branch is for Connected or Disconnected. Thanks.

Re: Waiting for a condition to become true, new flow needed?

Posted: 31 Jul 2015 15:21
by snovvman
snovvman wrote:Follow up to my previous post, I was able to create a trigger with both Connected and Disconnected, but how do I branch from the trigger so that each condition will perform different tasks? As far as I can tell, I can create actions using the + coming off of the trigger, but there is no way for me to define whether the branch is for Connected or Disconnected. Thanks.
Do I use a condition Power Source block after the trigger to branch off to True/False?

Re: Waiting for a condition to become true, new flow needed?

Posted: 31 Jul 2015 15:22
by Wibbly
That sounds right, yes :)