I have a rule that starts up my generator and that rule uses locks so that other rules in the same file don’t run at the same time and cause issues. I am running into a problem however because it looks like the timer part is outside of the lock.
2016-01-10 18:51:19.889 [INFO ] [g.openhab.model.script.Testing] - Generator Started - Locking
2016-01-10 18:51:20.057 [INFO ] [g.openhab.model.script.Testing] - Generator Started - Unlocked
I expected the lock to hold for 45 seconds, long enough for the generator to start, not less then 1 second.
rule "Generator Started"
when
Item Generator_Auto received command ON or
Item Generator_Override received command ON
then
logInfo("Testing", "Generator Started - Locking")
lock.lock()
try {
sendCommand(Generator_Start, ON)
generator_start_timer = createTimer(now.plusSeconds(45))
[
if (Generator_Status.state == CLOSED) {
sendCommand(Generator_Failed, OFF)
sendCommand(Generator_Cooling, OFF)
whenStarted = now // Start Clock
generator_load_timer = createTimer(now.plusSeconds(30))
[
sendMail("xxxxxxxxxx@mms.att.net", "Generator", "Generator Started, load at " + Buy_Total_Watts.state + " watts")
]
} else {
sendCommand(Generator_Failed, ON)
sendCommand(Generator_Override, OFF)
sendMail("xxxxxxxxxx@mms.att.net", "Generator", "Generator Failed to Start!!")
}
generator_start_timer = null
]
}
finally {
lock.unlock()
logInfo("Testing", "Generator Started - Unlocked")
}
end