Hmmmm, not getting a result here… Did the try/catch routine, and the designer likes it, but it doesn’t seem as though it’s actually caught and executed. Here’s what I have:
GARAGE_BIG_DOOR_TIMER = createTimer(now.plusMinutes(Garage_Big_Door_Timeout))
[|
logInfo("openhab","Garage big door door timer expired. Sending email.")
if (Garage_Big_Door_Reschedule_Multiplier == 1)
Mail_Subject = "Garage big door door was left open!"
else
Mail_Subject = "Garage big door door is STILL OPEN!"
var long Time_Difference_In_Minutes = (now.millis - Garage_Big_Door_Timer_Start_Time.millis) / 60000
Mail_Message = String::format ("Garage big door left open for %1$s minutes!",Time_Difference_In_Minutes)
sendMail(Mail_Destination,Mail_Subject,Mail_Message + " Raising, then attempting to shut.")
logInfo("openhab","Raising garage big door (to re-seat)")
postUpdate(GARAGE_BIG_DOOR_OPENER,OFF) // set status to OFF without sending physical command, so we can force send physical ON [open] command
sendCommand(VIRTUAL_GARAGE_ACTIVATE_COURTESY_LIGHTS,ON) // turn on the garage courtesy lights
sendCommand(GARAGE_BIG_DOOR_OPENER,ON) // open the door!
logInfo("openhab","Pausing garage big door rule for 45s")
// unconditionally pause 45s without launching a second thread
try { Thread::sleep(45000) } catch(InterruptedException e) {
logInfo("openhab","Resuming garage big door rule after pause. Closing door (to re-seat).")
postUpdate(GARAGE_BIG_DOOR_OPENER,ON) // set status to ON without sending physical command, so we can always send physical OFF [close] command!
sendCommand(GARAGE_BIG_DOOR_OPENER,OFF) // close the door!
}
Garage_Big_Door_Reschedule_Multiplier = Garage_Big_Door_Reschedule_Multiplier + 1
GARAGE_BIG_DOOR_TIMER.reschedule(now.plusMinutes(Garage_Big_Door_Timeout))
if (Garage_Big_Door_Reschedule_Multiplier > 5)
{
logInfo("openhab","***GIVING UP ON BIG GARAGE DOOR OPENER!*** Attempted to shut door " + (Garage_Big_Door_Reschedule_Multiplier - 1) + "times!")
sendMail(Mail_Destination,"Giving up trying to shut big garage door!","Attempted to shut garage door " + (Garage_Big_Door_Reschedule_Multiplier -1) + " times. Giving up!")
sendMail(Panic_Destination,"","Attempted to shut garage door " + (Garage_Big_Door_Reschedule_Multiplier -1) + " times. Giving up!")
GARAGE_BIG_DOOR_TIMER.cancel
GARAGE_BIG_DOOR_TIMER = null
}
]
What I’d expect to see in the log is that it opens the door, pauses for 45s, resumes execution, then shuts the door. But that’s not what I’m seeing; I see it pause, then… nothing:
2016-05-05 07:10:04.345 [INFO ] [g.openhab.model.script.openhab] - Garage big door door opened. Starting timer.
2016-05-05 07:10:04.386 [INFO ] [g.openhab.model.script.openhab] - Front courtesy light activated (courtesy light button), but it's daytime. Doing nothing.
2016-05-05 07:10:04.466 [INFO ] [g.openhab.model.script.openhab] - Side courtesy light activated (courtesy light button), but it's daytime. Doing nothing.
2016-05-05 07:10:06.360 [INFO ] [g.openhab.model.script.openhab] - Garage outside courtesy light activated ([garage] courtesy light button), but it's daytime. Doing nothing.
2016-05-05 07:10:07.297 [INFO ] [g.openhab.model.script.openhab] - Turning on garage interior courtesy light. ([all] courtesy light button)
2016-05-05 07:10:07.645 [INFO ] [g.openhab.model.script.openhab] - Garage lights turned on. Starting timer.
2016-05-05 07:12:06.217 [INFO ] [g.openhab.model.script.openhab] - Garage big door door timer expired. Sending email.
2016-05-05 07:12:08.193 [INFO ] [g.openhab.model.script.openhab] - Raising garage big door (to re-seat)
2016-05-05 07:12:08.654 [INFO ] [g.openhab.model.script.openhab] - Garage outside courtesy light activated ([garage] courtesy light button), but it's daytime. Doing nothing.
2016-05-05 07:12:08.945 [INFO ] [g.openhab.model.script.openhab] - Turning on garage interior courtesy light. ([garage] courtesy light button)
2016-05-05 07:12:09.006 [INFO ] [g.openhab.model.script.openhab] - Pausing garage big door rule for 45s
2016-05-05 07:12:09.236 [INFO ] [g.openhab.model.script.openhab] - Rescheduling garage interior courtesy lights by 5 minutes.
[after two minutes or so watching the garage cameras, I give up and manually shut the door myself.]
2016-05-05 07:14:42.633 [INFO ] [g.openhab.model.script.openhab] - Garage big door closed. Killing timer.
So… any ideas? Near as I can figure thread::sleep is in milliseconds, so 45K should be ~45s, +/- 100ms. (Heck even if it was +/- 10s it’d still be fine for my use!)