Motion detection always ON... when it isn't?


#1

Hey Peeps,

In my security piston, it see movement (which works), then a WHILE loop is started and is supposed to wait untill motion stops. Problem is that it seems the WHILE doesn’t seem to know that motion has stopped and loops forever. I’ve used this waiting method in other pistons without issue. In the devices logs, the motion did stop… so why wouldn’t the loop see this?

Sure could use a good suggestion on this. :slight_smile:


#3

How long are you waiting to determine the while loop is going indefinitely? Only asking because some motion sensors ‘latch’ their motion for 30, 60, 90 seconds or more.With your wait 30 seconds in there, it may take a while for the motion to disappear.

Otherwise, logs would be helpful in determining why it’s not behaving the way you want it to.


#4

Sorry for the late response, I was in “New Years Mode” when you guys posted your reply.
Happy New Year!

So… what I’m trying to do is if there’s movement detected, the piston is supposed to sit there and wait until there’s no movement, hence the WHILE loop. I’ve used this WHILE loop in other pistons and have got the result I was expecting.

What I’m noticing this morning in testing is the motion is only active for 30 seconds, which is well within my loop actually finishing one cycle. BUT nothing happens when motion ceases. I believe the piston exits because the initial conditions no longer exist.

I thought that if I made TASK CANCELLATION POLICY in the IF statement to NEVER, then once the IF is running, it will go though all statements within it all the way to the bottom. It’s not. Everything is skipped once motion stops. I must be setting this the wrong way.

Here is the modded piston. I only get the initial “security started” message, the “loop started” message… then that’s it.


#5

Hopefully, you found a solution, but if not, I think it’s generally better to think about Waiting is in the opposite terms as: waking or Triggering. Any time you might write “while this action is happening”, instead write “if not the opposite” or “on the other action”. With no task cancellation and no async while, you’ll be stuck handling ‘motion is active’ (which it was when the piston executed). aborting execution when the state changes is very frequently a convenient shortcut.