A SmartApp that had been running for a couple of months now stopped working after last weekends maintenance. While debugging there were no errors reported but I noticed that an atomicState attribute was not holding the correct value. In the initialize() function I set atomicState.count =0 . When a switch is turned a subscribed function is called where the attribute is incremented. So far so good.
When I reinitialize the app, the log shows this attribute has been reset to zero in the initialize() function but the old/previous value appears in the subscribed function when a switch is turned on.
I replaced all atomicState with state and the app preformed as expected. I reverted back to atomicState but now I get an error when I try to increment the attribute value. (code in question see below)
Anyone else having issues with atomicState or does anyone know what changes have been made?
def initialize() {
atomicState.currentCount=0 as Integer
atomicState.arrayCount=prefpresence.size()
subscribe(prefpresence, "presence", presenceHandler)
}
def presenceHandler(evt)
{
atomicState.currentCount=atomicState.currentCount+1 // No longer works. Error can't add null+null
log.debug "Event presenceHandler. Total Presence: $atomicState.arrayCount Current Presence Reporting: $atomicState.currentCount Name=$evt.name value=$evt.value"
if (atomicState.currentCount==atomicState.arrayCount) {
log.debug "Getting Current State"
getCurrentState()
atomicState.currentCount=0
}
}