What's the best pattern for *lack* of motion?


(Cam Soper) #1

I want to do a task after there has been no activity on a collection of motion sensors for a specific period of time. What’s the best pattern to accomplish that? I’ve come up with two:

  1. Subscribe to the inactive event. On inactive, use runIn() to schedule a method that checks in the future to see if there have been any state changes. If there have been NO state changes, do my task.

  2. Subscribe to both inactive and active. On inactive, schedule my task with runIn(). On active, unschedule my task with unschedule().

Which is the “right” way?

Thanks!


(Jordon) #2

I personally set up things like this in CoRE using method 2. I have triggers on true and false states. Allows for easier and better customization in my opinion. I hope this helps you out.