I have a series of tags that store the last 10 days of totalized values (tag names Day0-Day9). At midnight I want to shift each of the totals down 1 tag to act as a rolling totalizer.
My plan of attack was to use system.tag.readAsync to read the tags and system.tag.writeAsync to write the values to their new locations post-shift.
system.tag.readAsync is pointed to the tags for Day0 -Day8
system.tag.writeAsync is pointed to the tags for Day1-Day9
I got it to work once and then it just threw an error saying that “Length of values does not match length of paths”. I confirmed in a query window that the read was not listing as many values as I was sending read requests for.
Code is as follows:
#basically a blank callback for writeAsynch def writeCallback(asynchReturn): i=0 #Callback for readAsync def checkValues(asynchReturn): values =  for qValue in asynchReturn: print qValue.value values.append(qValue.value) tagsRead = [ ... list of tags goes here (multiple 10 day totalizers and some other tags I'm shifting) ] tagsWrite = [ ... list of tags goes here ] #print len(tagsRead) #print len(tagsWrite) system.tag.readAsync(tagsRead, checkValues) #print len(values) #print values system.tag.writeAsync(tagsWrite, values, writeCallback)
What am I doing wrong?
PS: I’m planning to call this from a gateway script if that matters.