Skip to content

OPC UA Writer Sink

Class: OPCWriterSinkBlockV1

Source: inference.enterprise.workflows.enterprise_blocks.sinks.opc_writer.v1.OPCWriterSinkBlockV1

The OPC UA Writer block enables you to write data to a variable on an OPC UA server, leveraging the asyncua library for seamless communication.

Supported Data Types

This block supports writing the following data types to OPC UA server variables: - Numbers (integers, floats) - Booleans - Strings

Note: The data type you send must match the expected type of the target OPC UA variable.

Node Lookup Mode

The block supports two methods for locating OPC UA nodes via the node_lookup_mode parameter:

  • hierarchical (default): Uses standard OPC UA hierarchical path navigation. The block navigates through the address space using get_child(). Each component in the object_name path is automatically prefixed with the namespace index.
  • Example: object_name="Roboflow/Crane_11" → path 0:Objects/2:Roboflow/2:Crane_11/2:Variable
  • Best for: Traditional OPC UA servers with hierarchical address spaces

  • direct: Uses direct NodeId string access. The block constructs a NodeId as ns={namespace};s={object_name}/{variable_name} and accesses it directly via get_node().

  • Example: object_name="[Sample_Tags]/Ramp" → NodeId ns=2;s=[Sample_Tags]/Ramp/South_Person_Count
  • Best for: Ignition SCADA systems and other servers using string-based NodeId identifiers

Cooldown

To prevent excessive traffic to the OPC UA server, the block includes a cooldown_seconds parameter, which defaults to 5 seconds. During the cooldown period: - Consecutive executions of the block will set the throttling_status output to True. - No data will be sent to the server.

You can customize the cooldown_seconds parameter based on your needs. Setting it to 0 disables the cooldown entirely.

Asynchronous Execution

The block provides a fire_and_forget property for asynchronous execution: - When fire_and_forget=True: The block sends data in the background, allowing the Workflow to proceed immediately. However, the error_status output will always be set to False, so we do not recommend this mode for debugging. - When fire_and_forget=False: The block waits for confirmation before proceeding, ensuring errors are captured in the error_status output.

Disabling the Block Dynamically

You can disable the OPC UA Writer block during execution by linking the disable_sink parameter to a Workflow input. By providing a specific input value, you can dynamically prevent the block from executing.

Connection Pooling

The block uses a connection pool to efficiently manage OPC UA connections. Instead of creating a new connection for each write operation, connections are reused across multiple writes to the same server. This significantly reduces latency and resource usage for high-frequency write scenarios.

  • Connections are automatically pooled per server URL and username combination
  • If a connection fails during a write operation, it is automatically invalidated and a new connection is established on the next write attempt

Retry Logic

The block includes configurable retry logic with exponential backoff for handling transient connection failures:

  • max_retries: Number of connection attempts before giving up (default: 3)
  • retry_backoff_seconds: Base delay between retries in seconds (default: 1.0). The delay doubles after each failed attempt (exponential backoff).

Note: Authentication errors (wrong username/password) are not retried as they will continue to fail.

Cooldown Limitations

Cooldown Limitations

The cooldown feature is optimized for workflows involving video processing. - In other contexts, such as Workflows triggered by HTTP services (e.g., Roboflow Hosted API, Dedicated Deployment, or self-hosted Inference server), the cooldown timer will not be applied effectively.

Type identifier

Use the following identifier in step "type" field: roboflow_enterprise/opc_writer_sink@v1to add the block as as step in your workflow.

Properties

