Skip to main content

BTEng MQTT

bteng-mqtt

MQTT integration for the BTEng Behavior Tree engine, for behavior-tree-based messaging in distributed automation and robotics.

  • Behavior-tree nodes that publish, subscribe, and react to broker traffic
  • A project needs only a topic registry and tree XML, with no Python to write
  • Same contract as bteng-opcua: same registry idea, same run command, same blackboard plumbing

Requirements

  • Python 3.12+
  • bteng >= 0.3.2
  • paho-mqtt >= 2.0
  • PyYAML >= 6.0
  • An MQTT broker for live runs. If you cannot install mosquitto, pip install amqtt provides one that does not need root.

Installation

pip install bteng-mqtt

Quick start

A project is a registry and one or more trees:

project/
├── config/mqtt_config.yaml   # broker settings + topic aliases
└── trees/main_flow.xml       # the behavior tree
<BTEng format_version="1.0" main_tree_to_execute="main">
  <Tree ID="main">
    <Sequence name="ConveyorFlow">
      <MqttConnect      name="Connect"    client_id="main" host="127.0.0.1" port="1883" />
      <MqttPublish      name="Start"      client_id="main" topic_alias="conveyor_cmd" value="start" />
      <MqttWaitForValue name="Running"    client_id="main" topic_alias="robot_state"
                        expected_value="running" timeout="10.0" />
      <MqttDisconnect   name="Disconnect" client_id="main" />
    </Sequence>
  </Tree>
</BTEng>
bteng-mqtt run trees/ -n config/mqtt_config.yaml

Nodes

Node Purpose
MqttConnect / MqttDisconnect / MqttReconnect Connection lifecycle; broker settings come from the registry
MqttPublish / MqttBatchPublish Publish one or many topics; QoS 1/2 wait for the acknowledgement
MqttSubscribe / MqttUnsubscribe Wait for a message or a specific value; persistent keeps the subscription
MqttWaitForValue Wait until a topic satisfies eq/ne/gt/lt/ge/le/contains
MqttCondition Synchronous check of the last value received; never blocks
MqttBatchRead Copy several topics' latest values to the blackboard
MqttRequestResponse Request/reply topic pair, the OpcUaCallMethod analog
Sleep Timed wait, identical to the node in bteng-opcua

Commands

bteng-mqtt run trees/ -n config/mqtt_config.yaml                       # run every tree
bteng-mqtt run trees/pick.xml -n config/mqtt_config.yaml --bb speed=1.5
bteng-mqtt discover -s config/discover.yaml -o config/mqtt_config.yaml # draft topics from live traffic
bteng-mqtt discover -s config/discover.yaml -o config/mqtt_config.yaml --check
bteng-mqtt monitor -n config/mqtt_config.yaml -a temperature           # tail decoded topics

discover is a sniff, not a harvest. MQTT has no information model, so a quiet topic is invisible and every payload type is a guess from the samples that arrived. Review the generated file before trusting it.

Try it

From a clone of the repository, with a broker on 127.0.0.1:1883:

bteng-mqtt run examples/trees/ -n examples/config/mqtt_config.yaml

request_response_tree.xml also needs examples/demo_responder.py running.

Documentation

Development

pip install -e ".[dev]"
pytest tests/

Tests marked broker need a live MQTT broker (BTENG_MQTT_BROKER, default 127.0.0.1:1883) and skip when none is listening.

License

MIT

Metadata

Release files for bteng-mqtt 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for bteng-mqtt 0.1.0
File Size Uploaded Provenance Actions
bteng_mqtt-0.1.0.tar.gz 78.0 kB Without provenance Details for bteng_mqtt-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for bteng-mqtt 0.1.0
File Interpreter ABI Platform Actions
bteng_mqtt-0.1.0-py3-none-any.whl Python 3 none any Details for bteng_mqtt-0.1.0-py3-none-any.whl

Total release size: 147.0 kB

Release files / bteng_mqtt-0.1.0.tar.gz

Download URL bteng_mqtt-0.1.0.tar.gz
Size 78.0 kB
Tags Source
SHA-256 checksum
How to use checksums
bd2e8e1bd6d7d3226dcee4ff673cd4c819f14a91a8041fd0b3d3f6a681aa5747
BLAKE2b-256 checksum
How to use checksums
5df72a2060d7aeb3283111dc618d2c7347a09e1db08f9096a5edfb2fc57e5538
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.4

Release files / bteng_mqtt-0.1.0-py3-none-any.whl

Download URL bteng_mqtt-0.1.0-py3-none-any.whl
Size 69.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
10b288170323ba74b5403b84ad9d532ac4d5d95cb9e94c03152d28d29e50355b
BLAKE2b-256 checksum
How to use checksums
f2eadc557cf2c624db61d5996d52e7c001617de50d2eb20888c7d9fd8b66dbc9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.4

Security for bteng-mqtt 0.1.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.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page