fixed the scheduling from throwing exceptions because it was using parenthesis when passing the handler method in to the scheduling method; ensured that the scheduler doesn't send empty events

This commit is contained in:
David Sulpy
2015-09-11 11:09:03 -05:00
parent 621bcfadd2
commit 7baad1c35e

View File

@@ -167,10 +167,6 @@ def subscribeToEvents() {
if (waterSensors != null) {
subscribe(waterSensors, "water", genericHandler)
}
if (canSchedule()) {
runEvery15Minutes(flushBuffer())
}
}
def getAccessKey() {
@@ -235,6 +231,8 @@ def installed() {
atomicState.grokerSubdomain = "groker"
atomicState.eventBuffer = [];
runEvery15Minutes(flushBuffer)
log.debug "installed (version $atomicState.version)"
}
@@ -317,7 +315,8 @@ def genericHandler(evt) {
// This is a handler function for flushing the event buffer
// after a specified amount of time to reduce the load on ST servers
def flushBuffer() {
if (atomicState.eventBuffer.size() > 0) {
log.trace "About to flush the buffer on schedule"
if (atomicState.eventBuffer != null && atomicState.eventBuffer.size() > 0) {
shipEvents();
}
}