Create an OPC-UA Thing Schema
Example Schema
You need to define the Thing that is going to represent and store the data from selected nodes from the OPC-UA server.
The following is an example of a Thing schema that has two properties defined for
nodes present on the Milo demo server used in the discovery section:
{
"@type": [
"swx:opcua"
],
"actions": {
"readNodeValue": {
"input": {
"type": "string"
},
"title": "Read Node Value"
}
},
"events": {
"readNodeValue": {
"data": {
"type": "string"
},
"description": "",
"title": "Read Node Value Result"
}
},
"properties": {
"config": {
"properties": {
"auth": {
"type": "string"
},
"endpoint": {
"type": "string"
},
"intervalData": {
"type": "integer"
},
"mode": {
"type": "string"
},
"policy": {
"type": "string"
}
},
"type": "object"
},
"ns=2;s=Demo.Dynamic.Float": {
"@type": "float64",
"readOnly": true,
"title": "RandomFloat",
"type": "number"
},
"ns=2;s=Demo.Dynamic.Int32": {
"@type": "int32",
"readOnly": true,
"title": "RandomInt32",
"type": "integer"
}
},
"title": "OPC-UA Thing"
}
Important parts of this schema are:
- The
@type
needs to have an item with valueswx:opcua
. Without it, the OPC-UA Device Driver will not process the schema. - The
config
property (of type object) is used to set various OPC-UA configurations (see below). - The other two properties are configured to subscribe to specific nodes on the OPC-UA server.
- The
readNodeValue
Action and Event can be used to manually retrieve a value from any OPC-UA node on the server.
OPC-UA Config Property
The config
property is of the type object and can have various child
properties that are used for the OPC-UA configuration. The endpoint
is required.
The following property keys are allowed (see OPC-UA Driver):
- Basic
-
endpoint
(required): this is the endpoint of the OPC-UA serverinterval
(optional; default 30000): the subscription interval in milliseconds
- Advanced
-
mode
(optional; defaultauto
): the security mode to use, available optionsauto
,None
,Sign
,SignAndEncrypt
policy
(optional; defaultauto
): the security policy to use, available optionsauto
,None
,Basic128Rsa15
,Basic256
,Basic256Sha256
,Aes128_Sha256_RsaOaep
,Aes256_Sha256_RsaPss
autogencert
(optional; defaulttrue
): auto generate a self-signed cert if no certfile/keyfile are specifiedcertfile
(optional): a public cert to use for communication with the endpointkeyfile
(optional): the private key of the public certauth
(optional; defaultAnonymous
): the authentication method for the connection to the server. Available options includeAnonymous
,Username
, andCertificate
"username
(optional): needed when authentication method is set to Usernamepassword
(optional): needed when authentication method is set to Username