Skip to main content

pyrustuyabridge

Python bindings for rustuya-bridge, an MQTT bridge for managing Tuya devices via the Tuya Local API.

This package exposes the bridge server as an embeddable component, so Python code can run it alongside and interpret MQTT topics/payloads identically to the native bridge.

Install

pip install pyrustuyabridge

Pre-built wheels are provided for Linux (manylinux2014 / musllinux_1_2 on x86_64 and aarch64), Windows x64, and macOS (x86_64 / arm64). Wheels are built with PyO3 abi3-py39, so a single wheel per platform supports CPython 3.9 and newer.

Quick start

import asyncio
from pyrustuyabridge import PyBridgeServer

async def main():
    server = PyBridgeServer(
        mqtt_broker="mqtt://localhost:1883",
        mqtt_root_topic="rustuya",
    )
    await server.start_async()

asyncio.run(main())

Applying config changes at runtime

The bridge is meant to be driven entirely over MQTT — including config changes. To apply a change to the topic/payload templates or mqtt_retain, edit the config_path file and publish a reconfigure action to the command topic. The bridge clears the retained messages published under the old scheme and then restarts itself in place — start()/start_async() keep running; they do not return, and live device connections carry over to the new cycle, so applying a change to a large fleet costs zero reconnects.

import asyncio
from pyrustuyabridge import PyBridgeServer

async def main():
    server = PyBridgeServer(config_path="/etc/rustuya/config.json")
    await server.start_async()  # only returns on stop()/close() or a signal

asyncio.run(main())

start()/start_async() return only when the bridge actually shuts down — stop()/close() from another thread/task, or (unless no_signals=True) SIGINT/SIGTERM. A supervisor is still worth running for boot and crash recovery, just not to change a topic.

Config precedence is kwargs > config_path file > defaults (the file only fills fields left unset). So put any field you want to change via reconfigure in the file, not in kwargs — a field passed as a kwarg wins and the file edit is ignored (same rule as CLI flags vs. config file in the native binary).

Helpers

The module also exposes topic/payload utilities for code that needs to match the bridge's wire format:

  • tpl_to_wildcard(template, root_topic) — template → MQTT wildcard.
  • match_topic(topic, template) — returns extracted variables or None.
  • render_template(template, vars) — substitutes {key} placeholders.
  • parse_payload(payload, vars) — parses an MQTT payload into a structured value.
  • parse_payload_with_template(payload, template) — reverse of render_template: recovers placeholder values from a rendered payload, or None if not reversible.
  • parse_seed_dps(payload, dp=None, template=None) — extracts the DPS map from an event payload exactly as the bridge's seed phase does; pass dp for single-DP ({dp}) topics, None for multi-DP topics whose payload is the full DPS object.
  • validate_payload_template(template) — (ok, message); checks whether a payload template can be reverse-parsed.

See the project repository for full documentation.

Metadata

Release files for pyrustuyabridge 0.4.1

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

Built distributions (wheels)

Table of built distributions (wheels) for pyrustuyabridge 0.4.1
File
pyrustuyabridge-0.4.1-cp39-abi3-win_amd64.whl CPython 3.9 abi3 Windows x86-64 Details
pyrustuyabridge-0.4.1-cp39-abi3-musllinux_1_2_x86_64.whl CPython 3.9 abi3 Linux musl 1.2+ x86-64 Details
pyrustuyabridge-0.4.1-cp39-abi3-musllinux_1_2_aarch64.whl CPython 3.9 abi3 Linux musl 1.2+ ARM64 Details
pyrustuyabridge-0.4.1-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.9 abi3 Linux glibc 2.17+ x86-64 Details
pyrustuyabridge-0.4.1-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl CPython 3.9 abi3 Linux glibc 2.17+ ARM64 Details
pyrustuyabridge-0.4.1-cp39-abi3-macosx_11_0_arm64.whl CPython 3.9 abi3 macOS 11.0+ ARM64 Details
pyrustuyabridge-0.4.1-cp39-abi3-macosx_10_12_x86_64.whl CPython 3.9 abi3 macOS 10.12+ x86-64 Details

Total release size: 20.2 MB

