Error during export objectlogs - bmodeco - 11.03.2017
I am logging several values in the objectlogs tab. When I try to export them I get the following error in a new safari-tab:
Error: /lib/genohm-scada/web/objectlogs/csv.lua:10: unexpected symbol near '='
Any ideas how to resolve this?
Thanks, Bart
RE: Error during export objectlogs - Erwin van der Zwart - 11.03.2017
Hi Bart,
Not sure, but it looks like you are using special sign in you object names and that might cause a error in the CSV notation.. are you using ' or '' signs or , in your object names?
BR,
Erwin
RE: Error during export objectlogs - admin - 12.03.2017
It's a bug in the FW, we will fix it in the next release.
RE: Error during export objectlogs - bmodeco - 12.03.2017
(11.03.2017, 22:51)Erwin van der Zwart Wrote: Hi Bart,
Not sure, but it looks like you are using special sign in you object names and that might cause a error in the CSV notation.. are you using ' or '' signs or , in your object names?
BR,
Erwin
Hi Erwin,
Only minus-sign nothing else.
I have attached a screendump.
Mvg, Bart
RE: Error during export objectlogs - bmodeco - 13.03.2017
(12.03.2017, 10:22)admin Wrote: It's a bug in the FW, we will fix it in the next release.
Hi Admin,
Any ideas how to get a logfile (csv) for a set of grpadresses?
I would need a 2 day logging of the weatherstation since it is giving wrong values (it is currently more than 50 degrees C in Belgium according to the station ) - need to send it to the supplier.
Best regards,
Bart
RE: Error during export objectlogs - Erwin van der Zwart - 13.03.2017
Hi Bart,
This script creates a csv of the object logs on your ftp folder:
Code: -- get past year data
logtime = os.time() - 60 * 60 * 24 * 365
-- list of objects by id
objects = {}
-- objects with logging enabled
query = 'SELECT address, datatype, name FROM objects WHERE disablelog=0'
for _, object in ipairs(db:getall(query)) do
objects[ tonumber(object.address) ] = {
datatype = tonumber(object.datatype),
name = tostring(object.name or ''),
}
end
-- csv buffer
buffer = { '"date","address","name","value"' }
-- get object logs
query = 'SELECT src, address, datahex, logtime, eventtype FROM objectlog WHERE logtime >= ? ORDER BY id DESC'
for _, row in ipairs(db:getall(query, logtime)) do
object = objects[ tonumber(row.address) ]
-- found matching object and event type is group write
if object and row.eventtype == 'write' then
datatype = object.datatype
-- check that object datatype is set
if datatype then
-- decode data
data = knxdatatype.decode(row.datahex, datatype)
-- remove null chars from char/string datatype
if datatype == dt.char or datatype == dt.string then
data = data:gsub('%z+', '')
-- date to DD.MM.YYYY
elseif datatype == dt.date then
data = string.format('%.2d.%.2d.%.2d', data.day, data.month, data.year)
-- time to HH:MM:SS
elseif datatype == dt.time then
data = string.format('%.2d:%.2d:%.2d', data.hour, data.minute, data.second)
end
else
data = ''
end
-- format csv row
logdate = os.date('%Y.%m.%d %H:%M:%S', row.logtime)
csv = string.format('%q,%q,%q,%q', logdate, knxlib.decodega(row.address), object.name, tostring(data))
-- add to buffer
table.insert(buffer, csv)
end
end
dst = '/home/ftp/logs.csv'
io.writefile(dst, table.concat(buffer, '\r\n'))
BR,
Erwin
RE: Error during export objectlogs - bmodeco - 14.03.2017
(13.03.2017, 22:46)Erwin van der Zwart Wrote: Hi Bart,
This script creates a csv of the object logs on your ftp folder:
Code: -- get past year data
logtime = os.time() - 60 * 60 * 24 * 365
-- list of objects by id
objects = {}
-- objects with logging enabled
query = 'SELECT address, datatype, name FROM objects WHERE disablelog=0'
for _, object in ipairs(db:getall(query)) do
objects[ tonumber(object.address) ] = {
datatype = tonumber(object.datatype),
name = tostring(object.name or ''),
}
end
-- csv buffer
buffer = { '"date","address","name","value"' }
-- get object logs
query = 'SELECT src, address, datahex, logtime, eventtype FROM objectlog WHERE logtime >= ? ORDER BY id DESC'
for _, row in ipairs(db:getall(query, logtime)) do
object = objects[ tonumber(row.address) ]
-- found matching object and event type is group write
if object and row.eventtype == 'write' then
datatype = object.datatype
-- check that object datatype is set
if datatype then
-- decode data
data = knxdatatype.decode(row.datahex, datatype)
-- remove null chars from char/string datatype
if datatype == dt.char or datatype == dt.string then
data = data:gsub('%z+', '')
-- date to DD.MM.YYYY
elseif datatype == dt.date then
data = string.format('%.2d.%.2d.%.2d', data.day, data.month, data.year)
-- time to HH:MM:SS
elseif datatype == dt.time then
data = string.format('%.2d:%.2d:%.2d', data.hour, data.minute, data.second)
end
else
data = ''
end
-- format csv row
logdate = os.date('%Y.%m.%d %H:%M:%S', row.logtime)
csv = string.format('%q,%q,%q,%q', logdate, knxlib.decodega(row.address), object.name, tostring(data))
-- add to buffer
table.insert(buffer, csv)
end
end
dst = '/home/ftp/logs.csv'
io.writefile(dst, table.concat(buffer, '\r\n'))
BR,
Erwin
Thanks Erwin!
How to get a group monitor, or device monitor - batistacaceres - 08.04.2017
This only work if I have objects, and if objects are mark as log.
If I want to get all traffic in knx without mark the log field, because there is some knx device that i have not control over it, and it send me each time some unknown data, that I have not in the object table.
I just want to send all trafic on KNX bus each 1 hour, even if I have not objects created in my LM5. Could it be posible???
RE: How to get a group monitor, or device monitor - Erwin van der Zwart - 08.04.2017
Hi,
You could try to enable auto object creation in the general settings and set the log policy to all objects.
This way there will be a object created when the telegram holds a valid KNX structure and the logging will be activated already because you log all objects including the new ones..
BR,
Erwin
|