get_value() method is not returning value of the node,the type of the node is ExtensionObject

46 Views Asked by At

On using below code i am not able to get the value of particular node.

from opcua import Client, ua
server_url = "opc.tcp://localhost:4840"
client = Client(server_url)
client.connect()
try:
    node_id = "ns=1;s=data/OpcUaServer/channels/1/0_VALUES"
    node = client.get_node(node_id)
    data_value = node.get_data_value()
    print("Node Value:", data_value)
    print("Node Value:", data_value)
finally:
    client.disconnect()

Output received: Node Value: ExtensionObject(TypeId:FourByteNodeId(ns=1;i=1), Encoding:1, 5 bytes) <class 'opcua.ua.uatypes.ExtensionObject'> So my Client need to know the Extension Object. The Problem is I can't load the type definitions. After connecting and running client.load_type_defitnitions(),there is nothing to happen,the outout also recieved: Node Value: ExtensionObject(TypeId:FourByteNodeId(ns=1;i=1), Encoding:1, 5 bytes).I have searched many methods, but they have no effect. If anyone can help, thank you in advance.

1

There are 1 best solutions below

2
Schroeder On

load load_type_defitnitions works only for legacy servers. Some server doens't expose this infomartion anymore.

As the opcua library is not supported anymore, try switch to asyncua and use the syncclient.

There you can try load_data_type_definitions instead of load_type_defitnitions. If this doesn't work try to open a pr in github of asyncua and we try to help you there.