I've written an app for my own use and figured I'd share it. I originally wrote it for a certain other platform, then another platform (see? not the one you're thinking of), and finally re-wrote it for Hubitat and fixed some longstanding bugs I tolerated. I figured I'd share it with the community in case anyone has any use for it.
At its core, it's similar to most motion-based lighting apps, but none of them could do a couple things I wanted. They all could more or less turn one or more lights on with motion and off with an optional delay after motion stops, and so can this. But most of my rooms have multi-bulb fixtures, and I don't always want all bulbs on. I also don't want them all to turn on or back to a specific state if motion is detected but one or more of them (not necessarily all) is already on-- a weakness of most apps I've used. Finally, I wanted to dim the bulbs as a warning before turning them off (imitating what Hue lets you do, but I wanted my logic on Hubitat). My app solves this by:
- allowing you to choose one or more bulbs (generally a whole room)
- allowing you to choose a motion sensor (one you'd want to use to turn on/off those lights)
- when motion stops, remembering the on/off states (and dim level) of each bulb and only turning those that were previously on back on (and to the saved level) when motion resumes (if not prevented by restrictions configured in the app: mode, lux, time of day, etc.)
- dimming the lights for 30 seconds (or whatever you choose) before turning them off, restoring them to their previous state if motion resumes during this time (regardless of mode/time/etc. restrictions--you had them on in the first place, after all) or after this time (if not in a mode/time/etc. condition where "on" is restricted).
- some of the above are optional features, but I've really only tested it with them all on since that's why I wrote the app and what distinguishes it from most others, but the options are there.
Note: I primarily use smart bulbs and say "bulbs" throughout, but the same applies to smart dimmers, where it will remember each dimmer. It should also work with plain switches but I haven't tested that much and the benefit of this over stock apps there is questionable.
Here's the folder in my GitHub repo for this app. It's a parent-child app, so you'll need to add the code for both and then install the parent:
Or direct raw code links/URLs:
- Parent app: https://raw.githubusercontent.com/RMoRobert/Hubitat/master/apps/LightsOnMotionPlus/LightsOnMotionPlusParent.groovy
- Child app: https://raw.githubusercontent.com/RMoRobert/Hubitat/master/apps/LightsOnMotionPlus/LightsOnMotionPlus.groovy
Again, I've only used this for myself and probably haven't tested every single option, but it works well for me. Hopefully others find it useful too. Let me know if you notice any problems! I have a wishlist that I'm working on soon, including:
- Multiple sensors for turning/keeping on (right now only allows one) (added)
- Ability to add additional sensors to keep on but not turn on (added)
- Ability to choose different "on" settings for "night mode" and (and restore to either previous "normal" mode settings if run in "normal" mode when last run in night mode), while keeping the existing mode restrictions where nothing happens at all (finally, I'll be able to replace my bathroom webCoRE piston!) (added)
- Probably willing to take requests if I have any use for it too