python-3.xopc-uanode-opcua

Error message through data readout of an OPC UA node - AttributeError: 'str' object has no attribute 'time_low'


I want to read data from nodes via OPC UA. The ns and id are correct but when trying to read data from the node it throws an error during converting python UUID 6 field format to OPC UA 4 field format. The node is a variable but it has also two children enter image description here

here my code:

from opcua import Client

...

client.connect()

forceAS = client.get_node("ns=3;g=V:0.3.0.0.1")
meaForceAS = forceAS.get_data_value() # here I get the error

When trying to read the data from the node I get the following error:

C:\ProgramData\Anaconda3\lib\site-packages\opcua\ua\ua_binary.py in nodeid_to_binary(nodeid)
    315     elif nodeid.NodeIdType == ua.NodeIdType.Guid:
    316         data = struct.pack("<BH", nodeid.NodeIdType.value, nodeid.NamespaceIndex) + \
--> 317                Primitives.Guid.pack(nodeid.Identifier)
    318     else:
    319         raise UaError("Unknown NodeIdType: {} for NodeId: {}".format(nodeid.NodeIdType, nodeid))

C:\ProgramData\Anaconda3\lib\site-packages\opcua\ua\ua_binary.py in pack(guid)
    100     def pack(guid):
    101         # convert python UUID 6 field format to OPC UA 4 field format
--> 102         f1 = Primitives.UInt32.pack(guid.time_low)
    103         f2 = Primitives.UInt16.pack(guid.time_mid)
    104         f3 = Primitives.UInt16.pack(guid.time_hi_version)

AttributeError: 'str' object has no attribute 'time_low'

Can someone help me here? Thanks in advance!


Solution

  • You used the wrong identifier g= is GUID and s= is String Identifier

    forceAS = client.get_node("ns=3;s=V:0.3.0.0.1")