Logic Machine Forum
Logic Machine objects to file for ETS Import - Printable Version

+- Logic Machine Forum (https://forum.logicmachine.net)
+-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1)
+--- Forum: General (https://forum.logicmachine.net/forumdisplay.php?fid=2)
+--- Thread: Logic Machine objects to file for ETS Import (/showthread.php?tid=1126)



Logic Machine objects to file for ETS Import - gtsamis - 04.12.2017

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


RE: Logic Machine objects to file for ETS Import - Erwin van der Zwart - 04.12.2017

Hi,

Try this (:

.lua   Mail exported group addresses as CSV for ETS import compatible with SL FW 1_2_1 or HL FW 1_5_1.lua (Size: 3.9 KB / Downloads: 177)


BR,

Erwin


RE: Logic Machine objects to file for ETS Import - gtsamis - 04.12.2017

Thank you Erwin... 
As always fast and right to the point!


RE: Logic Machine objects to file for ETS Import - j.martinez@t-ingeniamos.com - 24.07.2019

(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,


RE: Logic Machine objects to file for ETS Import - Daniel - 24.07.2019

Probably you have some objects without name. You can delete them by mass delete - Delete unnamed objects.


RE: Logic Machine objects to file for ETS Import - j.martinez@t-ingeniamos.com - 24.07.2019

(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?


RE: Logic Machine objects to file for ETS Import - Daniel - 24.07.2019

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)



RE: Logic Machine objects to file for ETS Import - admin - 25.07.2019

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-to-access-gmail-by-pop-imap-2-1171882


RE: Logic Machine objects to file for ETS Import - j.martinez@t-ingeniamos.com - 25.07.2019

(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-to-access-gmail-by-pop-imap-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