25.07.2019, 08:28
(This post was last modified: 25.07.2019, 08:30 by j.martinez@t-ingeniamos.com.)
(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!!