Setting Mode upon unlock or open events

I have a cell phone based presence sensor for my son which generally works great… but being a teenager his cell battery commonly runs out, gets left at home, left at school, you name it. Therefore when he arrives at home, no presence is detected, my mode stay set as away and I’m getting false positive alerts when he triggers garage doors or locks or motion… etc. I haven’t found an easy pre-built smart app or routine that simply evaluates if a lock code has been entered or a garage door has been opened and sets the mode accordingly. In my case it needs to evaluate sunset/sunrise to get the mode as either night or home, respectively.
I thought I’d try writing some simple code to handle this but I’m absolutely terrible working with dates in groovy (or really any other language). Is there either an app already built that I can use or a way to compare the date of a successful open event coming from either a lock or door with the current status of the sun? Spent about 2 hours messing around with date parsing and I’m just positive there is someone more experienced that could get me heading in the right direction more quickly… if there is painfully simple groovy documentation you can point me to, fantastic… always happy to learn. Thanks in advance, the help is appreciated!

1 Like

Hey Dennis

Have you looked into Rule Machine in the Community Created SmartApps section? If it won’t do it now, Bruce is amazing and will get it done for you

Rick

3 Likes

Any reason you’re not trying this with Rule Machine? All the time logic is taken care of.

If there’s a small part it can’t handle, then I can easily add a Virtual Switch to represent that part of the Trigger or Conditions.

2 Likes

On my way to the Rule Machine and will let you know! Thanks for pointing me in the right direction… admittedly, part of the allure of SmartThings is the opportunity to “play with code” again so excited to also learn some things from the app too! Thanks a bunch.

2 Likes

Youza batman… @bravenel totally ROCKS!! I’m like a kid in a candy shop now. Pretty sure I’ve got enough flexibility to drive my family totally crazy for at least another month. Thanks to all for pointing me in the right direction here!!:grin:

1 Like