diff --git a/openwrt/package/flukso/src/flukso.lua b/openwrt/package/flukso/src/flukso.lua index 93bc20b..339ac1c 100755 --- a/openwrt/package/flukso/src/flukso.lua +++ b/openwrt/package/flukso/src/flukso.lua @@ -78,14 +78,16 @@ function buffer(child, interval) return coroutine.create(function(meter, timestamp, value) local measurements = data.new() local threshold = timestamp + interval - local old_timestamp = 0 + local timestamp_prev = {} while true do - if meter ~= nil and timestamp > math.max(1234567890, old_timestamp) then measurements:add(meter, timestamp, value) end + if meter ~= nil and timestamp > math.max(1234567890, timestamp_prev[meter] or 0) then + measurements:add(meter, timestamp, value) + end if timestamp > threshold and next(measurements) then --checking whether table is not empty coroutine.resume(child, measurements) threshold = timestamp + interval - old_timestamp = timestamp + timestamp_prev[meter] = timestamp end meter, timestamp, value = coroutine.yield() end