Hi Hubitat community,
First, I've got some background to a possibly clever solution for geriatric pet owners.
Problem statement: Our very old dog needs to be physically carried outside at random, and no longer sees/hears/barks or moves very fast. He knows he needs to go outside and gets up and walks around prior to doing so, but can no longer communicate that need. He sleeps 23.5h/day so when he wakes up from a nap he basically needs to go out within 2-3 minutes or he will have an accident. My wife and I both work from home most of the day, but sometimes we will be in a call or on a different floor of the house and not hear him wake up. The goal should be obvious, but ideally we can go let him out and avoid an accident.
Ideal solution: I can get a notification on my phone via the Hubitat app (or flash a light, have a smart speaker announce, etc.) when he wakes up after being asleep for more than 20 minutes and has been in motion for more than 2 minutes straight (meaning - he is walking and not just adjusting his sleeping position).
I am CLOSE to what I would consider ideal operation of it, but would appreciate some help with the rule machine tweaks. I am open to any/all suggestions if I've done this wrong. I already know how to set/send the various notifications so that is not an issue.
Scenario/Proposed Solution: I've got an Aqara zigbee vibration sensor (DJT11LM) paired and the community (Xiaomi/Aqara/etc) driver loaded so the sensor reports variables of tilt, motion, presence, accelleration, battery, temp, etc. I am only using the motion report of active or inactive to determine his movement, no other variables.
The sensor is attached to his collar (it is very small and light, he doesn't notice it). I realize it will kill a few batteries if used constantly, but don't really care as they are CR2032 and $0.75/ea. I am getting events logged when the sensor moves or stops moving so that is all working fine.
My initial rule basically had an action that would trigger when the motion sensor was "inactive" for 20 minutes, then became active for more than 2 minutes straight. It would then notify my phone via the Hubitat App.
This seems basically only tell me if he hasn't moved AT ALL for 20 minutes. I'm pretty sure I need some IF/THEN statement to eliminate false activity (dog adjusts his sleeping position, but hasn't stood up/woken up) from resetting the 20 minute counter.
Questions:
1) Should I be using the trigger event of the sensor being inactive for 20 minutes OR just use the inactive state as the binary trigger and deal with the 20 minute delay in an action?
2) If I'm dealing with the 20 minute delay in an action IF/THEN, what should I tweak about the syntax below?
3) What's the best/proper way to do this?
I'm toying with this as a new rule to use, but unsure if it will yield the correct result.
Instead of just trial and error I figured I'd post here in case anyone has a better solution or a similar use-case in the future when searching. VERY thankful to the community for any replies.