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.4.0, < 0.5
  • 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
<root BTEng_format="1.0" main_tree_to_execute="main">
  <BehaviorTree 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>
  </BehaviorTree>
</root>
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 — bteng's built-in since 0.4; duration is in milliseconds

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.4.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.4.0
File Size Uploaded Provenance Actions
bteng_mqtt-0.4.0.tar.gz 78.3 kB Without provenance Details for bteng_mqtt-0.4.0.tar.gz

Built distribution (wheel)

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

Total release size: 147.0 kB

Release files / bteng_mqtt-0.4.0.tar.gz

Download URL bteng_mqtt-0.4.0.tar.gz
Size 78.3 kB
Tags Source
SHA-256 checksum
How to use checksums
144c85564d3d2264b326a844b08b16dff1f3c7950d0e0c436ec1329474b4d213
BLAKE2b-256 checksum
How to use checksums
14923f84dfa6c8190f37835e809ab820ac551a8cc4f1c1f6a140cc0a25298328
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.4.0-py3-none-any.whl

Download URL bteng_mqtt-0.4.0-py3-none-any.whl
Size 68.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e6f8e333036917c5847b40917390141f5205830e592f7c69267d0df8890b34d4
BLAKE2b-256 checksum
How to use checksums
0da67e73e426bcbe6e7fa72666183d267dde139ea55bf7ff813a2af45178c4b0
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.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.

Release history Release notifications | RSS feed

This release

0.4.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