This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Read from log.
#1
I'm using the db:getall function to read historical values from a GA. The point is to read a value that is one hour old and compare it to current value. but I'm getting an offset on several minutes. Is this just because there are no new value stored exactly one hour back from when I poll?
Reply
#2
Object log stores values only when they actually change. For your use case a scheduled script that saves current object value to storage should work better. This script can be adapted to store X latest values: https://forum.logicmachine.net/showthrea...26#pid1726
Reply
#3
(24.10.2023, 10:52)admin Wrote: Object log stores values only when they actually change. For your use case a scheduled script that saves current object value to storage should work better. This script can be adapted to store X latest values: https://forum.logicmachine.net/showthrea...26#pid1726

how would you access these values for comparing?
Reply
#4
Scheduled script that runs every minute. It will store latest 60 object values for the given address. oldvalue variable will contain the oldest entry in the list. It will be 1 hour long when the list accumulates 60 entries.
Code:
addr = '0/0/1'
key = 'values_' .. addr
max = 60

newvalue = grp.getvalue(addr)

storage.exec('lpush', key, newvalue)
storage.exec('ltrim', key, 0, max - 1)

oldvalue = storage.exec('lindex', key, -1)
oldvalue = tonumber(oldvalue)

log(newvalue, oldvalue)
Reply


Forum Jump: