In this particular case, no. I am turning ON my tv via the Harmony Hub Remote, which then turns On a virtual switch, which then runs a Hello Home Mode which turns off my night table lamp, but does not actually do any mode changes in this case. I would like to have the light turned off with a 5 minute delay as I usually come into the bedroom at night and turn on the tv and get changed and still would like light for a few more minutes.
You can try this
@Mbhforum let me know if it does what you need.
Thanks! Seems to have worked. My only question is what does the Turn it ON or OFF mean? When I turn the tv off (thus turning off the Virtual switch), I was nervous that the light would turn back on because I saw in the logs below. Fortunately, it did not turn the light on after 5 minutes. I am curious though why it shows a schedule being set though.
c520ab61-e69d-44ab-9481-8d38fcbd43c9 3:09:24 PM: trace Scheduling ‘turnOnOffAfterDelay’ for InstalledSmartApp: c520ab61-e69d-44ab-9481-8d38fcbd43c9
c520ab61-e69d-44ab-9481-8d38fcbd43c9 3:09:24 PM: trace Deleting scheduled job ‘turnOnOffAfterDelay’ for InstalledSmartApp: c520ab61-e69d-44ab-9481-8d38fcbd43c9
c520ab61-e69d-44ab-9481-8d38fcbd43c9 3:09:16 PM: info Turning off.
@Mbhforum the on or off setting will allow the delay to turn something off or on, which ever you prefer.
I am not sure about the schedule, give me a sec, and i will see if i cannot fix that.
In my case, I want to turn the light off when the virtual switch is turned ON. Should I leave the “Turn it On or Off” enabled? It is now and seems to be working even though the log entries show some sort of schedule when I turn the Virtual Switch off too.
Yes, the virtual switch code was just added to accommodate your needs. the on or off is whether you want it to turn something on or off after a delay. i will clean it up some more and we will give it another go.
Thanks. So the default behavior is to “turn off” the switch and by enabling that option, it gives the ability to turn “on or off”?
So when the virtual switch is toggled either on or off, it causes a time delay to be scheduled. When the time is up, it will execute the selection (on or off) for the device chosen. If you need it to be just when the virtual switch is toggled on, let me know, i can do that too.
That is definitely what I need. However, it seems to be working fine the way it is now, so not sure why you would need to modify the code further?
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.
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.
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.
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
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.
@bravenel you were my hero when you made the motor controller. With rule machine you just hitted Legend
It works like a charm with Rule Machine!