Async Statements Executing Linear


#1

1) Give a description of the problem
(I have created a piston to slowly turn my lights off in an order when my location mode changes to sleep. I want certain lights to fade in an order, but I want certain lights to fade in parallel with others when the piston is executed. I have placed my async actions towards the bottom, and they still execute in a linear fashion once my sync actions are done executing )

2) What is the expected behaviour?
(I want the lights to fade in the order I put them for sync actions, but want the async lights to fade in parallel as soon as the piston is executed.)

3) What is happening/not happening?
(All sync actions execute first before async actions will begin to execute)

**4) Post a Green Snapshot of the piston!


#2

My apologies, but I would not recommend trying to fade multiple devices simultaneously here in webCoRE. (and definitely not using ASYNC!)

Currently, you are trying to push out 131 commands in 1 ½ minutes!
(it’s going to look clunky)


Here is how I recommend:

IF Sleep switch changes to on
Then
    Turn off 1st bulb
    Wait 20 sec
    Turn off 2nd bulb
    Wait 10 sec
    Turn off 3rd & 4th bulbs
    Wait 30 sec
    Turn off 5th bulb
    etc.
END IF

Note: With this method, TCP needs to be set to Never on all of the WITH blocks.


#3

I suspect ‘async’ doesn’t mean what you think.

When a task hits a ‘wait’ of five seconds or more the piston sets a wake up timer and then exits. When it wakes up it a new instance is created which fast forwards to where it was and then continues.

If a task is set to ‘async’ it will still run in the usual sequence and if it hits a long wait it will still set the wake up timer but the piston will move on to the next task instead of exiting. A new instance of the piston will be fired to finish off the async task in the background, as it were.

Fades can behave similarly to waits if they are long enough.

So the async tasks should still appear in the order you want them to start up.

That said @WCmore has explained why, drawing on his great practical experience, what you are attempting might not be the best idea.


#4

Thank you!