Repository navigation
Releases: 3735943886/tuyawizard
Release list
v0.1.10
Bugfix release
Fixed
- The module-level
wizard()convenience function now tears down itsTuyaWizardvia the context manager (close()on both normal and exception exit). Previouslyfrom tuyawizard import wizard; wizard(...)leaked SDK-side state — therequests.Sessionconnection pools and the optionalSharingMQbackground thread — on every call. TheTuyaWizardclass already hadclose()/context-manager teardown; this closes the asymmetry on the front-door function.
Added
- Memory-leak regression tests: repeatedly constructing + closing a
TuyaWizardno longer accumulates threads, un-closed sessions, or live wizard/Manager objects across cycles. Thetuya_sharingSDK is never contacted —Manager/LoginControlare mocked. TestsCI workflow running the suite on push/PR across Python 3.9–3.13.
Notes
- Released now that the bundled Windows EXE's
rustuyadependency has reached its 0.3.0 stable line.
v0.1.9
Regression fix: close() no longer revokes the cloud terminal by default
0.1.8 regression: close() unconditionally called Manager.unload(), which POSTs to Tuya's /v1.0/m/token/terminal/expire endpoint and invalidates the saved access+refresh tokens server-side. Long-running consumers (rustuya-manager) that reuse tuyacreds.json across calls were forced into the QR fallback on every invocation after the first.
Fix
close() gains a keyword-only revoke_terminal=False parameter. The default no longer calls Manager.unload(); local cleanup (MQ thread join, requests.Session.close(), ref-cycle break) is unchanged so the 0.1.8 memory-leak fix is preserved.
# Long-running service / CLI cred-reuser — DEFAULT, saved creds stay valid
with TuyaWizard() as tuya:
tuya.login_auto(user_code="...")
devices = tuya.fetch_devices()
# Explicit logout — revoke server-side tokens
tuya.close(revoke_terminal=True)__exit__ still calls close() with no args, so with TuyaWizard() defaults to non-revoking.
Downstream
Consumers of 0.1.8 that called close() (or used with) and observed forced QR re-scans should bump to tuyawizard>=0.1.9. No code changes needed beyond the pin bump — default behavior automatically becomes non-revoking.
v0.1.8
close() / context manager for deterministic teardown
Long-running consumers that build a fresh TuyaWizard per operation were leaking ~750-950 KB RSS per cycle (observed by rustuya-manager). The underlying tuya_sharing SDK's Manager.unload() doesn't close the requests.Session connection pool or stop the optional SharingMQ background thread.
Use the context-manager form for leak-free teardown:
from tuyawizard import TuyaWizard
with TuyaWizard() as tuya:
tuya.login_auto(user_code="YOUR_USER_CODE")
devices = tuya.fetch_devices()Or call close() explicitly in a finally block. Idempotent and safe before login_auto(). Existing callers that drop TuyaWizard without close() keep working — the leak just isn't fixed for them.
Downstream consumers should pin tuyawizard>=0.1.8 to use it.
Windows EXE now built from this repo
The Windows single-file tuyawizard.exe is now built directly from this repo and attached to each release. The previous tuyawizard_windows repo has been merged in and archived.
Docs
- New "Lifecycle and cleanup" section in README.
pipx injectinstructions forrustuyaandcryptography.- Note that
cryptographyis an undeclared transitive dependency oftuya-device-sharing-sdk.
v0.1.7
Bug Fix
- fix(auth): Preserve the stored
user_codefromtuyacreds.jsonas a fallback for QR re-login. Previously, when the cached access token expired, the wizard would fail withNo User Code provided.even though the value was present in the credentials file. QR re-login now works correctly on token expiry.
Maintenance
- Dependabot bumped GitHub Actions to their latest majors (
checkout@v6,setup-python@v6,upload-artifact@v7,download-artifact@v8), clearing the Node.js 20 deprecation warnings.
Full Changelog: v0.1.6...v0.1.7
v0.1.6
What's Changed
- feat: Expose
apply_scan_resultsso you can inject scan data withoutrustuya(e.g. viarustuya-bridge). - refactor:
postprocess_devicesnow rejects unknown modes withValueErrorand warns whenscan_resultsare passed alongsidemode="parent"(they would otherwise be silently ignored). - docs: Added a "Using as a Python Module" section. Dropped emojis from README headings.
- ci: Added PyPI release workflow (this release should publish automatically).
Full Changelog: v0.1.5...v0.1.6