Search code examples
pythonopc-uaextension-objects

Is there a function or method for decoding OPC-UA extension objects to readable form


UaExpert is displaying this array as follows:

enter image description here

Is there any way to decode this extension object to a readable form? My output is the following. I done some research and the question has been raised but I haven't found any examples. Using the dict function gets you part way there but some of the items are returned as bytes.

{'TypeId': NumericNodeId(ns=2;i=543214), 'Encoding': 1, 'Body': b'\x1b\x00\x00\x00External Application Closed\x13\x00\x00\x0025/01/2023 12:40:56\x05\x00\x00\x00dfius\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', '_freeze': True}

Solution

  • You can load the type definition with the following method:

    await client.load_type_definitions() 
    

    The complete Sample can be found here: