Posts: 411
Threads: 103
Joined: Oct 2016
Reputation:
9
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
Posts: 1764
Threads: 6
Joined: Jul 2015
Reputation:
117
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
Posts: 411
Threads: 103
Joined: Oct 2016
Reputation:
9
(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
Posts: 1764
Threads: 6
Joined: Jul 2015
Reputation:
117
Hi,
Yes also possible but i don’t see why that design is any better...
BR,
Erwin
Posts: 940
Threads: 161
Joined: Jul 2015
Reputation:
33
I think that better could be create some hoovering script which delete unnecessary logs
Done is better than perfect
Posts: 411
Threads: 103
Joined: Oct 2016
Reputation:
9
(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
Posts: 7769
Threads: 42
Joined: Jun 2015
Reputation:
447
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 '',
})
Posts: 411
Threads: 103
Joined: Oct 2016
Reputation:
9
(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
Posts: 411
Threads: 103
Joined: Oct 2016
Reputation:
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
Posts: 7769
Threads: 42
Joined: Jun 2015
Reputation:
447
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.
|