[RELEASE] Auto Off - Automatically turn off devices after set amount of time on

Auto Off

Hubitat app that turns off your devices after they have been on some time.

Details

The app allows you to select switches you want to be turned off automatically. Each switch is tracked individually but they all share the auto-off time setting. If you need different auto-off times for different switches, just add another instance of this app.

Use Case

I have a few lights in the house that always seem to be left on. Sometimes the bathroom lights are left on for a few hours and sometimes the basement lights are left on so long that I can feel the hot spots on the floor above.

I had RM rules to deal with this but since you can't reference the trigger device (yo @joe.roback), I ended up with a lot of copies of the same logic. That bothers an OCD hobgoblin.

This app is cleaner to maintain after a dealing with just few lights in the house. It also took me a few times to learn about 'Cancellable" actions in RM that are required if you use Delay to implement this. Anyway, this app makes it all very easy.

Import App Link

https://raw.githubusercontent.com/MFornander/Hubitat/master/apps/AutoOff/AutoOff.groovy

Screenshot

Versions

  • 1.0.0 (2020-05-21) - Initial release
  • 1.1.0 (2020-05-23) - Add invert (auto on), and master switch options
3 Likes

This looks great. I too have about a dozen different RM rules for turning closet lights off.
The only thing I would add would be a switch to disable the auto-off. I have a virtual switch for lighting automatons that when turned off the RM rules don't run due to a condition.

Is there way to set this up for seconds instead of minutes?

Sounds reasonable. Open up an "Issue" over at the GitHub repository and I'll see what I can do:
https://github.com/MFornander/Hubitat/issues

It's code so it could do that but to keep the implementation clean I request a single callback every minute from the hub and see if there is anything to be done. Making it seconds would require me to increase the callback frequency or to add more complexity in the code. You can open up an Issue over at the GitHub repository but to be honest I'm probably going to keep it super simple, low-frequency, and low hub resource use.

state.offList[evt.device.id] = now() + autoTime * 60 * 1000

could try removing the * 60 so it doesn't convert the time to minutes. Not sure what kind of issues may result from that though.

there does appear to be checks for a newer/older version to the github repo though, so that might throw some wrenches into things as well.

Great code OP. Definitely better than going through each device individually or setting up rules for each device individually

Won't work since the offList is only checked every minute.

Edit: I was going to give you a patch to increase the resolution to seconds using the cron-style scheduler but I'm seeing that it doesn't allow less than one minute between callbacks either. Hubitat wants apps to behave and not be too busy, so no luck, unless I refactored it to use runIn() that has seconds resolution. I thought about that but going to stay away from that rabbit hole for now.

Version 1.1: Add invert (auto on), and master switch options

Ping @jason and @mark.oswell

1 Like