Sync VS Async Operation


#1

I have a piston of the following format.

IF A changes to ON then Do something.X
IF B changes to ON then Do Something Y

It works 90% of the time. But every once in awhile it doesn’t function properly. I was able to determine that if A and B occur at the same time is when it doesn’t work. A only gets evaluated, B doesn’t.

If I change those to Async will that solve that problem? I read the WIKI but still not sure.


#2

Async means that both IFs should run simultaneously. In practice it cannot as only one task can run at one time but with async the second IF will not be dependent on the first to be evaluated.


#3

So with async even if both A and B occur at the same time they should both get evaluated.


#4

It might depend on what you’re doing in the piston. If the action when A is true takes a few seconds it is very plausible that when the piston handles the event for the second device condition B is now false. Changing the piston to allow parallel execution may help more than using async.

With no information about the actions you’re performing no one will be able to help. Please post a green snapshot of your piston.


#5

Condition B would not change back to false. Even if it did it would change back to true fairly quickly which would be fine. Here’s what the piston does. I am using it for presence checking. I look at my ST presence and Life360 presence. If either of them change to away then I set a virtual presence thing. I do the same for my wife’s. What I can see in events is that my virtual presence gets set but my wifes doesn’t even tho the ST and Life360 show gone. And the only time it happens is if that occurs the same time as mine does. Not often, but it does happen. In the attached piston it is the second and 4th IF’s that are affected. I did change them to async, but it might be awhile before I know if that solved the problem. As I said it only happens rarely. Most of the time, even if we are together, they don’t occur at exactly the same time. I figure if nothing else I can make them separate pistons.