08.05.2024, 13:50
Using bacnet.scandevice() can be more convenient for reading many objects at once.
This script can be modified to create objects automatically using grp.create(). But if you need different data types you will need some extra logic to guess the data type from the name (description).
Code:
require('bacnet')
device, objects = bacnet.scandevice(1)
for _, obj in ipairs(objects) do
if obj.type == 'analog input' then
name = obj.description
value = tonumber(obj['present-value'])
grp.checkupdate(name, value)
os.sleep(0.1)
end
end
This script can be modified to create objects automatically using grp.create(). But if you need different data types you will need some extra logic to guess the data type from the name (description).