How to check for multiple triggers in a few seconds/minutes

I want to create a scene where the trigger is a motion sensor. When it executes, I need to check if the motion sensor has been triggered more than 3 times in the last minute, or some arbitrary number of times n the last X number of seconds.

Does anyone have any LUUP scripts that do this?

Hello,

I don’t think it’s possible whitout writting some Luup code.
It’s not exactlly what you’re searching for but it might help.

I written a small lua code I called “Virtual vigil”. The goal is to detect abnormal movement arround the house.

So here is how I made that :

  • I placed a detector in front and at the rear of the house.
  • Every time it’s armed and it detect a move, it will increment a value stored (mvt-AV or mvt-AR) à in a virtual container.
  • Each minute, an other scene will compare this number of move to the number 1 minute ago.
  • If move number exceed a value (here 4), it will increment a “the warning level”
  • Based on the warning level, some scene a triggered as turn on a light, move the camera, blink the alarm light , …

what still need to be coded :

  • Warning level automatically goes down if there is no motion during an amount of time
  • Warning level goes down based on some genuine action : turn off the alarm, …

Here is the code

Scene MouvementCounterAV (same for mvtAR)

local countAV = luup.variable_get("urn:upnp-org:serviceId:VContainer1","Variable1", 79) countAV = countAV + 1 luup.variable_set("urn:upnp-org:serviceId:VContainer1","Variable1",countAV,79)

Scene counter check :

local countAV = luup.variable_get("urn:upnp-org:serviceId:VContainer1","Variable1", 79) local countAR = luup.variable_get("urn:upnp-org:serviceId:VContainer1","Variable2", 79) local countAVLast = luup.variable_get("urn:upnp-org:serviceId:VContainer1","Variable3", 79) local countARLast = luup.variable_get("urn:upnp-org:serviceId:VContainer1","Variable4", 79) local alertLevel = luup.variable_get("urn:upnp-org:serviceId:VContainer1","Variable5", 79) local sensibAV = 20 local sensibAR = 4 local diffAV = countAV - countAVLast local diffAR = countAR - countARLast luup.variable_set("urn:upnp-org:serviceId:VContainer1","Variable3",countAV,79) luup.variable_set("urn:upnp-org:serviceId:VContainer1","Variable4",countAR,79) if diffAV >= sensibAV or diffAR >= sensibAR then alertLevel = tonumber(alertLevel) alertLevel = alertLevel + 1 luup.variable_set("urn:upnp-org:serviceId:VContainer1","Variable5",alertLevel,79) if alertLevel == 2 then luup.call_action("urn:micasaverde-com:serviceId:HomeAutomationGateway1", "RunScene", {SceneNum = "19"}, 0) elseif alertLevel == 3 then luup.call_action("urn:micasaverde-com:serviceId:HomeAutomationGateway1", "RunScene", {SceneNum = "20"}, 0) elseif alertLevel == 4 then luup.call_action("urn:micasaverde-com:serviceId:HomeAutomationGateway1", "RunScene", {SceneNum = "21"}, 0) end else if alertLevel == "2" then luup.call_action("urn:micasaverde-com:serviceId:HomeAutomationGateway1", "RunScene", {SceneNum = "19"}, 0) elseif alertLevel == "3" then luup.call_action("urn:micasaverde-com:serviceId:HomeAutomationGateway1", "RunScene", {SceneNum = "20"}, 0) elseif alertLevel == "4" then luup.call_action("urn:micasaverde-com:serviceId:HomeAutomationGateway1", "RunScene", {SceneNum = "21"}, 0) end end

And you also need to create a virtual container with the following value :
1 - Number of move at front
2 - Number of move at rear
3 - Last minute number of move AV
4 - Last minute number of move AR
5 - Warning level

Good luck with your project

I will add syntax for this to the “Request” list for my Program Logic Plugin [url=http://RTS-Services.com/Vera/Plugin/PL]http://RTS-Services.com/Vera/Plugin/PL[/url]

Sweet!

The reason I want to use this is because I have motion sensors outside my house. They used to just voice alert on the ELK and say motion detected in the back yard, but my wife hated it when they went off. And since they are outside, there are false positives.

I figure if I can trigger a voice alert after one gets tripped a few times within a time period, then it will cut down on the false positives and I may be able to re-enable the voice alert without getting yelled at. :slight_smile:

Edit: I don’t see this plugin in the app store. Where is it?

It’s now available from the APP store.