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.

Log only objects changes / remove storage files
#1
Good evening,

I need some help regarding object logging.

I have some objects that frequently sends group writes even without a value change.
Those objects are logged on the LM's Object Log and I am ending up with a bunch of records without any changes.
Is there any way that the logging will only happen if the object changes it's value?

Also can someone point the storage file location in order to remove unused ones?

Thank you in advance
George
Reply
#2
The only solution that I see is that you create another object for each one you want to log and then filter the input value in an event script.

Add this to Common functions:
Code:
function checkupdate(sendto, mindelta)
  -- event value
  local newvalue = event.getvalue()
  -- current object value
  local curvalue = grp.getvalue(sendto)
  -- absolute delta between event and current value
  local valdelta = math.abs(curvalue - newvalue)
  -- send if delta value is large enough
  if valdelta >= mindelta then
    grp.update(sendto, newvalue)
  end
end

Create an event script for each object where you want to log only value changes. 1/1/1 is your "virtual" object which is logged, 2 is minimum delta between current "virtual" object value which causes new value to be sent. Adjust as needed.
Code:
checkupdate('1/1/1', 2)

As for storage, do you mean script storage? In newer releases it's stored in a separate database and there's no easy way to delete some of the entries unless you know all of their names. You can only do a full clear operation.
Reply
#3
(03.10.2016, 07:11)admin Wrote: The only solution that I see is that you create another object for each one you want to log and then filter the input value in an event script.

Add this to Common functions:
Code:
function checkupdate(sendto, mindelta)
 -- event value
 local newvalue = event.getvalue()
 -- current object value
 local curvalue = grp.getvalue(sendto)
 -- absolute delta between event and current value
 local valdelta = math.abs(curvalue - newvalue)
 -- send if delta value is large enough
 if valdelta >= mindelta then
   grp.update(sendto, newvalue)
 end
end

Create an event script for each object where you want to log only value changes. 1/1/1 is your "virtual" object which is logged, 2 is minimum delta between current "virtual" object value which causes new value to be sent. Adjust as needed.
Code:
checkupdate('1/1/1', 2)

As for storage, do you mean script storage? In newer releases it's stored in a separate database and there's no easy way to delete some of the entries unless you know all of their names. You can only do a full clear operation.
Thank you for the answer, unfortunately for object logging it doesn't seem optimized solution, probably i will switch to general logging where i can filter what and when to log it.
By the way, is there any way i could check objects previous state before the database update and without using storage?


For the second question I mean storage used by storage.get and storage.set
Thank you in advance
George
Reply
#4
Well, object log main purpose is to log all telegrams. If you want to log changes you can try using trends instead. Each event script is executed only after new value has been updated in the database, so you should use storage or another object if you want to get previous value.

New firmware has storage.keys funciton which returns keys for all known storage items.
Reply
#5
(03.10.2016, 09:14)admin Wrote: Well, object log main purpose is to log all telegrams. If you want to log changes you can try using trends instead. Each event script is executed only after new value has been updated in the database, so you should use storage or another object if you want to get previous value.

New firmware has storage.keys funciton which returns keys for all known storage items.

Is there any way to completely remove a storage key that not longer used?
Reply
#6
storage.delete(key)
Reply


Forum Jump: