> For the complete documentation index, see [llms.txt](https://docs.heisenware.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.heisenware.com/~/changes/Q625pQNc0nXqVGPtyjAY/building-apps/integration/protocol-connectors/opc-ua-wip.md).

# OPC UA (WIP)

OPC Unified Architecture (OPC UA) is a platform-independent, service-oriented architecture that integrates diverse industrial automation systems. It provides a robust, secure, and scalable framework for connecting devices and transmitting data across various platforms. OPC UA's ability to standardise communication and ensure interoperability makes it an essential protocol connector in modern industrial environments.

Here is a practical example of how OPC UA can be used as a protocol in factory automation:

* An OPC UA server is installed on a central controller.
* Various production machines, equipped with OPC UA-enabled sensors and actuators, connect to the server.
* A manufacturing execution system (MES) acting as an OPC UA client retrieves machine statuses and production data for real-time monitoring and control. The OPC UA client in our case can be a machine with an [edge-connector](/~/changes/Q625pQNc0nXqVGPtyjAY/building-apps/integration/edge-connector.md) on it.

## Functions

### create

Constructs an OPC UA client instance.

<table><thead><tr><th width="153">Parameter</th><th width="83">Type</th><th width="99">Default</th><th>Description</th></tr></thead><tbody><tr><td>securityMode</td><td></td><td><code>'None'</code></td><td>One from <code>'unauthorized'</code>, <code>'None'</code>, <code>'Sign'</code> or <code>'SignAndEncrypt'</code>.</td></tr><tr><td>securityPolicy</td><td></td><td><code>'None'</code></td><td>One from <code>'Aes128_Sha256_RsaOaep'</code>, <code>'Basic128'</code>, <code>'Basic192'</code>, <code>'Basic192Rsa15'</code>, <code>'Basic256Sha256'</code>, <code>'Basic256Rsa15'</code>, <code>'Basic256Rsa15'</code>, <code>'unauthorized'</code>, <code>'None'</code>, <code>'PubSub_Aes128_CTR'</code> or <code>'PubSub_Aes256_CTR'</code>.</td></tr><tr><td>certificateFile</td><td>String</td><td></td><td></td></tr><tr><td>privateKeyFile</td><td>String</td><td></td><td></td></tr></tbody></table>

### listenToEvents

Reports about relevant events. You can use the `listener` box to connect a function to run on events.

### connect

Connects to an OPC UA server.

<table><thead><tr><th width="158">Parameter</th><th width="82">Type</th><th width="89">Default</th><th>Description</th></tr></thead><tbody><tr><td>endpointUrl</td><td>String</td><td></td><td></td></tr><tr><td>userIdentity</td><td>Object</td><td></td><td>Object that contains user identity information. All following parameters must be part of this object if utilised.</td></tr><tr><td><p>userIdentity.</p><p>username</p></td><td>String</td><td></td><td></td></tr><tr><td><p>userIdentity.</p><p>password</p></td><td>String</td><td></td><td></td></tr><tr><td><p>userIdentity.</p><p>userCertificate</p></td><td>String</td><td></td><td></td></tr><tr><td><p>userIdentity.</p><p>userCertificate</p><p>PrivateKey</p></td><td>String</td><td></td><td></td></tr></tbody></table>

### disconnect

### browse

Detailed browsing of the given browse path (non-recursive).

You can use the parameter `address` to navigate to the desired folder. The function shows the contents of the root folder as default. You can also specify the session with `sessionId`.

### readNode

Reads a variable.

Use parameter `address` for the node ID or a valid browse path. You can also specify the session with `sessionId`.

### readVariableValue

Reads the value of a variable.

Use parameter `address` for the node ID or a valid browse path. You can also specify the session with `sessionId`.

### monitorNode

Starts monitoring an item.

<table><thead><tr><th width="154">Parameter</th><th width="98">Type</th><th width="91">Default</th><th>Description</th></tr></thead><tbody><tr><td>address</td><td>String</td><td></td><td>Node ID or a valid browse path.</td></tr><tr><td>listener</td><td>Function</td><td></td><td>The connected function is automatically called upon time change.</td></tr><tr><td>options</td><td>Object</td><td></td><td>The options object can contain all the following parameters.</td></tr><tr><td><p>options.</p><p>sampling</p><p>Interval</p></td><td>Integer</td><td><code>1000</code></td><td>The sampling interval in milliseconds.</td></tr><tr><td><p>options.</p><p>queueSize</p></td><td>Integer</td><td><code>100</code></td><td>The maximum queue size.</td></tr><tr><td><p>options.</p><p>discard</p><p>Oldest</p></td><td>Boolean</td><td><code>true</code></td><td>Sets the policy for when the queue is full. Decides whether to discard the oldest or newest entries. Default discards the oldest entries.</td></tr><tr><td><p>options.</p><p>subscriptionId</p></td><td>String</td><td></td><td></td></tr></tbody></table>

### monitorValue

Starts monitoring an item value.

<table><thead><tr><th width="154">Parameter</th><th width="98">Type</th><th width="91">Default</th><th>Description</th></tr></thead><tbody><tr><td>address</td><td>String</td><td></td><td>Node ID or a valid browse path.</td></tr><tr><td>listener</td><td>Function</td><td></td><td>The connected function is automatically called upon time change.</td></tr><tr><td>options</td><td>Object</td><td></td><td>The options object can contain all the following parameters.</td></tr><tr><td><p>options.</p><p>sampling</p><p>Interval</p></td><td>Integer</td><td><code>1000</code></td><td>The sampling interval in milliseconds.</td></tr><tr><td><p>options.</p><p>queueSize</p></td><td>Integer</td><td><code>100</code></td><td>The maximum queue size.</td></tr><tr><td><p>options.</p><p>discard</p><p>Oldest</p></td><td>Boolean</td><td><code>true</code></td><td>Sets the policy for when the queue is full. Decides whether to discard the oldest or newest entries. Default discards the oldest entries.</td></tr><tr><td><p>options.</p><p>subscriptionId</p></td><td>String</td><td></td><td></td></tr></tbody></table>

### stopMonitor

Stops monitoring an item. Use the parameter `nodeId` to specify what to stop monitoring.

### writeNode

{% hint style="warning" %}
Does nothing at the moment.
{% endhint %}

### createSession

Creates a session.

### closeSession

Closes the session and all associated subscriptions. Use the parameter `sessionId` to specify which session to close.

### createSubscription

Creates a subscription.

<table><thead><tr><th width="182">Parameter</th><th width="94">Type</th><th width="88">Default</th><th>Description</th></tr></thead><tbody><tr><td>sessionId</td><td>String</td><td></td><td></td></tr><tr><td>options</td><td>Object</td><td></td><td></td></tr><tr><td><p>options.</p><p>maxNotifications</p><p>PerPublish</p></td><td>Integer</td><td>0</td><td>The maximum amount of notifications per time publishing.</td></tr><tr><td><p>options.</p><p>priority</p></td><td>Integer</td><td></td><td>The subscription priority from 0 to 255</td></tr><tr><td><p>options.</p><p>publishing</p><p>Enabled</p></td><td>Boolean</td><td>true</td><td>Enable or disable publishing.</td></tr><tr><td><p>options.</p><p>requestedLifetime</p><p>Count</p></td><td>Integer</td><td></td><td></td></tr><tr><td><p>options.</p><p>requestedMax</p><p>KeepAliveCount</p></td><td>Integer</td><td>10</td><td></td></tr><tr><td><p>options.</p><p>requested</p><p>PublishingInterval</p></td><td>Integer</td><td>1000</td><td>Interval in milliseconds for publishing.</td></tr></tbody></table>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.heisenware.com/~/changes/Q625pQNc0nXqVGPtyjAY/building-apps/integration/protocol-connectors/opc-ua-wip.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
