added an initialization of the atomicState.eventBuffer if the eventBuffer is null when handling an event

This commit is contained in:
David Sulpy
2015-10-04 20:19:11 -05:00
parent 239f771ac1
commit f012419710

View File

@@ -341,6 +341,13 @@ def eventHandler(name, value) {
def eventBuffer = atomicState.eventBuffer
def epoch = now() / 1000
// if for some reason this code block is being run
// but the SmartApp wasn't propery setup during install
// we need to set initialize the eventBuffer.
if (!atomicState.eventBuffer) {
atomicState.eventBuffer = []
}
eventBuffer << [key: "$name", value: "$value", epoch: "$epoch"]
log.debug eventBuffer