I created this device handler out of a personal need. This is my first publication and I am new to Groovy so be kind please. I welcome tips/pointers/requests and all around constructive criticism. Particularly I am interested in a less costly way to monitor sunset/sunrise rather than constantly querying it as well as any tips on better “debug” methods/functions to keep from testing a debug variable then log information if its set. I program in .net and there is a #IF DEBUG directive that helps with that.
The purpose of this app is to trigger switches based on motion sensors activity detection. I know it sounds familiar but in my case I needed a “re-trigger safety” timeout to prevent switches from coming on right after being switched off.
Using Dan’s thingshield classes I added 7 motion detectors to my home with some HC SR505’s. They don’t have a re-trigger or sensitivity control on them for adjustments. I was having issued where I would flip a switch off and walk away and the sensor would detect motion and flip the light right back on using the smart lighting app. This is a particular problem for the above situation because of the second or so lag of motion triggers having to hit the cloud first, then come back down to the hub before turning on the switch. Almost every time a light was turned off it popped back on as someone walked away.
Rather than build a simple if motion then light on with the re-trigger safety I added options I wished were in the original smart lighting app as well as standard time of day, day of week and mode restrictions.
*Turn on switch(es) via single or multiple motion sensor triggers.
*Once a switch is turned off set a re-trigger safety time in seconds in which motion detection will not turn the light back on
*Options for what the re-trigger safety applies to e.g. switch manually turned off or auto off
*Include an inactivity timeout to turn the light back off
*Include options for what circumstances the inactivity timer will function. e.g. Light turned on by the smartapp, light
turned on physically, by any other smartapp etc…
*Ability to disable the rule to prevent its running so you don’t have to delete it to stop it.
*Ability to enable debugging to help troubleshooting.
*Time of day restrictions
*Day of week restrictions
TO DO: illuminance options. (dont have an illuminance thing yet)
I am sure in time I will add more triggers and things like light bulbs to turn on via motion just not in V1 yet.
Get the APP via GitHub Integration here:
Owner - flyerdp
Name - flyerdp-SmartThings
There is a Manager App: Motion Based Switch Control Manager with Retrigger Safety (Credit to Mike Maxwell for his way of implementing versioning in the manager app)
and a child app that I started out looking at other projects and ended up writing wholly on my own:
Motion Based Switch Control with Retrigger Safety Child
Only publish the Manager App.