Posts: 187
Threads: 43
Joined: Jul 2015
Reputation:
2
Hi all,
Is there any already made script to export LM objects in CSV or XML format for ETS import?
Thank you in advance
George
Posts: 187
Threads: 43
Joined: Jul 2015
Reputation:
2
Thank you Erwin...
As always fast and right to the point!
Posts: 4639
Threads: 24
Joined: Aug 2017
Reputation:
207
Probably you have some objects without name. You can delete them by mass delete - Delete unnamed objects.
------------------------------
Ctrl+F5
Posts: 4639
Threads: 24
Joined: Aug 2017
Reputation:
207
You can use this script. It will save csv in to ftp main folder
Code:
-- Get all objects from DB
objects_table = db:getall('SELECT * FROM objects ORDER BY address ASC')
log(objects_table)
buffer = {}
mainvalue = -1
middlevalue = -1
subvalue = -1
-- Loop through objects_table
for _, object in ipairs(objects_table) do
address = knxlib.decodega(object.address)
addresstable = string.split(address, '/')
if mainvalue ~= addresstable[1] then
mainvalue = addresstable[1]
table.insert(buffer, '"Main Group ' .. addresstable[1] .. '","","","' .. addresstable[1] .. '/-/-"')
end
if middlevalue ~= addresstable[2] then
middlevalue = addresstable[2]
table.insert(buffer, '"","Middle Group ' .. addresstable[2] .. '","","' .. addresstable[1] .. '/' .. addresstable[2] .. '/-"')
end
if subvalue ~= addresstable[3] then
subvalue = addresstable[3]
table.insert(buffer, '"","","' .. object.name .. '","' .. addresstable[1] .. '/' .. addresstable[2] .. '/' .. addresstable[3] .. '"')
end
end
--Create attachment inside FTP server
src = 'Object export created on ' .. os.date('%Y-%m-%d %H_%M_%S') .. '.csv'
dst = '/home/ftp/' .. src
io.writefile(dst, buffer)
script.disable(_SCRIPTNAME)
------------------------------
Ctrl+F5