1

I have a problem with setting a value to a node in opcua from a python client. Infact I get an error when I use set_node(intValue) I obtain a Bad type mismatch. The code is:

time.sleep(1)
nodo = client.get_node("ns=1;i=68") 
nodo.set_value(0)
time.sleep(1)
nodo = client.get_node("ns=1;i=68")  
nodo.set_value(1) 

And the error that I obtain is: opcua.ua.uaerrors._auto.BadTypeMismatch: "The value supplied supplied for the attribute is not the same type as the attribute"s value." (BadTypeMismatch)

1 Answers1

3

You must match the correct ua type. To find the correct type you can use UAExpert, another test client or read the documentation of the server.

Possible types are

  • ua.UInt32
  • ua.Int32
  • ua.Int16
  • ua.UInt16
  • ua.UInt64
  • ua.Int64
  • ua.Byte (unsigned 8bit)
  • ua.SByte (signed 8bit)
  • ...

For example for UInt32:

nodo.set_value(ua.UInt32(1)) 
Schroeder
  • 749
  • 4
  • 10