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.
New in summer 2020: version 5.0 of the app is a complete rewrite you can read about in post 71 below with many new features, including unlimited "per mode" settings.
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/LightsOnMotionPlus5.groovy
(NOTE: Existing v4.x users should add 5.x child as new app, keep 4.x child installed, and upgrade the parent. Do not upgrade the 4.x child to a 5.x child, as 5.x is a complete rewrite and 5.x apps must be created new.)