BACnet device creation using system.device.addDevice()

Hi all,

Hoping someone can assist me, I am trying to create a tool to autoamte BACnet device drivers addition (I have many to add) and was hoping to automate the process using the scripting. I am unsure if the BACnet device driver supports the system.device.addDevice() method? If it is, is there any documentation on the headers (dictionary keys) for the device parameters?

Any help is appreciated.

Many Thanks,

MG.

That driver isn't listed under either system.device.addDevice() nor the DeviceProps Listing supplement.

I would think that's a documentation oversight.

1 Like

Yeah, I did try having a look. I am hoping it is possible as it would be a huge help. Unsure if there is any other documentation I can look at.

Unfortunately... this drivers awkward configuration dependency on a "Local Device" means it's not really supported in the scripting functions right now.

Ok, that's not quite right. It's not documented because it's a bit difficult due to the local device. You basically need to know a priori the ID of that local device setting from the internal DB, presumably by querying or viewing the internal DB.

But if you do know it, you can add the devices like normal:

dType = "com.inductiveautomation.BacnetIpDeviceType"
dName = "remoteDevice"
dProps = {
  "LocalBacnetDeviceSettingsId" : 5, # <-----------  Pay attention to this line
  "RemoteAddress": "asdf"
}
system.device.addDevice(deviceType = dType, deviceName = dName, deviceProps = dProps)

You can figure out the key names by looking at the BacnetIpRemoteDeviceSettings table.

2 Likes

Hi Kevin,

This worked perfectly thanks! For anyone reading this in the future the script I have tested in the script console is below.

testParameters = {
"LOCALBACNETDEVICESETTINGSID":"1",
"REMOTEADDRESS":"10.10.10.10",
"REMOTEPORT":"47808",
"REMOTEDEVICENUMBER":"100", 
"WRITEPRIORITY":"8",
"COVENABLED":"1",
"COVHEARTBEATINTERVAL":"5",
"COVSUBSCRIPTIONLIFETIME":"900",
"COVSUBSCRIPTIONTRETRYINTERVAL":"120",
"CONFIRMEDNOTIFICATIONSENABLED":"0",
"DISCOVERYTIMEOUT":"5"
}



system.device.addDevice(deviceName="BacNETIP_Test1", deviceType="com.inductiveautomation.BacnetIpDeviceType", deviceProps=testParameters)

As mentioned by Kevin view the internal DB to get your "LOCALBACNETDEVICESETTINGSID" from another device. For those who haven't before navigate to (http(s)://gateway:8088/web/status/sys.internaldb?6) and use

SELECT * FROM BacnetIpRemoteDeviceSettings

as your query. Any pre-existing devices will show, use the integer under "LOCALBACNETDEVICESETTINGSID".

  • REMOTEADDRESS is the hostname
  • REMOTEDEVICENUMBER is the BACnet ID

Hopefully this helps other, took my absolutely ages to get this right :grimacing:.

Thanks everyone for your help it's really appreciated!

2 Likes