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.

Min/Max last 24h
#2
You can try this way, log your object for a day and then use this script, change logaddress and pastTime as needed. 
Code:
logaddress = '32/1/3'
pastTime   = 60*60*1  --in seconds


addr = grp.find(logaddress)

time= os.time() - pastTime

objects = db:getall('SELECT dataraw, logtime, datahex FROM objectlog WHERE address =' .. addr.id .. ' AND logtime >'.. time )

local result, value = 0,0

    for _, objvalue in ipairs(objects) do
  value = busdatatype.decode(objvalue.datahex, addr.datatype)
 
        result = math.max(result, value)
   end
log(result) --max



    for _, objvalue in ipairs(objects) do
  value = busdatatype.decode(objvalue.datahex, addr.datatype)
      result = math.min(result, value)
   end
log(result) --min
------------------------------
Ctrl+F5
Reply


Messages In This Thread
Min/Max last 24h - by erikfluff - 17.10.2025, 08:52
RE: Min/Max last 24h - by Daniel - 17.10.2025, 10:11
RE: Min/Max last 24h - by erikfluff - 17.10.2025, 10:45
RE: Min/Max last 24h - by Daniel - 17.10.2025, 10:54
RE: Min/Max last 24h - by admin - 17.10.2025, 11:05

Forum Jump: