Metadata-Version: 2.4
Name: pyrustuyabridge
Version: 0.1.4
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: POSIX :: Linux
Classifier: Operating System :: MacOS
Classifier: Operating System :: Microsoft :: Windows
Classifier: Programming Language :: Rust
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Topic :: Home Automation
Classifier: Topic :: System :: Networking
Summary: Python bindings for rustuyabridge — an MQTT bridge for Tuya devices
Keywords: tuya,mqtt,iot,bridge,smart-home,automation
Author: 3735943886
License: MIT
Requires-Python: >=3.9
Description-Content-Type: text/markdown
Project-URL: Homepage, https://github.com/3735943886/rustuya-bridge
Project-URL: Issues, https://github.com/3735943886/rustuya-bridge/issues
Project-URL: Repository, https://github.com/3735943886/rustuya-bridge

# pyrustuyabridge

Python bindings for [rustuya-bridge](https://github.com/3735943886/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 a Python
manager can run alongside it and interpret MQTT topics/payloads identically to
the native bridge.

## Install

```bash
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

```python
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())
```

## Helpers

The module also exposes topic/payload utilities for managers that need 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.

See the [project repository](https://github.com/3735943886/rustuya-bridge)
for full documentation.

