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.

Logic Machine objects to file for ETS Import
#1
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
Reply
#2
Hi,

Try this (:



BR,

Erwin
Reply
#3
Thank you Erwin... 
As always fast and right to the point!
Reply
#4
(04.12.2017, 11:47)Erwin van der Zwart Wrote: Hi,

Try this (:



BR,

Erwin
 Thank you so much it is just what i am looking for.....But it always show me the next error:

Resident script:52: attempt to concatenate field 'name' (a nil value)
stack traceback:


What am i doing wrong?

Kind Regars,
Reply
#5
Probably you have some objects without name. You can delete them by mass delete - Delete unnamed objects.
------------------------------
Ctrl+F5
Reply
#6
(24.07.2019, 14:08)Daniel. Wrote: Probably you have some objects without name. You can delete them by mass delete - Delete unnamed objects.
Thanks for your help.

As you told me it was the reason.... i deleted the blank objects and now it didn't show the error but i never receive the email. I have receveid an "we have blocked a connection" from gmail and after that i activated the "no secure connection allowed"  in security page in gmail....but nothing.... i never received the csv file.
I tried with several gmail accounts and the same problem.
Any idea about it?
Reply
#7
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
Reply
#8
For Gmail you might need to enabled "less secure apps" for sending. Also try settings secure = 'tlsv1_2' instead of sslv23. You can also create a separate password for Gmail, see this guide: https://www.lifewire.com/get-a-password-...-2-1171882
Reply
#9
(24.07.2019, 16:34)Daniel. Wrote: 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)


Thank you very much Daniel!!!! It works properly!

(25.07.2019, 06:16)admin Wrote: For Gmail you might need to enabled "less secure apps" for sending. Also try settings secure = 'tlsv1_2' instead of sslv23. You can also create a separate password for Gmail, see this guide: https://www.lifewire.com/get-a-password-...-2-1171882

Dear Edwar,


I tried it quickly because the ftp way works and i have the CSV files downloaded yet. But i want to fix the email to send mails properly but i will deal with it later.

Thank you mate!! Cool
Reply


Forum Jump: