bteng-opcua
OPC UA integration for the BTEng Behavior Tree engine, for behavior-tree-based communication and control in industrial automation.
- 12 async OPC UA leaf nodes for connections, reads and writes, subscriptions, history access, and method calls. A timed wait is bteng's built-in
Sleep(durationin milliseconds) - Registry generated from the server's information model with
bteng-opcua harvest, so addresses and data types are not written by hand - Trees run from the command line with
bteng-opcua run, with no Python to write
All OPC UA nodes implement the StatefulActionNode protocol: they return RUNNING while an async operation is in flight, then SUCCESS or FAILURE on completion.
Requirements
Installation
pip install bteng-opcua
Quick start
Describe what to harvest. This is the only file you write by hand:
# harvest.yaml
server: opc.tcp://192.168.1.10:4840 # or: nodeset: models/robot.NodeSet2.xml
harvest:
- "Objects/Robot" # every Variable and Method underneath
Generate the registry, then run a tree against it:
bteng-opcua harvest -s harvest.yaml -o nodes.yaml # generate; commit nodes.yaml
bteng-opcua harvest -s harvest.yaml -o nodes.yaml --check # CI: fail if the model drifted
bteng-opcua run tree.xml -n nodes.yaml # run a tree
Generation is a build step: trees run offline against the committed YAML, and the server is contacted only when you regenerate. Aliases default to the snake_cased BrowseName (MoveToPosition becomes move_to_position).
A tree addresses nodes by alias, so no node IDs or data types appear in the XML:
<root BTEng_format="1.0" main_tree_to_execute="main">
<BehaviorTree ID="main">
<Sequence name="root">
<OpcUaConnect name="connect" endpoint="opc.tcp://localhost:4840" session_id="main"/>
<OpcUaRead name="read_temp" session_id="main" node_alias="temperature"
value="{current_temp}"/>
<OpcUaDisconnect name="disconnect" session_id="main"/>
</Sequence>
</BehaviorTree>
<!-- Required for value="{key}" to WRITE to the blackboard. -->
<TreeNodesModel>
<Action ID="OpcUaRead"><output_port name="value"/></Action>
</TreeNodesModel>
</root>
Declare output ports in
<TreeNodesModel>. Without it the parser treats every{key}attribute as an input, andOpcUaReadsilently falls back to storing under its alias.
Nodes
| Node | Purpose |
|---|---|
OpcUaConnect |
Establish a named OPC UA session |
OpcUaDisconnect |
Close a session (best-effort) |
OpcUaReconnect |
Re-establish a dropped session using its saved config |
OpcUaRead |
Read one variable node to the blackboard |
OpcUaWrite |
Write one variable node from the blackboard |
OpcUaBatchRead |
Read multiple nodes in a single round-trip |
OpcUaBatchWrite |
Write multiple nodes in parallel |
OpcUaCallMethod |
Invoke an OPC UA method with typed input/output args |
OpcUaSubscribe |
React to data-change notifications (on_change or on_value mode) |
OpcUaWaitForValue |
Poll a node until its value matches an expected value |
OpcUaReadHistory |
Read a time-windowed history from a HistoricalAccess node |
OpcUaCondition |
Read a node and check it against an expected value |
Nodes resolve addresses through a registry alias (node_alias, recommended) or directly with a raw node_id and node_index.
Try it
From a clone of the repository, run everything against the demo server:
python examples/demo_server.py # terminal 1
bteng-opcua harvest -s examples/config/harvest.yaml -o examples/config/nodes.yaml
bteng-opcua run examples/trees/ -n examples/config/nodes.yaml
See examples/README.md for the project layout.
Documentation
- Authoring guide: full walkthrough from harvest spec to running tree
- Reference: harvest authentication, registry format, data types, sessions, and Python/XML integration
- Changelog
Development
pip install -e ".[dev]"
pytest tests/
tests/test_subscribe_integration.py needs a real OPC UA server.
License
Metadata
Release files for bteng-opcua 0.4.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| bteng_opcua-0.4.0.tar.gz | 63.6 kB | Without provenance | Details for bteng_opcua-0.4.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| bteng_opcua-0.4.0-py3-none-any.whl | Python 3 | none | any | Details for bteng_opcua-0.4.0-py3-none-any.whl |
Total release size: 118.4 kB
Release files / bteng_opcua-0.4.0.tar.gz
| Download URL | bteng_opcua-0.4.0.tar.gz |
|---|---|
| Size | 63.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e4a00ed68aaa7d6a55d4b638fe8de55c5cec71758f6c74880a89bd45da28ac19
|
|
BLAKE2b-256 checksum How to use checksums |
495e4898b83c5cdcfc5674a374d41e5eaff3f90c5aa7c8910ccf2f7441b17951
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.4
|
Release files / bteng_opcua-0.4.0-py3-none-any.whl
| Download URL | bteng_opcua-0.4.0-py3-none-any.whl |
|---|---|
| Size | 54.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7b6203c33044fa7bf51d03571d3a2e55078510da6149c0233654d1881d4ab390
|
|
BLAKE2b-256 checksum How to use checksums |
1591b48161042cbceb795a7b7418abb987cb21852d1d82f844b1fedafd0fd38f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.4
|
Security for bteng-opcua 0.4.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.