Goodnight Home with lights off delay

Its fine, i just wanted to see if/why it was creating another schedule. I also cleaned it up a little to try to cause less confusion. Like i said, this app was written without a virtual switch, so i hacked it together to provide a quick fix. This code should be more proper. Let me know if it makes more sense and works.

Thanks. Still works, although when I turn the virtual switch off, it still shows that a schedule is created but then set to false after 2 mins, but never turns the light back on, which is the desired behavior in my case. Also, you improved the debug logging to include the virtual switch state. I think this is exactly what I need! Thank you. Once again, the community proves it’s faster than ST themselves. This product would be nothing without the community…

c520ab61-e69d-44ab-9481-8d38fcbd43c9 3:54:09 PM: debug turnOnOffAfterDelay: State: [startTimer:1423947125837], false
c520ab61-e69d-44ab-9481-8d38fcbd43c9 3:52:08 PM: trace Scheduling ‘turnOnOffAfterDelay’ for InstalledSmartApp: c520ab61-e69d-44ab-9481-8d38fcbd43c9
c520ab61-e69d-44ab-9481-8d38fcbd43c9 3:52:05 PM: trace Deleting scheduled job ‘turnOnOffAfterDelay’ for InstalledSmartApp: c520ab61-e69d-44ab-9481-8d38fcbd43c9
c520ab61-e69d-44ab-9481-8d38fcbd43c9 3:52:05 PM: debug Event Handler: switch: off, State: [startTimer:1423946986082]
c520ab61-e69d-44ab-9481-8d38fcbd43c9 3:52:05 PM: debug Virtual Switch Handler: switch: off
c520ab61-e69d-44ab-9481-8d38fcbd43c9 3:51:48 PM: info Turning off.

1 Like

So, tell me which scenario you need.
a) when i toggle the virtual switch on or off, set a time delay and turn the device off after x minutes.
or
b) when i toggle the virtual switch on, set a time delay and turn the device on after x minutes, and when i toggle the virtual switch off, set a time delay and turn the device off after x minutes.
or
something else?

It works! I am happy! My scenario is this:

When the Virtual Switch is turned ON, turn OFF the Light 5 minutes later. Nothing else…but it’s working, I just tested it. I do have the turn on and off enabled, and since it’s working, I see no reason to disable that setting.

Great, I am glad you have what you need. That’s what i love about SmartThings, you can tailor it to your exact needs.

Thanks. I probably could have coded it myself and it would have taken me 19 hours since I am not great at coding. Thanks again!

Ben - any update on this?

So…it still isn’t possible to add a delay to the goodnight routine :frowning:

Sure, just use Rule Machine to do it.

You can fire a trigger from the Goodnight Routine running, have it delay doing whatever it is you want to delay. This does not entail changing the Routine.

1 Like

@bravenel you were my hero when you made the motor controller. With rule machine you just hitted Legend :slight_smile:
It works like a charm with Rule Machine!

1 Like