False Motion Reduction Controller - if at least 2 sensors detect motion within 60 seconds then trigger motion on virtual sensor


#1

I discovered webCoRE last night and love it, so much so I want to move most of what I had in legacy/various SmartApps into Pistons.

I currently use ZoneMotionManager to group my Downstairs and Upstairs Motion Sensors. The SmartApp monitors the sensors, and has a virtual Motion Sensor that it outputs to. It’s main use is for reducing false-motion activations, by only triggering motion if 2 or more motion sensors trigger within 60 seconds of each other.

I believe I have been able to get the principles in the code provided below, but I’m struggling on implementing the 60 second timer (as at the moment if moving between rooms as each sensor goes ‘inactive’ the virtual motion sensor will never trigger - I’m looking for an overlap period of 60 seconds.

Any help would be greatly appreciated.

Best wishes,
Guy


#2

Hmm… I wonder if the Age command would allow you to check the last time that a motion sensor was active. It keeps track of the time (in milliseconds) of the last Event for a device. But I don’t know if it differentiates between Active and Inactive…or just the last event.

The other way I could see this working would be if you Triggered on a motion sensor going to active and then saved the time of that event into a datetime variable. Then if you get another Trigger you could check against time that is stored in the variable and if it within a minute, you could set your virtual presence sensor to active.

The syntax is something like this:

Set variable Timestamp = addMinutes($now, 1)

Then to check you would use:

IF $now is less than Timestamp

Just know that initially the empty variable will equal the current date and time. So either realize that and run it thru a couple times or manually give it a value in the IDE for the piston.


#3

Hi Mike,

Thank you for your reply, I gave the Age command a go (after reading up here) and you were right - it doesn’t discern the difference between Active and Inactive.

Moving on to the Timestamp variable - coding was never my strong point. I’ve tried to implement it by declaring the variable at the start of the piston, however I’m at a bit of a loss on how to add the code into IF part.

Any help would be appreciated, but again - thank you for your help so far.


#4

So this is more along the lines of what I was thinking… This is the basic structure, but it would need to be expanded out in order to fully realize what you’re trying to accomplish. (I don’t have as many motion sensors as you…so I had to improvise a bit with the devices).

Anyway, my thought is that the first time motion is triggered by one of these devices (or the first time in a while one of these devices becomes active) then the piston will run through and the $now is before Timestamp will evaluate to false. Which will then set a value in the Timestamp variable for 60 seconds into the future.

Then if you get a second motion event from any of the devices it will run through the same piston but this time the second IF block would evaluate to True if any of the motion sensors turned active in less than 60 seconds. That way you’d know that you had 2 motion events in less than 60 seconds. Then you could set your virtual motion sensor on.

I’m not doing anything at all with Inactive because I really didn’t know how you wanted to handle that. Meaning what has to happen to determine that you want to set the virtual sensor back to Inactive .

I’m not expecting this to be the final solution…but rather another iteration towards your ultimate goal. But at least you can now see a bit more about the idea that I had in mind.


#5

Hi Mike,

Thanks again for your help, I’ve gone ahead with your example and successfully implemented my desired use case (and in-turn removed another redundant SmartApp).

I have set the Motion Zone to go to ‘Inactive’ if all of the sensors are Inactive - which works well for my scenario of trying to reduce false activations.

My next step will be to set some kind of buffer to prevent my alarm going off during a power-outage - as my Aeotec Multisensor 6’s which are mains powered all trigger motion as soon as the power is restored!

Thanks again for your help - hopefully this thread proves useful for anyone else looking to replicate similar functionality.