We don't want the values with bad quality to be added to the chunk_history
. We also need to return a value for all tags even if it's the last known value outside the start and end dates. We use includeBoundingValues=True
but it looks like the ignoreBadQuality=1
is then ignored. No option for last known value with good quality?
The tags are all setup like this:
Deadband Style Discrete
Deadband Mode Absolute
Sample Mode OnChange
Min Time Between Samples 1 Minute
Max Time Between Samples 1 Hour
# Loop through the folderPathArray in chunks
for i in range(0, len(folderPathArray), chunk_size):
chunk = folderPathArray[i:i+chunk_size]
# Query tag history for the current chunk
chunk_history = system.tag.queryTagHistory(
paths=chunk,
returnFormat="Tall",
startDate=startTime,
endDate=endTime,
returnSize=-1,
#includeBoundingValues=False, # ← Needs to be False so that random values are not added when there is no sample in the time specified.
includeBoundingValues=True, # ← Needs to be True so that all tags POST all the time???? But now you get Bad Quality samples, ignoreBadQuality is ignored.
aggregationMode="LastValue", # ← Only works with returnformat Wide?
ignoreBadQuality=1,
noInterpolation=1
)