Client¶
Canonical path: o6.client.Client
Root shortcut: o6.Client
Client
¶
Bases: _NativeClient
High-level OPC UA client.
Every request-issuing method returns a plain value when the client drives its
own event loop, and an awaitable when it runs on an external one; see
MaybeAwaitable. Operations on a client that is not
connected raise instead of silently doing nothing.
See the Client guide for the whole picture, and the tutorials for task-by-task walkthroughs.
Attributes¶
root
instance-attribute
¶
Node handle for the standard Root folder (i=84).
objects
instance-attribute
¶
Node handle for the standard Objects folder (i=85).
types
instance-attribute
¶
Node handle for the standard Types folder (i=86).
views
instance-attribute
¶
Node handle for the standard Views folder (i=87).
loop
property
¶
The asyncio event loop used by this client. Set at construction time, not modifiable afterwards.
onGlobalNotification
property
writable
¶
Registry of handlers for every notification this client's underlying connection produces (lifecycle, service calls, ...).
Use as a decorator, a callable, or a list, exactly like the
Server.on<category>Notification registries.
See Notification handler.
onLifecycleNotification
property
writable
¶
Registry of handlers for this client's own lifecycle notifications
(connection started/stopped), independent of onGlobalNotification.
See Notification handler.
onServiceNotification
property
writable
¶
Registry of handlers for this client's own service-call begin/end
notifications, independent of onGlobalNotification.
See Notification handler.
subscriptions
property
¶
A copy of the active subscriptions for this client, keyed by id.
defaultSubscription
property
¶
The clients' default subscription.
Raises RuntimeError when disconnected or when no default exists.
With connect(createDefaultSubscription=False), create a subscription
explicitly and pass it to monitor() or monitorEvent().
Functions¶
__init__
¶
__init__(
endpointUrl="",
loop=None,
*,
logger=None,
certificate=None,
privateKey=None,
trustList=None,
revocationList=None,
securityMode=None,
securityPolicy=None,
applicationUri=None,
username=None,
password=None,
allowNonePolicyPassword=False,
name=""
)
Create a new OPC UA client.
The constructor accepts the most commonly needed settings as keyword
arguments. Everything else — sessionName,
requestedSessionTimeout, sessionLocaleIds, endpoint, and every other
ClientConfig property — is set on client.config
before calling connect():
client = o6.Client("opc.tcp://localhost:4840")
client.config.sessionName = "my-session"
client.config.requestedSessionTimeout = 60_000
client.config.sessionLocaleIds = ["en-US"]
client.config.endpoint = my_endpoint_description
client.config.setUsernamePassword("user", "secret")
client.connect()
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
endpointUrl
|
str
|
OPC UA endpoint to connect to, e.g.
|
''
|
loop
|
AbstractEventLoop | None
|
Asyncio event loop to use. Defaults to the running loop, or a newly created one if none is running. |
None
|
logger
|
Logger | None
|
Python logger used for all client-level log output.
Equivalent to |
None
|
certificate
|
str | Path | bytes | None
|
Client certificate as a file path ( |
None
|
privateKey
|
str | Path | bytes | None
|
Private key matching certificate, as a file path
or raw bytes.
Equivalent to |
None
|
trustList
|
list[str | Path | bytes] | None
|
Trusted server certificates, each as a file path or
raw bytes.
Equivalent to |
None
|
revocationList
|
list[str | Path | bytes] | None
|
Certificate revocation lists (CRL), each as a
file path or raw bytes.
Equivalent to |
None
|
securityMode
|
int | None
|
OPC UA message security mode
( |
None
|
securityPolicy
|
str | None
|
URI or short name of the security policy, e.g.
|
None
|
applicationUri
|
str | None
|
Application URI sent in the
|
None
|
username
|
str | None
|
Username for |
None
|
password
|
str | None
|
Password for |
None
|
allowNonePolicyPassword
|
bool
|
Permit transmitting a username/password
token without encryption. Defaults to False, including when
credentials are supplied. Equivalent to
|
False
|
name
|
str
|
Optional client name. Must be a valid Python identifier,
not match |
''
|
connect
¶
Connect to the server.
Establishes a SecureChannel and, by default, a Session. Finalizes encryption settings (certificate / key) before connecting.
If noSession is True, only the SecureChannel is opened
(useful for discovery or when a session will be activated manually
later).
Creates the default subscription unless createDefaultSubscription=False.
Opt out for sessions that only read, write, call, or browse, or supply
an explicit subscription to monitoring methods. If post-session setup
fails, including default-subscription creation, the session is closed
before the error is raised.
Starts the background worker thread.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
noSession
|
bool
|
Open only the SecureChannel, skip Session creation. |
False
|
createDefaultSubscription
|
bool
|
Create the convenience subscription after
connecting (default: |
True
|
disconnect
¶
Disconnect from the server.
By default closes all subscriptions, ends the Session, and closes the SecureChannel, then stops the background worker thread.
Pass closeSession=False to close only the SecureChannel while
keeping the Session alive (e.g. for session transfer). In that case
deleteSubscriptions is ignored.
Safe to call when already disconnected or when the event loop is
closed — returns None without raising.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
closeSession
|
bool
|
Close the Session (and SecureChannel). When
|
True
|
deleteSubscriptions
|
bool
|
Delete all active subscriptions before
disconnecting. Ignored when |
True
|
startReverseConnect
¶
Listen for an incoming OPC UA reverse connection from the server.
In the reverse-connect scenario the server initiates the TCP
connection to the client. The client opens a listen socket on
port and waits for the server to connect.
Close the connection with the standard disconnect.
client.startReverseConnect(port=4840, hostnames=["0.0.0.0"])
# ... use client ...
client.disconnect()
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
port
|
int
|
TCP port to listen on. |
required |
hostnames
|
list[str] | None
|
Network interfaces to advertise. |
None
|
activateCurrentSession
¶
Re-activate the session that is already associated with this client.
Sends an ActivateSession request using the client's stored identity token and credentials. Also creates the default subscription.
Typical use — session transfer, step 2 on the receiving client when the session was originally opened by this client and the SecureChannel has been renewed or re-established:
activateSession
¶
Activate a session that was created by another client.
Used for session transfer: client A's session is handed off to
client B. Client B must first open a SecureChannel without a session
(connect(noSession=True)), then call this method with the token
and nonce obtained from the originating session.
# Client B — take over a session using credentials supplied
# by the originating session
client_b.connect(noSession=True)
client_b.activateSession(token, nonce)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
authToken
|
NodeId
|
Authentication token ( |
required |
serverNonce
|
bytes
|
Server nonce bytes from the originating session. |
required |
__enter__
¶
Enter the sync context manager; connect if not already connected.
Calls connect when the client is not yet connected, then
returns self. exit calls disconnect if the
client is still connected when the block ends.
__exit__
¶
Exit the sync context manager; disconnect if still connected.
Calls disconnect when the client is still connected.
Exceptions from the with block are not suppressed.
See enter for full usage.
__aenter__
async
¶
Async counterpart of enter.
Same semantics — connects if not already connected and returns
self — but uses await internally. aexit awaits
disconnect.
__aexit__
async
¶
Exit the async context manager; disconnect if still connected.
Awaits disconnect when the client is still connected.
Exceptions from the async with block are not suppressed.
See aenter for full usage.
__getitem__
¶
Resolve a node ID to a typed Node object.
Reads NodeClass and BrowseName from the server and returns the
matching Node subclass (e.g. VariableNode,
ObjectNode, …). Service and attribute failures raise StatusCodeError;
an unknown ID has code BAD_NODE_ID_UNKNOWN. Malformed responses
raise RuntimeError.
key accepts anything that can be converted to a NodeId:
a string ("ns=1;s=Temperature"), an integer (numeric node id in
namespace 0), or a NodeId instance.
serviceFindServers
¶
Raw FindServers service call — discover servers known to a discovery server.
serviceFindServersOnNetwork
¶
Raw FindServersOnNetwork service call — enumerate servers registered via mDNS/LDS.
serviceGetEndpoints
¶
Raw GetEndpoints service call — retrieve the endpoint descriptions of a server.
invalidateNodeCache
¶
Invalidate cached child navigation for this client's existing handles.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target
|
NodeIdLike | None
|
Invalidate every handle for this node, or all handles when omitted. The next navigation browses again. Async callers must await this operation. |
None
|
Use this after external address-space changes or raw service browsing.
Complete browse() calls invalidate their target automatically, and
client node/reference mutations and namespace refresh invalidate all
handles. Cached misses are browsed again once before raising.
serviceAddNodes
¶
Raw AddNodes service call — add one or more nodes to the address space.
serviceDeleteNodes
¶
Raw DeleteNodes service call — remove one or more nodes from the address space.
serviceAddReferences
¶
Raw AddReferences service call — add references between nodes.
serviceDeleteReferences
¶
Raw DeleteReferences service call — remove references between nodes.
serviceBrowse
¶
Raw Browse service call — navigate the address space from one or more start nodes.
Returns references according to the BrowseDescription filter in the
request. Use serviceBrowseNext to continue if the response
indicates more results are available.
serviceBrowseNext
¶
Raw BrowseNext service call — continue a Browse that returned a continuation point.
serviceTranslateBrowsePathsToNodeIds
¶
Raw TranslateBrowsePathsToNodeIds service call — resolve browse paths to NodeIds.
serviceRegisterNodes
¶
Raw RegisterNodes service call — obtain optimised NodeIds for repeated access.
serviceUnregisterNodes
¶
Raw UnregisterNodes service call — release NodeIds obtained via RegisterNodes.
serviceRead
¶
Raw Read service call — read one or more node attributes.
serviceHistoryRead
¶
Raw HistoryRead service call — read historical values or events from nodes.
serviceWrite
¶
Raw Write service call — write one or more node attribute values.
serviceHistoryUpdate
¶
Raw HistoryUpdate service call — insert, replace, or delete historical data.
serviceCall
¶
Raw Call service call — invoke one or more OPC UA methods.
getRemoteDataTypes
¶
Read custom StructureDefinition data types from the server.
Browses the server's DataType hierarchy (rooted at Structure,
NodeId i=22) and reads the DataTypeDefinition and
BrowseName attributes for every discovered node. Only nodes that
carry a StructureDefinition (structs, structs-with-optional-fields,
and unions) are included in the result.
Pass typeNodes to restrict the query to a specific set of DataType
NodeIds instead of walking the full hierarchy. Passing an empty list
returns [] immediately without contacting the server. Expanded references
with a namespace URI or remote server index are skipped; only local
NodeIds can be read through this session.
Each entry in the returned list is a dict with the following keys:
typeName(str) —BrowseName.nameof the DataType node.typeId(NodeId) — NodeId of the DataType node.binaryEncodingId(NodeId) — default binary encoding NodeId (StructureDefinition.defaultEncodingId).structureType([StructureType][o6.ns.ns0.datatypes.StructureType]) — the information-model structure category.membersSize(int) — number of fields in the structure.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
typeNodes
|
list[NodeIdLike] | None
|
Explicit DataType NodeIds to query. |
None
|
updateRemoteNamespaces
¶
Atomically synchronize namespace mappings and custom datatypes.
The client first installs a provisional wire-index mapping when a URI has several compiled versions, reads the server's NamespaceMetadata, then selects an exact version or the latest available fallback. The final Python mapping, SecureChannel decoder mapping, and custom datatype chain are replaced as one snapshot. A failed refresh leaves the preceding snapshot usable. Call this again if a connected server adds namespaces at runtime; unchanged snapshots are not rebuilt.
getEndpoints
¶
Return the endpoints advertised by a server.
Sends a GetEndpoints request to endpointUrl. No active session
is required — connect with connect(noSession=True) first if the
client is not yet connected.
Each [EndpointDescription][o6.ns.ns0.datatypes.EndpointDescription] in the result describes one available endpoint and includes the endpoint URL, security mode, security policy URI, transport profile URI, server certificate, and the list of supported [UserTokenPolicy][o6.ns.ns0.datatypes.UserTokenPolicy] entries.
client.connect(noSession=True)
endpoints = client.getEndpoints("opc.tcp://localhost:4840")
for ep in endpoints:
print(ep.endpointUrl, ep.securityMode, ep.securityPolicyUri)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
endpointUrl
|
str
|
URL of the server to query, e.g.
|
required |
localeIds
|
list[str] | None
|
Preferred locales for localised strings in the
response (e.g. |
None
|
profileUris
|
list[str] | None
|
Restrict the result to endpoints that match one of
these transport profile URIs. |
None
|
Raises:
| Type | Description |
|---|---|
StatusCodeError
|
The discovery service failed or is unsupported. |
findServers
¶
Return servers registered at a discovery server or known to a server.
Sends a FindServers request to endpointUrl. Typically called
against a Local Discovery Server (LDS) at
"opc.tcp://localhost:4840" to enumerate all servers registered on
the host, or against any server to retrieve its own
[ApplicationDescription][o6.ns.ns0.datatypes.ApplicationDescription].
No active session is required — connect(noSession=True) is
sufficient.
Each [ApplicationDescription][o6.ns.ns0.datatypes.ApplicationDescription] in the result contains the
application name, application URI, application type, product URI, and
a list of discovery URLs that can be passed to
getEndpoints.
client.connect(noSession=True)
servers = client.findServers("opc.tcp://localhost:4840")
for srv in servers:
print(srv.applicationUri, srv.discovery_urls)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
endpointUrl
|
str
|
URL of the discovery server or server to query. |
required |
localeIds
|
list[str] | None
|
Preferred locales for the
|
None
|
serverUris
|
list[str] | None
|
Restrict the result to servers whose
|
None
|
Raises:
| Type | Description |
|---|---|
StatusCodeError
|
The discovery service failed or is unsupported. |
findServersOnNetwork
¶
Return servers visible on the network via a Local Discovery Server (LDS).
Sends a FindServersOnNetwork request to the connected LDS. The LDS maintains a registry of servers that have announced themselves via mDNS or the RegisterServer2 service. This call is only meaningful when connected to an LDS; a regular OPC UA server will return an empty list or an error.
The result is paginated: use startingRecordId and
maxRecordsToReturn to page through large registries. The
record_id field on each [ServerOnNetwork][o6.ns.ns0.datatypes.ServerOnNetwork] entry can
be used as the startingRecordId for the next page.
Each [ServerOnNetwork][o6.ns.ns0.datatypes.ServerOnNetwork] entry contains the server name,
discovery URL, and a list of capability strings (e.g. "DA" for
Data Access, "HE" for Historical Events).
# Fetch the first 100 servers that support Data Access
servers = client.findServersOnNetwork(
maxRecordsToReturn=100,
serverCapabilityFilter=["DA"],
)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
startingRecordId
|
int
|
Record ID to start from for pagination.
|
0
|
maxRecordsToReturn
|
int
|
Maximum number of entries to return.
|
0
|
serverCapabilityFilter
|
list[str] | None
|
Restrict the result to servers that
advertise all of the given capability strings. |
None
|
Raises:
| Type | Description |
|---|---|
StatusCodeError
|
The discovery service failed or is unsupported. |
read
¶
Read one attribute from a node or a list of nodes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target
|
NodeIdLike | list[NodeIdLike]
|
One NodeId-like target (including a Node) or a list of targets. |
required |
attr
|
AttributeId | str
|
AttributeId or case-insensitive attribute name; keyword-only. |
VALUE
|
timestampsToReturn
|
TimestampsToReturn | None
|
SOURCE (the default), SERVER, BOTH, or NEITHER. |
None
|
valueOnly
|
bool
|
Return values for all Good-severity statuses when True, discarding status and timestamps. False returns DataValues for the caller to interpret, including Uncertain and Bad statuses. |
True
|
range
|
IndexRange | list[IndexRange]
|
Inclusive OPC UA range string, stop-exclusive slice or tuple of slices, or one range per target. A scalar range broadcasts. None or an empty string reads the entire attribute. |
None
|
Returns:
| Type | Description |
|---|---|
MaybeAwaitable[Any]
|
A scalar for one target, or a list in input order. An empty target |
MaybeAwaitable[Any]
|
list returns []. Raw DataValues retain per-target statuses and |
MaybeAwaitable[Any]
|
supported timestamp metadata, including failed reads. |
Raises:
| Type | Description |
|---|---|
StatusCodeError
|
A service failure or an Uncertain/Bad value-only status. The code property preserves the status; batch errors include the failed index in an exception note. Nonempty ranges on non-Value attributes return BAD_INDEX_RANGE_NO_DATA. |
TypeError
|
An argument has an unsupported Python type. |
ValueError
|
An attribute name, slice, or range-list length is invalid. |
write
¶
Write one attribute using a scalar, parallel lists, or a mapping.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target
|
NodeIdLike | list[NodeIdLike] | Mapping[NodeIdLike, Any]
|
One NodeId-like target (including a Node), a list of targets, or a target-to-value mapping. |
required |
value
|
Any
|
Value for one target, or an equal-length list for target lists. Omit for mappings. A list for a scalar target is an array value. Explicit None writes a null value where the target permits it; omitting a scalar value raises ValueError. DataValues retain supported status and timestamp metadata. Non-Value attributes require their expected datatype and reject status/timestamp metadata with BAD_WRITE_NOT_SUPPORTED. |
_WRITE_UNSET
|
attr
|
AttributeId | str
|
AttributeId or case-insensitive attribute name; keyword-only. |
VALUE
|
range
|
IndexRange | list[IndexRange]
|
Inclusive OPC UA range string, stop-exclusive slice or tuple of slices, or one range per target. A scalar range broadcasts. None or an empty string writes the entire attribute. Nonempty ranges require Value; mappings do not accept ranges. |
None
|
Returns:
| Type | Description |
|---|---|
MaybeAwaitable[StatusCode | list[StatusCode]]
|
One StatusCode for a scalar target, otherwise a list in input order, |
MaybeAwaitable[StatusCode | list[StatusCode]]
|
including one-element batches. Empty lists/mappings return []. Every |
MaybeAwaitable[StatusCode | list[StatusCode]]
|
target is attempted despite per-target status failures; check results. |
Raises:
| Type | Description |
|---|---|
StatusCodeError
|
A service-level failure; code preserves its status. |
TypeError
|
An argument has an unsupported Python type. |
ValueError
|
Input shapes, attribute names, or ranges are invalid. Shapes and ranges are validated before any writes. |
call
¶
Invoke a method on a node.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
objectId
|
NodeIdLike
|
The object node id that owns the method. |
required |
methodId
|
NodeIdLike
|
The method node id to invoke. |
required |
inputArgs
|
list[Any]
|
Positional input arguments to pass to the method. |
[]
|
Returns:
| Type | Description |
|---|---|
MaybeAwaitable[tuple[StatusCode, *(tuple[Any, ...])]]
|
|
MaybeAwaitable[tuple[StatusCode, *(tuple[Any, ...])]]
|
and any available outputs. Invalid method selection and argument |
MaybeAwaitable[tuple[StatusCode, *(tuple[Any, ...])]]
|
validation also produce method results. A zero-output result is |
MaybeAwaitable[tuple[StatusCode, *(tuple[Any, ...])]]
|
|
Raises:
| Type | Description |
|---|---|
StatusCodeError
|
The Call service failed; |
TypeError
|
An argument cannot be converted to an OPC UA value. |
browse
¶
browse(
target,
*,
direction=ns0.datatypes.BrowseDirection.FORWARD,
reftype=ns0.reftypes.HierarchicalReferences,
refsubtypes=True,
nodeClassMask=ns0.datatypes.NodeClass.UNSPECIFIED,
resultMask=ns0.datatypes.BrowseResultMask.ALL
)
Browse references from a node.
The method transparently follows server-issued continuation points by
calling BrowseNext until all references have been collected, so the
returned list is always complete even when the server splits the
response into multiple batches.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target
|
NodeIdLike
|
The node id to browse from. |
required |
direction
|
BrowseDirection
|
The browse direction (forward, inverse, or both). |
FORWARD
|
reftype
|
NodeIdLike
|
A reference type to filter by, or |
HierarchicalReferences
|
refsubtypes
|
bool
|
If |
True
|
nodeClassMask
|
int
|
A node-class mask to filter the target nodes, as the
|
UNSPECIFIED
|
resultMask
|
int
|
A browse result mask to customize returned fields, as
the |
ALL
|
Returns:
| Type | Description |
|---|---|
MaybeAwaitable[list[ReferenceDescription]]
|
A list of |
MaybeAwaitable[list[ReferenceDescription]]
|
references. Sync callers receive the list directly; async tasks |
MaybeAwaitable[list[ReferenceDescription]]
|
must await the call. Node and NodeId targets have the same contract. |
Raises:
| Type | Description |
|---|---|
StatusCodeError
|
Browse or BrowseNext returned a service or result failure. Outstanding continuation points are released on failure or cancellation where the connection permits release. |
browsePage
¶
browsePage(
target,
*,
maxReferences=0,
direction=ns0.datatypes.BrowseDirection.FORWARD,
reftype=ns0.reftypes.HierarchicalReferences,
refsubtypes=True,
nodeClassMask=ns0.datatypes.NodeClass.UNSPECIFIED,
resultMask=ns0.datatypes.BrowseResultMask.ALL
)
Fetch one page of references, matching Server.browsePage.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target
|
NodeIdLike
|
Node to browse from. |
required |
maxReferences
|
int
|
Requested page size; zero means no client-side cap. |
0
|
direction
|
BrowseDirection
|
Forward, inverse, or both reference directions. |
FORWARD
|
reftype
|
NodeIdLike
|
ReferenceType to follow; defaults to HierarchicalReferences. |
HierarchicalReferences
|
refsubtypes
|
bool
|
Include subtypes of the reference type. |
True
|
nodeClassMask
|
int
|
Restrict target node classes; zero means all classes. |
UNSPECIFIED
|
resultMask
|
int
|
Reference fields to return; defaults to |
ALL
|
Returns:
| Type | Description |
|---|---|
MaybeAwaitable[BrowseResult]
|
One BrowseResult, directly for sync callers or awaitable in async |
MaybeAwaitable[BrowseResult]
|
code. Continue with |
MaybeAwaitable[BrowseResult]
|
token with |
Raises:
| Type | Description |
|---|---|
StatusCodeError
|
The service or individual browse failed. |
browseNext
¶
Continue or release pages from browsePage.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
releaseContinuationPoint
|
bool
|
Release tokens instead of fetching pages. |
required |
continuationPoint
|
bytes | list[bytes] | tuple[bytes, ...]
|
One token or a list/tuple of session-owned tokens. |
required |
Returns:
| Type | Description |
|---|---|
MaybeAwaitable[list[BrowseResult]]
|
One BrowseResult per token, always as a list. An empty input returns |
MaybeAwaitable[list[BrowseResult]]
|
an empty list. Await the operation in async code. |
Raises:
| Type | Description |
|---|---|
StatusCodeError
|
The service or any continuation operation failed. |
translateBrowsePathsToNodeIds
¶
Resolve one BrowsePath or a list of paths.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
browsePath
|
BrowsePath | list[BrowsePath]
|
A BrowsePath or list of BrowsePaths to resolve. |
required |
Returns:
| Type | Description |
|---|---|
MaybeAwaitable[BrowsePathResult | list[BrowsePathResult]]
|
One BrowsePathResult for a scalar input, or a list in input order. |
MaybeAwaitable[BrowsePathResult | list[BrowsePathResult]]
|
Each result retains its status, including partial/unresolved paths; |
MaybeAwaitable[BrowsePathResult | list[BrowsePathResult]]
|
an empty list returns an empty list. Await in async code. |
Raises:
| Type | Description |
|---|---|
StatusCodeError
|
The service failed. Use
|
browseSimplifiedBrowsePaths
¶
Resolve a BrowseName chain through forward hierarchical references.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
origin
|
NodeIdLike
|
Node at which the path starts. |
required |
browsePath
|
QualifiedName | str | list[QualifiedName | str] | tuple[QualifiedName | str, ...]
|
One QualifiedName/string or a list/tuple forming one path. |
required |
Returns:
| Type | Description |
|---|---|
MaybeAwaitable[BrowsePathResult]
|
One BrowsePathResult, retaining unresolved-path status. Await in |
MaybeAwaitable[BrowsePathResult]
|
async code. Unlike |
browseInteractive
¶
Open a curses-based interactive browser for the address space.
Requires the curses module (install windows-curses on
Windows). Returns the selected NodeId string (or BrowsePath string)
when the user quits with n / p; returns None otherwise.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
nodeId
|
NodeIdLike | None
|
Optional starting node id (defaults to |
None
|
historyRead
¶
historyRead(
target,
startTime,
endTime,
numValuesPerNode=0,
returnBounds=False,
timestampsToReturn=ns0.datatypes.TimestampsToReturn.BOTH,
)
Read raw historical values for one or more nodes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target
|
NodeIdLike | list[NodeIdLike]
|
A node id or list of node ids to read history from. |
required |
startTime
|
datetime
|
The start time for the history interval. |
required |
endTime
|
datetime
|
The end time for the history interval. |
required |
numValuesPerNode
|
int
|
Maximum number of values to return per node. |
0
|
returnBounds
|
bool
|
If |
False
|
timestampsToReturn
|
TimestampsToReturn
|
Which timestamps to return with each value. |
BOTH
|
Returns:
| Type | Description |
|---|---|
Any
|
Historical data for the requested nodes. Server-issued continuation |
Any
|
points are followed until the interval or per-node limit is exhausted. |
historyUpdateInsert
¶
Insert new historical values into a node's history.
Insertion fails for any timestamp that already has a value stored.
Use historyUpdateReplace to overwrite existing entries.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target
|
NodeIdLike
|
The node id whose history is being updated. |
required |
values
|
list[DataValue]
|
The historical values to insert. |
required |
Returns:
| Type | Description |
|---|---|
Any
|
The raw result of the history update operation. |
historyUpdateReplace
¶
Replace existing historical values for a node.
Replacement requires that a value already exists at each provided
timestamp. Use historyUpdateInsert to add new entries.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target
|
NodeIdLike
|
The node id whose history is being updated. |
required |
values
|
list[DataValue]
|
The historical values to replace existing entries with. |
required |
Returns:
| Type | Description |
|---|---|
Any
|
The raw result of the history update operation. |
historyUpdateDelete
¶
Delete historical values from a node.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target
|
NodeIdLike
|
The node id whose history should be deleted. |
required |
startTime
|
datetime
|
The start of the deletion interval. |
required |
endTime
|
datetime
|
The end of the deletion interval. |
required |
Returns:
| Type | Description |
|---|---|
Any
|
The raw result of the history delete operation. |
addObject
¶
addObject(
name,
parent,
*,
nodeId=None,
typeDefinition=ns0.objtypes.BaseObjectType,
ns=1,
parentReference=ns0.reftypes.Organizes
)
Create an Object and return a usable handle, matching Server.addObject.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
LocalizedTextLike
|
BrowseName and DisplayName of the Object. |
required |
parent
|
NodeIdLike
|
Parent node. |
required |
nodeId
|
NodeIdLike | None
|
Requested NodeId; the server assigns one when omitted. |
None
|
typeDefinition
|
NodeIdLike
|
ObjectType, defaulting to BaseObjectType. |
BaseObjectType
|
ns
|
int
|
Namespace index for the BrowseName. |
1
|
parentReference
|
NodeIdLike
|
Parent reference, defaulting to Organizes. |
Organizes
|
Returns:
| Type | Description |
|---|---|
MaybeAwaitable[ObjectNode]
|
An ObjectNode, directly in sync code or awaitable in async code. |
MaybeAwaitable[ObjectNode]
|
|
Raises:
| Type | Description |
|---|---|
StatusCodeError
|
Remote node creation failed. |
addVariable
¶
addVariable(
name,
parent,
value=None,
*,
nodeId=None,
dataType=None,
typeDefinition=ns0.vartypes.BaseDataVariableType,
writable=True,
ns=1,
parentReference=ns0.reftypes.Organizes
)
Create a Variable with friendly inputs, matching Server.addVariable.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
LocalizedTextLike
|
BrowseName and DisplayName of the Variable. |
required |
parent
|
NodeIdLike
|
Parent node. |
required |
value
|
Any
|
Initial value; its datatype and array rank are inferred. Typed empty NumPy arrays preserve their datatype and rank; empty Python sequences require an explicit dataType. |
None
|
nodeId
|
NodeIdLike | None
|
Requested NodeId; assigned by the server when omitted. |
None
|
dataType
|
NodeIdLike | None
|
Explicit OPC UA datatype, otherwise inferred from value. |
None
|
typeDefinition
|
NodeIdLike
|
VariableType, defaulting to BaseDataVariableType. |
BaseDataVariableType
|
writable
|
bool
|
Allow client writes; defaults to True. |
True
|
ns
|
int
|
Namespace index for the BrowseName. |
1
|
parentReference
|
NodeIdLike
|
Parent reference, defaulting to Organizes. |
Organizes
|
Returns:
| Type | Description |
|---|---|
MaybeAwaitable[VariableNode]
|
A VariableNode, directly in sync code or awaitable in async code. |
MaybeAwaitable[VariableNode]
|
|
MaybeAwaitable[VariableNode]
|
History registration and Python behavior installation are server-only. |
Raises:
| Type | Description |
|---|---|
StatusCodeError
|
Remote node creation failed. |
TypeError
|
The initial value has no inferable datatype. |
addVariableNode
¶
addVariableNode(
*,
parent,
parentReference=ns0.reftypes.HasComponent,
browseName,
requestedNodeId=None,
attributes,
typeDefinition=ns0.vartypes.BaseDataVariableType
)
Add a variable node to the server.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
parent
|
NodeIdLike
|
The parent node id for the variable. |
required |
browseName
|
QualifiedName | str
|
The BrowseName for the variable. |
required |
attributes
|
VariableAttributes
|
The variable attributes. |
required |
requestedNodeId
|
NodeIdLike | None
|
Optionally request a specific node id. |
None
|
parentReference
|
NodeIdLike
|
The reference type used to link the variable. |
HasComponent
|
typeDefinition
|
NodeIdLike
|
The variable type definition node id. |
BaseDataVariableType
|
Returns:
| Type | Description |
|---|---|
MaybeAwaitable[NodeId]
|
The newly created variable node id. |
addVariableTypeNode
¶
addVariableTypeNode(
*,
parent,
parentReference=ns0.reftypes.HasSubtype,
browseName,
requestedNodeId=None,
attributes
)
Add a variable type node to the server.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
parent
|
NodeIdLike
|
The parent node id for the type node. |
required |
browseName
|
QualifiedName | str
|
The BrowseName for the variable type. |
required |
attributes
|
VariableTypeAttributes
|
The variable type attributes. |
required |
requestedNodeId
|
NodeIdLike | None
|
Optionally request a specific node id. |
None
|
parentReference
|
NodeIdLike
|
The reference type used to link the type node. |
HasSubtype
|
Returns:
| Type | Description |
|---|---|
MaybeAwaitable[NodeId]
|
The newly created variable type node id. |
addObjectNode
¶
addObjectNode(
*,
parent,
parentReference=ns0.reftypes.HasComponent,
browseName,
requestedNodeId=None,
attributes,
typeDefinition=ns0.objtypes.BaseObjectType
)
Add an object node to the server.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
parent
|
NodeIdLike
|
The parent node id for the object. |
required |
browseName
|
QualifiedName | str
|
The BrowseName for the object. |
required |
attributes
|
ObjectAttributes
|
The object attributes. |
required |
requestedNodeId
|
NodeIdLike | None
|
Optionally request a specific node id. |
None
|
parentReference
|
NodeIdLike
|
The reference type used to link the object. |
HasComponent
|
typeDefinition
|
NodeIdLike
|
The object type definition node id. |
BaseObjectType
|
Returns:
| Type | Description |
|---|---|
MaybeAwaitable[NodeId]
|
The newly created object node id. |
addObjectTypeNode
¶
addObjectTypeNode(
*,
parent,
parentReference=ns0.reftypes.HasSubtype,
browseName,
requestedNodeId=None,
attributes
)
Add an object type node to the server.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
parent
|
NodeIdLike
|
The parent node id for the type. |
required |
browseName
|
QualifiedName | str
|
The BrowseName for the object type. |
required |
attributes
|
ObjectTypeAttributes
|
The object type attributes. |
required |
requestedNodeId
|
NodeIdLike | None
|
Optionally request a specific node id. |
None
|
parentReference
|
NodeIdLike
|
The reference type used to link the type node. |
HasSubtype
|
Returns:
| Type | Description |
|---|---|
MaybeAwaitable[NodeId]
|
The newly created object type node id. |
addViewNode
¶
addViewNode(
*,
parent,
parentReference=ns0.reftypes.HasComponent,
browseName,
requestedNodeId=None,
attributes
)
Add a view node to the server.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
parent
|
NodeIdLike
|
The parent node id for the view. |
required |
browseName
|
QualifiedName | str
|
The BrowseName for the view. |
required |
attributes
|
ViewAttributes
|
The view attributes. |
required |
requestedNodeId
|
NodeIdLike | None
|
Optionally request a specific node id. |
None
|
parentReference
|
NodeIdLike
|
The reference type used to link the view. |
HasComponent
|
Returns:
| Type | Description |
|---|---|
MaybeAwaitable[NodeId]
|
The newly created view node id. |
addReferenceTypeNode
¶
addReferenceTypeNode(
*,
parent,
parentReference=ns0.reftypes.HasSubtype,
browseName,
requestedNodeId=None,
attributes
)
Add a reference type node to the server.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
parent
|
NodeIdLike
|
The parent node id for the reference type. |
required |
browseName
|
QualifiedName | str
|
The BrowseName for the reference type. |
required |
attributes
|
ReferenceTypeAttributes
|
The reference type attributes. |
required |
requestedNodeId
|
NodeIdLike | None
|
Optionally request a specific node id. |
None
|
parentReference
|
NodeIdLike
|
The reference type used to link the node. |
HasSubtype
|
Returns:
| Type | Description |
|---|---|
MaybeAwaitable[NodeId]
|
The newly created reference type node id. |
addDataTypeNode
¶
addDataTypeNode(
*,
parent,
parentReference=ns0.reftypes.HasSubtype,
browseName,
requestedNodeId=None,
attributes
)
Add a data type node to the server.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
parent
|
NodeIdLike
|
The parent node id for the data type. |
required |
browseName
|
QualifiedName | str
|
The BrowseName for the data type. |
required |
attributes
|
DataTypeAttributes
|
The data type attributes. |
required |
requestedNodeId
|
NodeIdLike | None
|
Optionally request a specific node id. |
None
|
parentReference
|
NodeIdLike
|
The reference type used to link the node. |
HasSubtype
|
Returns:
| Type | Description |
|---|---|
MaybeAwaitable[NodeId]
|
The newly created data type node id. |
addMethodNode
¶
addMethodNode(
*,
parent,
parentReference=ns0.reftypes.HasComponent,
browseName,
requestedNodeId=None,
attributes
)
Add a method node to the server.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
parent
|
NodeIdLike
|
The parent node id for the method. |
required |
browseName
|
QualifiedName | str
|
The BrowseName for the method. |
required |
attributes
|
MethodAttributes
|
The method attributes. |
required |
requestedNodeId
|
NodeIdLike | None
|
Optionally request a specific node id. |
None
|
parentReference
|
NodeIdLike
|
The reference type used to link the method. |
HasComponent
|
Returns:
| Type | Description |
|---|---|
MaybeAwaitable[NodeId]
|
The newly created method node id. |
deleteNode
¶
Delete one or more nodes using the remote session permissions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
nodeId
|
NodeIdLike | list[NodeIdLike]
|
A node, node id, or list of these targets. |
required |
deleteTargetReferences
|
bool
|
If True (default), remove incoming references from remaining nodes. False leaves dangling references. |
True
|
Returns:
| Type | Description |
|---|---|
MaybeAwaitable[StatusCode | list[StatusCode]]
|
One StatusCode for a scalar target, otherwise a list in input order, |
MaybeAwaitable[StatusCode | list[StatusCode]]
|
including one-element batches. All targets are attempted despite |
MaybeAwaitable[StatusCode | list[StatusCode]]
|
per-target failures. An empty list returns [] without a request. |
MaybeAwaitable[StatusCode | list[StatusCode]]
|
Async callers must await the result. |
Raises:
| Type | Description |
|---|---|
StatusCodeError
|
The service failed. |
TypeError
|
An argument has an invalid Python type. |
ValueError
|
A target cannot be converted to a node id. |
addReference
¶
addReference(
source,
reftype,
target,
forward=True,
targetNodeClass=ns0.datatypes.NodeClass.UNSPECIFIED,
targetServerUri="",
)
Add a reference between two nodes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source
|
NodeIdLike
|
The source node id for the reference. |
required |
reftype
|
NodeIdLike
|
The reference type id. |
required |
target
|
NodeIdLike | ExpandedNodeId
|
The target node id. |
required |
forward
|
bool
|
If |
True
|
targetNodeClass
|
NodeClass
|
Optional target node class for the reference. |
UNSPECIFIED
|
targetServerUri
|
str
|
Optional server uri when referencing an external node. |
''
|
Returns:
| Type | Description |
|---|---|
MaybeAwaitable[StatusCode]
|
The individual StatusCode, or an awaitable resolving to it. |
MaybeAwaitable[StatusCode]
|
Rejected mutations, including duplicate local edges, return bad statuses. |
Raises:
| Type | Description |
|---|---|
StatusCodeError
|
The service failed. |
TypeError
|
An argument has an invalid Python type. |
ValueError
|
An argument cannot be converted to a node id or enum. |
deleteReference
¶
Delete a reference between two nodes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source
|
NodeIdLike
|
The source node id for the reference. |
required |
reftype
|
NodeIdLike
|
The reference type id. |
required |
target
|
NodeIdLike | ExpandedNodeId
|
The target node id. |
required |
forward
|
bool
|
If |
True
|
deleteBidirectional
|
bool
|
If |
True
|
Returns:
| Type | Description |
|---|---|
MaybeAwaitable[StatusCode]
|
The individual StatusCode, or an awaitable resolving to it. |
MaybeAwaitable[StatusCode]
|
Rejected deletions return non-Good statuses, including |
MaybeAwaitable[StatusCode]
|
UNCERTAIN_REFERENCE_NOT_DELETED for an absent edge. |
Raises:
| Type | Description |
|---|---|
StatusCodeError
|
The service failed. |
TypeError
|
An argument has an invalid Python type. |
ValueError
|
An argument cannot be converted to a node id. |
createSubscription
¶
createSubscription(
publishingInterval=100.0,
lifetimeCount=36000,
maxKeepaliveCount=10,
maxNotificationsPerPublish=10,
publishingEnabled=True,
*,
onCreated=None,
onStatusChange=None,
onDeleted=None
)
Create a subscription to monitor data or events.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
publishingInterval
|
float
|
The desired publishing interval in milliseconds. |
100.0
|
lifetimeCount
|
int
|
The subscription lifetime count. |
36000
|
maxKeepaliveCount
|
int
|
The maximum keepalive count. |
10
|
maxNotificationsPerPublish
|
int
|
The maximum number of notifications per publish. |
10
|
publishingEnabled
|
bool
|
Whether the subscription is initially enabled. |
True
|
onCreated
|
Callable[['o6.subscription.Subscription', CreateSubscriptionResponse], MaybeAwaitable[None]] | None
|
Optional callback invoked with |
None
|
onStatusChange
|
Callable[['o6.subscription.Subscription', StatusChangeNotification], MaybeAwaitable[None]] | None
|
Optional callback invoked with
|
None
|
onDeleted
|
Callable[['o6.subscription.Subscription'], MaybeAwaitable[None]] | None
|
Optional callback invoked with |
None
|
Returns:
| Type | Description |
|---|---|
MaybeAwaitable[Subscription]
|
A |
monitor
¶
monitor(
target,
callback=None,
samplingInterval=100.0,
*,
valueOnly=True,
subscription=None,
filter=None,
monitoringMode=ns0.datatypes.MonitoringMode.REPORTING,
queueSize=1,
discardOldest=True,
onCreated=None,
onDeleted=None
)
Monitor data changes on one or more nodes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target
|
NodeIdLike | ReadValueId | list[NodeIdLike | ReadValueId]
|
A node id, [ReadValueId][o6.ns.ns0.datatypes.ReadValueId], or list thereof to monitor. |
required |
callback
|
DataChangeCallback | None
|
Optional callback invoked for each data change. If |
None
|
samplingInterval
|
float
|
The requested sampling interval in milliseconds. |
100.0
|
valueOnly
|
bool
|
If |
True
|
subscription
|
Subscription | None
|
Optional subscription to attach the monitored items to.
If |
None
|
filter
|
DataChangeFilter | None
|
Optional [DataChangeFilter][o6.ns.ns0.datatypes.DataChangeFilter] to control triggering. |
None
|
monitoringMode
|
MonitoringMode
|
Monitoring mode for the item (default: |
REPORTING
|
queueSize
|
int
|
Requested queue size (default: |
1
|
discardOldest
|
bool
|
Whether to discard the oldest entry when the queue is
full (default: |
True
|
onCreated
|
CreatedCallback | None
|
Optional lifecycle callback; see |
None
|
onDeleted
|
DeletedCallback | None
|
Optional lifecycle callback; see |
None
|
Returns:
| Type | Description |
|---|---|
MaybeAwaitable[MonitoredItem | list[MonitoredItem]]
|
A monitored item or list of monitored items created for the target nodes. |
monitorEvent
¶
monitorEvent(
nodeId,
callback,
filter=None,
*,
subscription=None,
monitoringMode=ns0.datatypes.MonitoringMode.REPORTING,
queueSize=100,
discardOldest=True,
onCreated=None,
onDeleted=None
)
Monitor events on a node.
Callbacks receive a dict[str, Any] keyed by selected event-filter paths,
such as "/Message" or "/ConditionName/Id", optionally preceded by the
monitored item handle.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
nodeId
|
NodeIdLike
|
The node id to monitor for events. |
required |
callback
|
EventCallback
|
Callback invoked for each matching event. |
required |
filter
|
EventFilter | str | None
|
Optional event filter or filter expression string. If |
None
|
subscription
|
Subscription | None
|
Optional subscription to attach the monitored item to.
Defaults to |
None
|
monitoringMode
|
MonitoringMode
|
Monitoring mode for the item (default: |
REPORTING
|
queueSize
|
int
|
Requested queue size (default: |
100
|
discardOldest
|
bool
|
Whether to discard the oldest entry when the queue is
full (default: |
True
|
onCreated
|
CreatedCallback | None
|
Optional lifecycle callback; see |
None
|
onDeleted
|
DeletedCallback | None
|
Optional lifecycle callback; see |
None
|
Returns:
| Type | Description |
|---|---|
MaybeAwaitable[MonitoredItem]
|
The created monitored event item. |