Posts: 411
Threads: 103
Joined: Oct 2016
Reputation:
9
Hi
How to get table of all objects?
Or better how to obtain table of all objects which doesn't contain a specific tag?
I tried
grp.tag()
grp.tag({})
grp.tag('')
grp.tag(nil)
but with no luck
LM5Lp, firmware: 2018.08.22 and 2021.12.15, FlashSYS v2, ARMv7 Processor rev 5 (v7l), kernel 4.4.151 and 4.4.259
Posts: 940
Threads: 161
Joined: Jul 2015
Reputation:
33
28.02.2019, 14:15
(This post was last modified: 28.02.2019, 14:29 by buuuudzik.)
I think this could be a solution:
Code:
tag = "exclude"
objects = grp.all()
filteredObjects = {}
for _,o in ipairs(objects) do
if o.tagcache.find(tag) then table.insert(filteredObjects, o) end
end
You can also use db query:
Code:
tag = "exclude"
sqlQuery = 'SELECT * FROM objects WHERE tagcache NOT LIKE "%" .. tag .. "%"'
filteredObjects = db:getall(sqlQuery)
-- if you need a value then you must also decode a value based on datatype
for _, o in ipairs(objects) do
o.value = knxdatatype.decode(o.datahex, o.datatype)
end
Done is better than perfect
Posts: 411
Threads: 103
Joined: Oct 2016
Reputation:
9
Thank you. I missed grp.all() exists.
LM5Lp, firmware: 2018.08.22 and 2021.12.15, FlashSYS v2, ARMv7 Processor rev 5 (v7l), kernel 4.4.151 and 4.4.259