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

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.6
File Actions
pyrustuyabridge-0.4.6-cp39-abi3-win_amd64.whl CPython 3.9 abi3 Windows x86-64 Details for pyrustuyabridge-0.4.6-cp39-abi3-win_amd64.whl
pyrustuyabridge-0.4.6-cp39-abi3-musllinux_1_2_x86_64.whl CPython 3.9 abi3 Linux musl 1.2+ x86-64 Details for pyrustuyabridge-0.4.6-cp39-abi3-musllinux_1_2_x86_64.whl
pyrustuyabridge-0.4.6-cp39-abi3-musllinux_1_2_aarch64.whl CPython 3.9 abi3 Linux musl 1.2+ ARM64 Details for pyrustuyabridge-0.4.6-cp39-abi3-musllinux_1_2_aarch64.whl
pyrustuyabridge-0.4.6-cp39-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl CPython 3.9 abi3 Linux glibc 2.17+ x86-64 Details for pyrustuyabridge-0.4.6-cp39-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
pyrustuyabridge-0.4.6-cp39-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl CPython 3.9 abi3 Linux glibc 2.17+ ARM64 Details for pyrustuyabridge-0.4.6-cp39-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
pyrustuyabridge-0.4.6-cp39-abi3-macosx_11_0_arm64.whl CPython 3.9 abi3 macOS 11.0+ ARM64 Details for pyrustuyabridge-0.4.6-cp39-abi3-macosx_11_0_arm64.whl
pyrustuyabridge-0.4.6-cp39-abi3-macosx_10_12_x86_64.whl CPython 3.9 abi3 macOS 10.12+ x86-64 Details for pyrustuyabridge-0.4.6-cp39-abi3-macosx_10_12_x86_64.whl

Total release size: 20.6 MB

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

Download URL pyrustuyabridge-0.4.6-cp39-abi3-win_amd64.whl
Size 2.6 MB
Tags CPython 3.9 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
0215206534167777b99cb160594ecbc1b7582e1aed96a84a6911f085f8f1719a
BLAKE2b-256 checksum
How to use checksums
a771cf8baaabb781024f141afc2be72d069c4eb8c5c0c7196d88418229ece3d6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 14, 2026.

Transparency log

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

Download URL pyrustuyabridge-0.4.6-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
e077a2b5871cde76667efe26a81244606b26702f4dc84a02f5a127d3745d25da
BLAKE2b-256 checksum
How to use checksums
ee8071b73023ff9c32e1a8730f3672adffef157a1f8eb26e91c23f1e9da4d7cd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 14, 2026.

Transparency log

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

Download URL pyrustuyabridge-0.4.6-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
0320bd63cce44600e26b03e1fc3aababce8e8158189be31b3bbcaa127146700c
BLAKE2b-256 checksum
How to use checksums
202106b5f7bf7f2ef528c26f495b2e5d533b456372ccc440b1799a24edc88604
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 14, 2026.

Transparency log

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

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

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 Nov 14, 2026.

Transparency log

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

Download URL pyrustuyabridge-0.4.6-cp39-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
Size 2.9 MB
Tags CPython 3.9 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
e70a6d010f5d9a60bbf26a23cc58a412b9da78d2299110dcf2e8264d967dd5d3
BLAKE2b-256 checksum
How to use checksums
0f00f5ed413b170a4459c1d7ebba28a02e48e2e765b04616dad0d9ce523a27b1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 14, 2026.

Transparency log

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

Download URL pyrustuyabridge-0.4.6-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
fd3147d31dc2abaa286080ecd8ba9fb67af46538ccaad931063b32f277056dba
BLAKE2b-256 checksum
How to use checksums
72ff9927c7640fa44cfa0c81ecda522c82cd7a9e378fd204d786ea13c0c15768
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 14, 2026.

Transparency log

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

Download URL pyrustuyabridge-0.4.6-cp39-abi3-macosx_10_12_x86_64.whl
Size 3.0 MB
Tags CPython 3.9 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
63d1f0e55dbc209f681bda621e421f89424fed85bf1bfb0cae7f4874138ff299
BLAKE2b-256 checksum
How to use checksums
8274e013bb14224105b9cc4868299c554cf1875e390b73e1e3060a2686e86341
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 14, 2026.

Transparency log

Security for pyrustuyabridge 0.4.6

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.

Full provenance

All 7 files in this release have been uploaded with provenance metadata.

Select from 7 files

Attestation for pyrustuyabridge-0.4.6-cp39-abi3-win_amd64.whl

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 Nov 14, 2026.

Transparency log

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.6 This release

7 release files Full 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