OPC Device Connection Status - Via Scripting

Good Morning -

I am running Perspective, 8.1.19. Looking to get the status of my OPC UA devices via a scripting so I can put it in a customer dashboard. I can get a listing of the device names easily enough using a script like this -

devices = system.opc.browseServer(opcServer, nodeId)
for device in devices:
	print device.getDisplayName()

but can't find a way to get the status of each of these devices (connected, connecting, etc.). Has anyone done this before?


Usually there is a 'Connected' OPC tag created with each OPC device.

Just monitor that tag and you should be good to go.

1 Like

Thanks @kyler.kamyszek, that's what I was looking for! Each connection is listed under the tag folder Gateway/Devices for anyone wondering.

1 Like

To answer in the context of the original quesion, system.device.listDevices() will return a dataset with the same information.


When I look in the tag browser, I do see System - > Gateway -> OPC ->Connections but I don't see devices listed here in the tags. I am looking to display the same information.

You have to create the tag and point it to the connection property.

Is there anyway to also get an enabled bit for if it's enabled in the gateway.

Just from the output of .listDevices(). The device itself can't give that information because its code isn't running at all when disabled, and therefore cannot respond to such a request.