Interactive wizard for Tuya Library
Project description
Tuya Wizard
tuyawizard is a powerful and interactive CLI tool and Python library designed to help you discover and manage devices registered on the Tuya Cloud. It simplifies the authentication process using QR code login via the Smart Life or Tuya Smart app.
Features
- Easy Authentication: Support for QR code login using the Smart Life or Tuya Smart mobile apps.
- Automatic Token Management: Automatically handles and refreshes cloud tokens.
- Device Discovery: Fetches a comprehensive list of all registered devices and their details.
- Flexible Usage: Use it as a standalone CLI tool or integrate it into your own Python projects.
- Refactored & Typed: Modern Python implementation with type hints and improved error handling.
Installation
Install the package via pip:
pip install tuyawizard
To enable the local network scan feature, you need to install the optional dependency:
pip install rustuya
Quick Start (CLI)
You can run the wizard directly from your terminal:
python -m tuyawizard
Command-line Options
| Option | Default | Description |
|---|---|---|
-device-file FILE |
tuyadevices.json |
Path to save the discovered devices list (JSON). |
-credentials-file FILE |
tuyacreds.json |
Path to load/save cloud authentication credentials (JSON). |
--postprocess |
false |
Run postprocess after fetching devices. |
--postprocess-only |
false |
Run postprocess only (skip wizard login/fetch). |
--postprocess-mode |
all |
Select postprocess mode: parent, scan, all. |
Post process
- parent: In the post‑process stage, the output JSON is adjusted so that each
subdeviceis properly linked to its parent device. - scan: The output JSON is enriched with
IPandversiondetails obtained through the realtime scanner (requiresrustuya).
Postprocess Examples
Run wizard and then postprocess:
python -m tuyawizard --postprocess
Run postprocess only:
python -m tuyawizard --postprocess-only
Run parent-only postprocess:
python -m tuyawizard --postprocess-only --postprocess-mode parent
Run scan-only postprocess:
python -m tuyawizard --postprocess-only --postprocess-mode scan
Using as a Python Module
tuyawizard can also be imported and used as a module inside your own Python
project — fetch the device list from the Tuya cloud and, optionally, enrich
it with LAN scan data.
With rustuya installed
If rustuya is installed, just call postprocess_devices after fetching —
it runs the LAN scan and merges the results in one step:
from tuyawizard import TuyaWizard, postprocess_devices
tuya = TuyaWizard()
tuya.login_auto(user_code="YOUR_USER_CODE")
devices = tuya.fetch_devices()
postprocess_devices(devices, mode="scan") # scans via rustuya and merges
Without rustuya (inject your own scan data)
If rustuya is not available but you already have id/ip(/version)
data collected from elsewhere (for example via rustuya-bridge), inject
those results directly. version is optional per item:
from tuyawizard import TuyaWizard, apply_scan_results
tuya = TuyaWizard()
tuya.login_auto(user_code="YOUR_USER_CODE")
devices = tuya.fetch_devices()
scan_results = [
{"id": "bf...01", "ip": "192.168.1.10"},
{"id": "bf...02", "ip": "192.168.1.11", "version": "3.4"},
]
apply_scan_results(devices, scan_results)
How to get User Code
- Open the Smart Life or Tuya Smart app.
- Go to Me (Profile) tab.
- Tap on the Settings icon in the top right corner.
- Go to Account and Security.
- You will find your User Code (or Account ID) there.
Output Files
tuyacreds.json: Contains sensitive authentication tokens and endpoint information. Keep this file secure.tuyadevices.json: A structured JSON list of all your Tuya devices and their properties.
Notes
- Client Credentials: This tool currently uses temporary Home Assistant client credentials. These are intended to be replaced when official 3rd-party developer credentials become more widely available.
- Python Version: Requires Python 3.8 or higher.
License
This project is licensed under the MIT License.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file tuyawizard-0.1.7.tar.gz.
File metadata
- Download URL: tuyawizard-0.1.7.tar.gz
- Upload date:
- Size: 10.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c8a061c309873fd6c29a0c34bdf39e71d1a19ce32b9fced231c50213ae22207b
|
|
| MD5 |
f097df14e63aca5fdb678998dc879f91
|
|
| BLAKE2b-256 |
aa13ed801f5e2d407209763b3757873864845fa3b20f528f58e7cb5ec0d05c1f
|
Provenance
The following attestation bundles were made for tuyawizard-0.1.7.tar.gz:
Publisher:
release.yml on 3735943886/tuyawizard
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
tuyawizard-0.1.7.tar.gz -
Subject digest:
c8a061c309873fd6c29a0c34bdf39e71d1a19ce32b9fced231c50213ae22207b - Sigstore transparency entry: 1570812657
- Sigstore integration time:
-
Permalink:
3735943886/tuyawizard@5e68800f8e782a9890f51f8615e7087fb8c5339b -
Branch / Tag:
refs/tags/v0.1.7 - Owner: https://github.com/3735943886
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@5e68800f8e782a9890f51f8615e7087fb8c5339b -
Trigger Event:
release
-
Statement type:
File details
Details for the file tuyawizard-0.1.7-py3-none-any.whl.
File metadata
- Download URL: tuyawizard-0.1.7-py3-none-any.whl
- Upload date:
- Size: 9.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4da4494f7b4446c89de5787b94469b864749c4981d27342512cb4f56aedc05f3
|
|
| MD5 |
746dd95cc03ef1d3a057e4e16b1d1ea0
|
|
| BLAKE2b-256 |
9d139f626c71fa6d569d7c3b8001a00cce2a4609bc7ac6cf7d3330995e1f1c89
|
Provenance
The following attestation bundles were made for tuyawizard-0.1.7-py3-none-any.whl:
Publisher:
release.yml on 3735943886/tuyawizard
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
tuyawizard-0.1.7-py3-none-any.whl -
Subject digest:
4da4494f7b4446c89de5787b94469b864749c4981d27342512cb4f56aedc05f3 - Sigstore transparency entry: 1570812833
- Sigstore integration time:
-
Permalink:
3735943886/tuyawizard@5e68800f8e782a9890f51f8615e7087fb8c5339b -
Branch / Tag:
refs/tags/v0.1.7 - Owner: https://github.com/3735943886
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@5e68800f8e782a9890f51f8615e7087fb8c5339b -
Trigger Event:
release
-
Statement type: