I have code that subscribes to motion detector activity and pushes it out via a web service.
With my Aeon multi-sensor, it re-triggers every 15 seconds. So if you are in the room for 10 minutes, you would get 80 messages.(40 active and 40 inactive).
Anyone have code that would filter the messages so that it requires you to be gone for 1 minute.
If there is constant motion for 6 hours, then no motion for 1 minute - there should only be 2 messages total sent. One active and one inactive
One option would be to have the activity on the motion sensor change the mode, and then have a separate smart app which changes the mode again after Inactivity. Then ignore all the activity that occurs during the mode that was set by the first activity.
So:
Current mode: Ready.
Motion occurs. Notify, and set mode to Motion Already Detected.
Ignore all motion if mode is Motion Already Detected.
If Inactive for 15 minutes, notify and change mode to Ready.
tgauchat
(ActionTiles.com co-founder Terry @ActionTiles; GitHub: @cosmicpuppy)
3
If this is done in a single SmartApp (alert and delay…), then you can use state or atomicState to maintain that “activate mode” instead of the global location.mode.
I wish SmartThings provided more globals (there’s only one – location.mode!), but at least we have persistent state within SmartApps and Device Handlers, and you can create Virtual Devices to store and share an attribute between SmartApps (e.g., you could have a Virtual Switch that turns the motion sensing “off” for any number of motion alerting SmartApps that first check that Virtual Switch…).
Mode filtering is built into a lot of SmartApps and the Dashboard Solution Apps … for better or worse. It means that if you add any modes, you may have to edit the configuration of some or all of the SmartApps to accommodate the new mode.
Couldn’t you store the last motion timestamp? When there is motion, calculate now - last motion. if over 60 seconds, do alert and update last motion timestamp. if less then 60 only update timestamp
probably, that is why I am looking for some example code of how that might be done in Groovy / IDE. Right now I have code that ships out data I care about to my server (running C#) for processing and I can send commands back into the hub. I really just know enough about Groovy to do that. I would have (and still might) implement this logic on my side, but this is the more sensible place if I could make it simple and scalable to do.
This was really an implementation question more than a logic question.