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.

Object Logs - How to log changes only?
#1
Hi
I would like to login just changes. Not constant values.
Like: My meteo station sends information about twilight every 10 minutes. It's for security reasons and I don't want to change it. Unfortunately the value is logged every 10 minutes. But there're only two changes during a day.
Can I switch the logging behavior somehow?
What I described in the text above is just an example. The real situation is more complex and my log contains tenths of group objects of this type.

Thank you in advance.
LM5Lp, firmware: 2018.08.22 and 2021.12.15, FlashSYS v2, ARMv7 Processor rev 5 (v7l), kernel 4.4.151 and 4.4.259
Reply
#2
Hi,

Only way to do that is by using a second (virtual) object where log is enabled and only update that secondary object when value changes on the main object.

BR,

Erwin
Reply
#3
(12.03.2018, 16:11)Erwin van der Zwart Wrote: Hi,

Only way to do that is by using a second (virtual) object where log is enabled and only update that secondary object when value changes on the main object.

BR,

Erwin

Hmm I don't like this design. Can't I log values from script directly by some internal function or through direct database access?
LM5Lp, firmware: 2018.08.22 and 2021.12.15, FlashSYS v2, ARMv7 Processor rev 5 (v7l), kernel 4.4.151 and 4.4.259
Reply
#4
Hi,

Yes also possible but i don’t see why that design is any better...

BR,

Erwin
Reply
#5
I think that better could be create some hoovering script which delete unnecessary logsWink
Done is better than perfect
Reply
#6
(12.03.2018, 20:06)Erwin van der Zwart Wrote: Hi,

Yes also possible but i don’t see why that design is any better...

BR,

Erwin

Because it doesn't require hundred of additional virtual objects.

1. I create a script for tag "logme" which stores the object value into log
2. I uncheck the "log" checkbox.
3. I set tag "logme" at objects I want to log.

BTW This setup solves problem with readings logging too.

But whole solution depends on information how I can log value into "Object logs" from script?

Thank you
LM5Lp, firmware: 2018.08.22 and 2021.12.15, FlashSYS v2, ARMv7 Processor rev 5 (v7l), kernel 4.4.151 and 4.4.259
Reply
#7
From event script:
Code:
time, utime = os.microtime()
logtime = time + utime / 1000000

db:insert('objectlog', {
  src = event.srcraw,
  address = event.dstraw,
  logtime = logtime,
  datahex = event.datahex,
  eventtype = event.type:gsub('group', ''),
  sender = event.sender or '',
})
Reply
#8
(13.03.2018, 11:28)admin Wrote: From event script:
Code:
time, utime = os.microtime()
logtime = time + utime / 1000000

db:insert('objectlog', {
 src = event.srcraw,
 address = event.dstraw,
 logtime = logtime,
 datahex = event.datahex,
 eventtype = event.type:gsub('group', ''),
 sender = event.sender or '',
})
Perfect! Thank you.
LM5Lp, firmware: 2018.08.22 and 2021.12.15, FlashSYS v2, ARMv7 Processor rev 5 (v7l), kernel 4.4.151 and 4.4.259
Reply
#9
Thank you once again. This solution is perfect. It shrunk my log from 1 newly generated row every second to aprox. ten records per hour.
I've one additional question. I compare changes between new and old values by storing the old value into storage. It works. But isn't there any better option here? Like "event.oldvalue" member in event table? I haven't found it yet.
LM5Lp, firmware: 2018.08.22 and 2021.12.15, FlashSYS v2, ARMv7 Processor rev 5 (v7l), kernel 4.4.151 and 4.4.259
Reply
#10
Storage is perfectly fine since you need to compare not previously received but previously logged value. You can also query database for last logged value for this object but it will be bit slower.
Reply


Forum Jump: