24.10.2023, 11:08
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)