Release files / pyrustuyabridge-0.4.1-cp39-abi3-win_amd64.whl

Download URL pyrustuyabridge-0.4.1-cp39-abi3-win_amd64.whl
Size 2.6 MB
Tags CPython 3.9 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
4ca755ce6d5326a3f7dc50d8de63663bed717194be9dce2116492ed23f2041df
BLAKE2b-256 checksum
How to use checksums
989903031b3ec9cd5129cd33f53b7f0c36ec0be26bac431068e23b9a404fda1c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 5, 2026.

Transparency log

Release files / pyrustuyabridge-0.4.1-cp39-abi3-musllinux_1_2_x86_64.whl

Download URL pyrustuyabridge-0.4.1-cp39-abi3-musllinux_1_2_x86_64.whl
Size 3.3 MB
Tags CPython 3.9 Linux musl 1.2+ x86-64 abi3
SHA-256 checksum
How to use checksums
0d860468cf3ecf8fb2dfbc33cba9e1304f2e8d504ecaccce42eb92e91fff22b6
BLAKE2b-256 checksum
How to use checksums
7e142497af10b990378baa9e18896b8e25695f1aa67aa7bc964c3bb3f544a551
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 5, 2026.

Transparency log

Release files / pyrustuyabridge-0.4.1-cp39-abi3-musllinux_1_2_aarch64.whl

Download URL pyrustuyabridge-0.4.1-cp39-abi3-musllinux_1_2_aarch64.whl
Size 3.0 MB
Tags CPython 3.9 Linux musl 1.2+ ARM64 abi3
SHA-256 checksum
How to use checksums
2975f1c774201b28fbea117ae814aa97b7b97ab0727e24f4c5f453c60ae72782
BLAKE2b-256 checksum
How to use checksums
2358fb0662276e0f06401661e89d85fafe68afed71f1767234b69ab36d1715f5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 5, 2026.

Transparency log

Release files / pyrustuyabridge-0.4.1-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL pyrustuyabridge-0.4.1-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 3.0 MB
Tags CPython 3.9 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
fb1c20b39710148739cd69f329c0de8fdeda06f10358ba70f88854d80cd7532a
BLAKE2b-256 checksum
How to use checksums
ec42bfa869f4d9de31a56693b3f428d68e14f2cea6684684ac21c87acc47eb7e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 5, 2026.

Transparency log

Release files / pyrustuyabridge-0.4.1-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL pyrustuyabridge-0.4.1-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 2.8 MB
Tags CPython 3.9 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
8be9e014632e2494559f78430fa4a78d23bcbaa8a792c4371a6c3af16e1cecbd
BLAKE2b-256 checksum
How to use checksums
fbc4ac0cdcdbf0e4cf283e08ba310f8b1e0053c42e18056f737048be0b4959ce
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 5, 2026.

Transparency log

Release files / pyrustuyabridge-0.4.1-cp39-abi3-macosx_11_0_arm64.whl

Download URL pyrustuyabridge-0.4.1-cp39-abi3-macosx_11_0_arm64.whl
Size 2.7 MB
Tags CPython 3.9 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
e1e6ac0aba8a9d43b1bc69751c98e2279b7f12be45bf422d597baa9ba5d449f1
BLAKE2b-256 checksum
How to use checksums
137e4a2b8c43b37357979a4ffb9388dede3b4436ceaec56763b8f285dda0df2d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 5, 2026.

Transparency log

Release files / pyrustuyabridge-0.4.1-cp39-abi3-macosx_10_12_x86_64.whl

Download URL pyrustuyabridge-0.4.1-cp39-abi3-macosx_10_12_x86_64.whl
Size 2.9 MB
Tags CPython 3.9 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
3e550df536960bf886cc2139c86a7d5dfc8e5712377c601fe4c25b3f6ba508f6
BLAKE2b-256 checksum
How to use checksums
e61cb799f4fbf5898b83898e977caed34ce1ac79428b1975f59aced55c9f0074
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 5, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.4.1 This release

7 release files

0.4.0

7 release files

0.3.0

7 release files

0.1.4

7 release files

0.1.3

7 release files

0.1.2

7 release files

0.1.1

7 release files

0.1.0

7 release files

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