There’s a smartapp built into ST for “Light Turn On Open/Close” (that can be found under “lights & switches.”
(The smartapp basically turns on a light for a configured length of time when a door is opened or closed.)
I’m wondering if something similar, but with more intelligence, exists (yet.) In particular:
I’d like the times to be based on sunset/sunrise (not on hard-coded times.)
The smartapp shouldn’t “turn on” the light (and then turn it off again after the duration) if the light was already on before the door was opened. (This really annoys my wife. She has a light on already for some other purpose, but if anyone comes through the door, the light turns off after 3 minutes.)
The portion of the smartapp that turns the light off after a duration should be canceled if the light/switch is messed with externally. (Worst case would be to have to turn the light off and back on again to cancel the timer. Better would be that the smartapp catches “on” commands from a switch to cancel the turn-off timer.)
Writing the above should be fairly simple for me, but I really hate re-inventing the wheel. I can’t FIND anything that does these things, but if someone else knows of one, please let me know…
Gary, This is a recurring question, with variations on the theme. You would need a SmartApp, not one of the built-in ones to do what you want, but this would be pretty simple. One common request is for a light not to turn off after x minutes if it was already turned on (presumably by someone turning on the switch). There is an example of this on at least two other threads. These apps, as you suggest, do “catch” the on commands, or discover the state of the switch to make the decisions.
I had a house guest who wanted to disable motion turning on a hall light so as not to wake toddlers. I wrote a very small app that disabled motion turning on the light if someone had turned it off with a switch.
If you need help getting this to work, PM me. There are several folks here willing to help you get going.
Gary, You just hit on the key to success in ST. Just try it. You’ll be amazed what you can do once you get past the puzzle nature of the beast. That, and read other people’s code…