Name Type Description Refs
name str Enter a unique identifier for this step..
url str URL of the OPC UA server to which data will be written..
namespace str The OPC UA namespace URI or index used to locate objects and variables..
user_name str Optional username for authentication when connecting to the OPC UA server..
password str Optional password for authentication when connecting to the OPC UA server..
object_name str The name of the target object in the namespace to search for..
variable_name str The name of the variable within the target object to be updated..
value Union[bool, float, int, str] The value to be written to the target variable on the OPC UA server..
value_type str The type of the value to be written to the target variable on the OPC UA server. Supported types: Boolean, Double, Float, Int16, Int32, Int64, Integer (Int64 alias), SByte, String, UInt16, UInt32, UInt64..
timeout int The number of seconds to wait for a response from the OPC UA server before timing out..
fire_and_forget bool Boolean flag to run the block asynchronously (True) for faster workflows or synchronously (False) for debugging and error handling..
disable_sink bool Boolean flag to disable block execution..
cooldown_seconds int The minimum number of seconds to wait between consecutive updates to the OPC UA server..
node_lookup_mode str Method to locate the OPC UA node: 'hierarchical' uses path navigation, 'direct' uses NodeId strings (for Ignition-style string-based tags)..
max_retries int Maximum number of connection attempts before giving up. Default is 3 with exponential backoff starting at 15ms..
retry_backoff_seconds float Base delay between retry attempts in seconds (doubles each retry). Default is 0.015 (15ms) for fast exponential backoff..

The Refs column marks possibility to parametrise the property with dynamic values available in workflow runtime. See Bindings for more info.

Available Connections

Compatible Blocks

Check what blocks you can connect to OPC UA Writer Sink in version v1.

Input and Output Bindings

The available connections depend on its binding kinds. Check what binding kinds OPC UA Writer Sink in version v1 has.

Bindings
  • input

    • url (string): URL of the OPC UA server to which data will be written..
    • namespace (string): The OPC UA namespace URI or index used to locate objects and variables..
    • user_name (string): Optional username for authentication when connecting to the OPC UA server..
    • password (string): Optional password for authentication when connecting to the OPC UA server..
    • object_name (string): The name of the target object in the namespace to search for..
    • variable_name (string): The name of the variable within the target object to be updated..
    • value (Union[string, float, boolean, integer]): The value to be written to the target variable on the OPC UA server..
    • value_type (string): The type of the value to be written to the target variable on the OPC UA server. Supported types: Boolean, Double, Float, Int16, Int32, Int64, Integer (Int64 alias), SByte, String, UInt16, UInt32, UInt64..
    • timeout (integer): The number of seconds to wait for a response from the OPC UA server before timing out..
    • fire_and_forget (boolean): Boolean flag to run the block asynchronously (True) for faster workflows or synchronously (False) for debugging and error handling..
    • disable_sink (boolean): Boolean flag to disable block execution..
    • cooldown_seconds (integer): The minimum number of seconds to wait between consecutive updates to the OPC UA server..
    • node_lookup_mode (string): Method to locate the OPC UA node: 'hierarchical' uses path navigation, 'direct' uses NodeId strings (for Ignition-style string-based tags)..
    • max_retries (integer): Maximum number of connection attempts before giving up. Default is 3 with exponential backoff starting at 15ms..
    • retry_backoff_seconds (float): Base delay between retry attempts in seconds (doubles each retry). Default is 0.015 (15ms) for fast exponential backoff..
  • output

    • error_status (boolean): Boolean flag.
    • disabled (boolean): Boolean flag.
    • throttling_status (boolean): Boolean flag.
    • message (string): String value.
Example JSON definition of step OPC UA Writer Sink in version v1
{
    "name": "<your_step_name_here>",
    "type": "roboflow_enterprise/opc_writer_sink@v1",
    "url": "opc.tcp://localhost:4840/freeopcua/server/",
    "namespace": "http://examples.freeopcua.github.io",
    "user_name": "John",
    "password": "secret",
    "object_name": "Line1",
    "variable_name": "InspectionSuccess",
    "value": "running",
    "value_type": "Boolean",
    "timeout": 10,
    "fire_and_forget": true,
    "disable_sink": false,
    "cooldown_seconds": 10,
    "node_lookup_mode": "hierarchical",
    "max_retries": 1,
    "retry_backoff_seconds": 0.015
}