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.

BACnet address mapping
#7
(08.05.2024, 13:50)admin Wrote: Using bacnet.scandevice() can be more convenient for reading many objects at once.

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).

Thank you Admin. Always glad to have you around for support.  Smile

Here the final script which worked nicely. I didn't mind to set datapoints for the temperature objects later manualy using mass edit as this was very easy.
in this script the part which creates the group addresses is commented because we only need this to run one time. 
Code:
require('bacnet')
--HVAC BACnet Server Name:AS219, IP: xxx.xxx.xxx.xxx, Device ID:1
device, objects = bacnet.scandevice(1)

for _, obj in ipairs(objects) do
  if obj.type == 'analog input' then
    index = obj.id
    name = obj.description
    value = tonumber(obj['present-value'])
   
      --Automaticaly create group addresses based on name and index
      --[[
      grp.create({name = name, address = '23/0/' .. index, datatype = dt.int32})
      ]]--
     
    grp.checkwrite(name, value)
    os.sleep(0.5)
  end
end
Reply


Messages In This Thread
BACnet address mapping - by Osvaldas - 12.12.2023, 10:40
RE: BACnet address mapping - by admin - 12.12.2023, 10:57
RE: BACnet address mapping - by Osvaldas - 20.12.2023, 14:19
RE: BACnet address mapping - by Daniel - 08.05.2024, 13:08
RE: BACnet address mapping - by admin - 08.05.2024, 13:50
RE: BACnet address mapping - by manos@dynamitec - 08.05.2024, 20:56

Forum Jump: