Releases: jasonacox/tinytuya
Releases · jasonacox/tinytuya
v1.18.1 - IR Learn Frame Fix
What's Changed
- Raise parse_header payload ceiling so large IR learn frames decode by @ostjen in #709
- core: Added
MAX_PAYLOAD_LENGTHconstant (default 1440 bytes) intinytuya/core/const.pyto replace the hardcoded 1000-byte ceiling inparse_header(). Enables local IR learn frame capture from devices with larger payloads such as AC IR blasters. Fixes #708 via #709 by @ostjen. - Adding heated towel radiator element, AFD02 by @mintsoft in #703
New Contributors
Full Changelog: v1.18.0...v1.18.1
v1.18.0 - Format Handling and UX Improvements
What's Changed
devices.jsonformat: All loading paths (library, CLI, scanner, wizard, API server) now support both a flat[{...}]list and the{"devices": [{...}]}wrapped-dict format via a new centralizedload_devicefile()helper. Fixes #532 via #700 by @uzlonewolf and @jasonacox.- API server: Added
isRegistered()/deviceError()helpers to distinguish "Device offline" from "Device ID not found" in error responses. - Cloud: Preserve device mappings on transient Cloud API failure in
getdevices()so a temporary outage no longer wipes the local device map by @jasonacox in #692. - IRRemoteControlDevice: Raise
RuntimeErroron undetectedcontrol_typeinsend_command()instead of silently failing by @jasonacox-sam in #698. - Contrib: New examples for
IRRemoteControlDeviceby @uzlonewolf in #699. - Contrib: Revert deprecated
Contrib/__init__.pyby @uzlonewolf in #686. - Docs: Clarify
set_version()example — 3.3 is not the required version by @jasonacox-sam in #695. - Scanner: Improved messaging for devices with no IP address — now clearly indicates the device may be battery-powered or sleeping and that local control is not supported, instead of the generic "Error: No IP found" by @jasonacox in #689.
- Wizard: When the Tuya Cloud API returns a "permission deny" error (or error code 1010), the wizard now prints a targeted hint suggesting the user check their IoT Core service subscription at https://iot.tuya.com by @jasonacox in #689.
- README: Added troubleshooting notes clarifying battery-powered device limitations and warning against aggressive polling intervals that can cause devices to drop or reset their connection.
- CLI: Refactored device-control functions into a new
cli.pymodule to keep__main__.pyfocused on argument parsing and dispatch by @uzlonewolf in #689. - CLI: New
monitorcommand — connects to a device with a persistent socket, prints the initial status, then listens for async updates with a heartbeat every 12 s and a full status refresh every 30 s by @uzlonewolf in #689. - CLI: New
versionsubcommand —tinytuya versionprints the installed TinyTuya version. - CLI: New
helpsubcommand —tinytuya helpprints a detailed usage summary with examples for all commands. Runningtinytuyawith no arguments also shows the full help. - CLI (
on,off,set,get,monitor):--idand--nameare now mutually exclusive and one is required (previously both were optional).--versionomitted now triggers an auto-scan instead of silently defaulting to v3.3 by @uzlonewolf in #689. - CLI (
on,off,set,get,monitor): Improved handling of device local keys that contain special shell characters ($,#,=,:,!) - re: #688 by @jasonacox in #689:- If
--keyis omitted and the key is not found indevices.json, the CLI now prompts interactively for the key. Input at a terminal prompt bypasses shell interpretation entirely, so no quoting or escaping is needed. - Added key length validation — Tuya local keys are always exactly 16 characters. If the resolved key is the wrong length (the most common symptom of a shell-escaping problem), a clear error is printed with platform-specific quoting tips for Linux/Mac and Windows CMD.
- If
New Contributors
- @jasonacox-sam made their first contribution in #695
Full Changelog: v1.17.6...v1.18.0
v1.17.6 - RFRemoteControlDevice Bug Fixes
What's Changed
- Contrib: Fix
RFRemoteControlDevice- three bugs that each independently causedrfstudy_sendcommands to be silently ignored by the device by @kongo09 in #684:rf_decode_button: fix missing()onbase64.b64decodecall — previously always returnedNone.send_command: build correctrfstudy_sendpayload (feqas int instead ofstudy_feqas string, addmode/ratefields, injectverinto each key dict); study/exit commands are unaffected.rf_send_button: do not forwardstudy_feqintofeq;feq=0tells the device to use the frequency embedded in the code itself.
- Adds regression tests for all three fixes.
New Contributors
Full Changelog: v1.17.5...v1.17.6
v1.17.5
What's Changed
- Enhance command line interface with device control and listing commands by @jasonacox in #681
list– List all devices fromdevices.jsonas a formatted table (default) or JSON (--json).on/off– Turn a device switch on or off, with optional--dps Nto target a specific switch index (default: 1).set– Write a value to a DPS index (--dps N --value VALUE). Value is parsed as JSON where possible (e.g.true,123) and falls back to a plain string.get– Read device status; omit--dpsfor full status JSON or supply--dps Nto retrieve a single plain value.- All control commands accept
--id IDor--name NAMEto identify the target device. When--nameis used, the device ID is resolved via a case-insensitive lookup indevices.json. - Missing credentials (
--key,--ip,--version) are automatically filled in from the matchingdevices.jsonentry.
- Contrib: Add
SoriaInverterDeviceto support SORIA solar micro-inverters by @Markourai in #680 - Enhance
CoverDevicewith automatic command type detection by @jasonacox in #654- Major rewrite to support 8 different device command types with automatic detection (credit: @make-all):
- Type 1:
["open", "close", "stop", "continue"]— Most curtains, blinds, roller shades (DEFAULT) - Type 2:
[true, false]— Simple relays, garage doors, locks - Type 3:
["0", "1", "2"]— String-numeric position/state - Type 4:
["00", "01", "02", "03"]— Zero-prefixed numeric position/state - Type 5:
["fopen", "fclose"]— Directional binary (no stop) - Type 6:
["on", "off", "stop"]— Switch-lexicon - Type 7:
["up", "down", "stop"]— Vertical-motion (lifts, hoists) - Type 8:
["ZZ", "FZ", "STOP"]— Vendor-specific (Abalon-style, older standard)
- Type 1:
- Added
continue_cover()method for device types that support it (Types 1 and 4) - Added
set_cover_type(type_id)method to manually override auto-detection
- Major rewrite to support 8 different device command types with automatic detection (credit: @make-all):
- Expand DPS detection ranges in XenonDevice to include missing values by @jasonacox in #674
- Update Scanner: improved clarity on v3.4 and v3.5 device identification when unresponsive by @jasonacox in #672
- Added star projector example by @Andy-Voigt in #670
- Add Dart Flutter port of TinyTuya to README by @sjhorn in #657
- Fix pylint CI workflow to run on pull requests as well as pushes, catching errors before merge
New Contributors
- @sjhorn made their first contribution in #657
- @Andy-Voigt made their first contribution in #670
- @Markourai made their first contribution in #680
Full Changelog: v1.17.4...v1.17.5
v1.17.4 - Cloud Config
What's Changed
- Add
configFileoption to the Cloud constructor, allowing users to specify the config file location (default remains 'tinytuya.json') by @blackw1ng in #640
New Contributors
- @blackw1ng made their first contribution in #640
Full Changelog: v1.17.3...v1.17.4
v1.17.3 - Colorama Optional
What's Changed
- This update makes the colorama dependency optional for the tinytuya library, allowing it to function without colorama while gracefully disabling color output. This will help with memory or dependency limited platforms. Update by @uzlonewolf in #637.
Full Changelog: v1.17.2...v1.17.3
v1.17.2 - BulbDevice
What's Changed
- Add Singapore datacenter, update BulbDevice for non-bulb devices again by @uzlonewolf in #625
Full Changelog: v1.17.1...v1.17.2
v1.17.1 - Fix BulbDevice
What's Changed
- Fix BulbDevice for non-bulb devices. This will allow BulbDevice to be used even for non-bulb devices, e.g. turn_on() & turn_off(), by @uzlonewolf in #620.
Full Changelog: v1.17.0...v1.17.1
v1.17.0 - BulbDevice Rewrite
What's Changed
- Tool updates: pcap parse fix, new broadcast relay by @uzlonewolf in #612
- Fix initialization bug with python2 (embedded devices) by @Ircama in #615
- Rewrite BulbDevice and rework set_multiple_values(), again by @uzlonewolf in #617
BulbDevice Example Usage
import time
import random
import tinytuya
d = tinytuya.BulbDevice(DEVICEID, address=DEVICEIP, local_key=DEVICEKEY, version=DEVICEVERS, persist=True)
# BASIC FUNCTIONS
print('Basic Tests')
d.set_colour(255,127,63) # Set to orange
d.set_white_percentage(100.0, 0.0) # 100% brightness, 0% colour temperature
d.set_brightness_percentage(100) # 100% brightness
# MUSIC MODE
print("Music Mode")
d.set_mode('music')
d.set_socketPersistent( True )
# Devices respond with a command ACK, but do not send DP updates.
# Setting the 2 options below causes it to wait for a response but
# return immediately after an ACK.
d.set_sendWait( None )
d.set_retry( False )
for x in range(100):
red = random.randint(0,255)
green = random.randint(0,255)
blue = random.randint(0,255)
if (x % 6 == 0):
# extend every 6 beat
d.set_music_colour( d.MUSIC_TRANSITION_FADE, red, green, blue )
time.sleep(2)
else:
# Jump!
d.set_music_colour( d.MUSIC_TRANSITION_JUMP, red, green, blue )
time.sleep(0.1) # the bulbs seem to get upset if updates are faster than 0.1s (100ms)
# SCENE MODE
if d.bulb_has_capability(d.BULB_FEATURE_SCENE_DATA):
d.set_mode('scene')
print('String based scenes compatible smartbulb detected.')
# Example: Color rotation
print('Switch to Scene 7 - Color Rotation')
d.set_scene( 7, '464602000003e803e800000000464602007803e803e80000000046460200f003e803e800000000464602003d03e803e80000000046460200ae03e803e800000000464602011303e803e800000000')New Contributors
Full Changelog: v1.16.3...v1.17.0
v1.16.3 - Devices.json Error Handling
What's Changed
- Add error handling in Cloud getdevices() function for edge case where old devices.json has corrupt or malformed device entries. by @jasonacox in #609
- Server p14 update: Add main loop logic to try to recover when exception occurs.
Full Changelog: v1.16.2...v1.16.3