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.

Any way to delete all NON LM objects?
#1
Hello,

What I want to achieve: I want to set all names of my objects (knx) to exact names that are in my ets project, but the only way to do this is to delete the existing objects and import new ones. Problem is that there are very many objects and I dont want to delete them in small quantities - I want to delete them all at once and import all at once, here I face a problem: if I delete all my objects I will delete my LM created objects too and I have very many scripts and won't remember them all. Maybe there is a way to delete only knx objects from logicmachine?

Thanks, I hope those who read understood my point  Rolleyes
Reply
#2
Hi
You can do it like that
https://forum.logicmachine.net/showthrea...98#pid9898
BR
------------------------------
Ctrl+F5
Reply
#3
Thank You!
Reply
#4
Code:
123456789101112131415161718192021
data = io.readfile('/home/ftp/data.esf') if data then   lines = data:split('\n')   for _, line in ipairs(lines) do     props = line:split('\t')     if #props >= 5 then       addr = props[1]:match('[0-9]+/[0-9]+/[0-9]+$')       if addr then         name = props[2]:trim()         id = buslib.encodega(addr)         db:update('objects', { name = name }, { id = id })       end     end   end   os.remove('/home/ftp/data.esf') end
Is there any way to use this code with .json files instead of .esf? The reason is that .esf does not export knx objects which are not linked to anything and in addition it does not support some symbols from my language so instead of normal symbol it puts "?" in that place.
Reply
#5
Hi
You can try to use this tool to convert ESF text symbols in better format. http://openrb.com/convert/
BR
------------------------------
Ctrl+F5
Reply
#6
Yes I've tried it but it converts to other symbols not from my language so it's not really helping. If I import a clean .json file though, everything works perfectly - all symbols are in their places so I want a solution with .json file.
Reply
#7
Use this for JSON:
Code:
123456789101112131415
require('json') file = '/home/ftp/data.json' data = json.pdecode(io.readfile(file)) if type(data) == 'table' and type(data.objects) == 'table' then   for id, obj in pairs(data.objects) do     id = tonumber(obj.id or id)     if type(id) == 'number' and type(obj.name) == 'string' then       db:update('objects', { name = obj.name }, { id = id })     end   end   os.remove(file) end
Reply
#8
Thank You very much! I'll try it as soon as possible and report how it went Smile

P.S It works perfectly!
Reply


Forum Jump: