(edit: Just clean up, hopefully making it more clear)
In a child app:
settings['device'].each{singleDevice->
parent.mergeMaps([state:[state:'on', appId:2227, appType:'time', time:1706627961088]],singleDevice)
}
parent.logDeviceTable(settings['device'],'CHILD: ')
In parent app:
def mergeMaps(Map rightMap, singleDevice){
leftMap = atomicState.'devices'."${singleDevice.id}"
leftMap.putAll(rightMap)
atomicState.'devices'."${singleDevice.id}" = leftMap
logDeviceTable(singleDevice,'PARENT: ')
return
}
So the child calls the parent mergeMaps, does the merge, logs the result from the parent, then immediately after returning to the childa and logs it again. Logging the exact same atomicState, two results.
PARENT: [hue:[currentLevel:10, stopLevel:100, appType:time, appId:2227, startTime:1706575430463, stopTime:1706575440466, startLevel:10, priorLevel:13], state:[state:on, appId:2227, appType:time, time:1706627961088]]
CHILD: [hue:[currentLevel:10, stopLevel:100, appType:time, appId:2227, startTime:1706575430463, stopTime:1706575440466, startLevel:10, priorLevel:13], state:[appType:time, appId:2227, state:off, time:1706575440574]]
So the "state" key in the atomicState merges correctly with "on" in the parent, but then atomicState value does not carry back to the child app. (The timestamp shows it's getting is the old value.) Am I missing something? How do I get atomicState to sync?
Function logDeviceTable just does that - logs out the atomicState value. Nothing else.
def logDeviceTable(multiDevice,line){
multiDevice.each{singleDevice->
log.debug line + ' ' + atomicState.'devices'?."${singleDevice.id}"
}
}