How to update the configuration of an existing device via System.device

Hi everyone,
I am trying to update the configuration of an existing device using System.device utilities. I can some devices via script as mentioned in the System.device.addDevice document. Howerver, the system.device utility doesn’t have a function to get info of an existing device by the device name. There’s a function called system.device.getListDevices will return a read-only dataset of devices. You can see in the figure below.

Thank you for your time!

We don’t really have any functions for editing or even list the device configurations right now.

1 Like

Thanks for your reply.
Actually, I think I will delete then add a device again in the same script. It’s inconvenient but I think this trick will work.
If I don’t misunderstand, each device has a unique name. We can refer to a specific device by device name. I hope this feature will happen in the future.

1 Like

@Kevin.Herron Because we don’t have any update functions at the moment, I delete a device then add it with new props again in the same script. I wonder that the new device will be conflicted with the old device. What will happen if we delete a device? All information, historical tags will be deleted immediately or they still exist in the database.

Deleting a device is fine, none of your tag information or historical information is touched. This all happens in the OPC server, there is nothing linking the OPC tag to the server/device except the OPC Server and OPC Item Path tag properties. Just make sure you add it back with the same name.

1 Like

Thanks for your reply.
If I don’t misunderstand. Because the tags still exist, we must add a new device with the same name? Otherwise, the system will notify the error.

Yes, if you don’t use the same name when you add it all your OPC tags will have Error_Config because they will be pointing at OPC Item Paths that no longer exist.

1 Like

Thank you so much for your help.

Are there any ways to get a ModbusTCP configuration such as Prefix, UnitId, Addresses? Although we don’t have any functions for retrieving the device configuration, I wonder that we might do that if we write a custom module. I have looked into the ModbusTCPDriverSettings table in the local/data/config.idb file. I think there must be some ways to interact with that data.

Nothing supported. If you want to risk digging around in the internal db nobody will stop you.

1 Like

Just keep in mind that you can only run this from the gateway scope. I created a gateway message handler that ran this script and returned the result. Then I can use system.util.sendRequest from any scope to run the message handler and hence the query

1 Like