Tracking when nothing has happened for awhile

Continuing the discussion from Monitoring Elderly Parent - Need a little help and advice:

The original poster covered multiple topics under the eldercare umbrella, but I wanted to break this one out because I know people have addressed it in several different ways for other use cases.

I saw one that used a combination of delay (to set up a future action) and unschedule (to cancel that action), just as an example.

Anyway, this is just a request for your favorite ways to handle this type of situation regardless of the individual use case.

How would you send a notification after X hours of no motion detected on a specific motion sensor?

Tagging the following because I’m pretty sure they’ve all coded something along these lines before. :wink:

@baldeagle072 . @garyd9 , @geko , @rayzurbock , @tgauchat , @tslagle13 , @wackware

You probably need to monitor a number of sensors (motion, contact, etc.) and if neither of them is activated within specified period of time, trigger an alert (Push message, SMS, etc.). The easiest way to accomplish this IMHO, is to have a periodic task that runs say every 10 minutes and checks all the sensors in the group to see when the last state change has occurred.

initialize sets a runIn for n*3600 for handler “timeoutFunc”

events for whatever motion sensors to call an event handler “motionEvent.” That event handler just resets the runIn for n*3600 on handler timeoutFunc.

timeoutFunc sends the notification.

The problem with this is that ST tends to lose it’s mind on occasion, and timeoutFunc might never run. I suppose a cron-type schedule should also run that ensures that timeoutFunc is still scheduled. That should handle the case of the timeoutFunc disappearing.

Which sensors do you have in the house currently? Motion, presence, etc?

@chilidog01 ,

I hope you are monitoring this topic, just noodling around with custom coding ways to solve the use case you described. If you aren’t yourself a coder, no problem, just answer the use case questions that come up and the coders can get into the techie stuff.

BTW, here’s some of the code I was remembering that uses unschedule, but I don’t know if the author still participates in the community, this is from the old archives. It’s a “lights off” reset where the lights are supposed to go off after a certain period without motion, but if you move again, it delays the lights off request.

In this case, change “lights off” to some kind of notification process.

unschedule() is prone to TimeoutException errors, as discussed elsewhere. That’s why I suggested using periodic polling which seems more reliable, although still not 100%.

1 Like

Perhaps you could schedule a task however often you like (once an hour?) that checks all of your desired sensors for events over the last hour using myDevice.eventsSince() and if none have triggered, then send notification.

Thank you for your response. Last coding I did was either speakeasy or fortran IV ;^) Sorry for the long delay. I am using 2 ECO pirz motion sensors. They have a 4 min reset time.
I found an app for motion sensors on the smartphone app under eldercare that is designed to do what I want, i.e., notify if someone leaves one area for another area and doesnt return to the first area in a specific period of time. I tried to set it up and tested it but could not get it to send a signal. It appears that the sensors are sensors are seeing/not seeing appropriately. I opened a support ticket and am slowly working through the process. Expecting a live chat later this week which i hope will resolve it. I will post a followup when/if resolved.