Releases: jasonacox/tinytuya
Releases · jasonacox/tinytuya
v1.3.0 - TuyaCloud API Support
- Code format cleanup and readability improvements (pull request #91)
- Upgrade - Add TuyaCloud API support and functions (#87 #95)
import tinytuya
c = tinytuya.Cloud(
apiRegion="us",
apiKey="xxxxxxxxxxxxxxxxxxxx",
apiSecret="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
apiDeviceID="xxxxxxxxxxxxxxxxxxID")
# Display list of devices
devices = c.getdevices()
print("Device List: %r" % devices)
# Select a Device ID to Test
id = "xxxxxxxxxxxxxxxxxxID"
# Display DPS IDs of Device
result = c.getdps(id)
print("DPS IDs of device:\n", result)
# Display Status of Device
result = c.getstatus(id)
print("Status of device:\n", result)
# Send Command - This example assumes a basic switch
commands = {
'commands': [{
'code': 'switch_1',
'value': True
}, {
'code': 'countdown_1',
'value': 0
}]
}
print("Sending command...")
result = c.sendcommand(id,commands)
print("Results\n:", result)
v1.2.11 - Updated Scan and Wizard Retry Logic
- Added retries logic to
wizard
andscan
to honor value set by command line or default to a value based on the number of devices (if known):
# Explicit value set via command line
python3 -m tinytuya wizard 50 # Set retry to 50
python3 -m tinytuya scan 50
# Use automatic computed value
python3 -m tinytuya wizard # Compute a default
python3 -m tinytuya scan
# Example output
TinyTuya (Tuya device scanner) [1.2.11]
[Loaded devices.json - 32 devices]
Scanning on UDP ports 6666 and 6667 for devices (47 retries)...
v1.2.10 - Wizard Update for New Tuya Regions
- PyPi Version 1.2.10
- Added ability to disable device auto-detect (default vs device22) via
d.disabledetect=True
. - Wizard: Added new data center regions for Tuya Cloud: (Issues #66 #75)
Code | Region | Endpoint |
---|---|---|
cn | China Data Center | https://openapi.tuyacn.com |
us | Western America Data Center | https://openapi.tuyaus.com |
us-e | Eastern America Data Center | https://openapi-ueaz.tuyaus.com |
eu | Central Europe Data Center | https://openapi.tuyaeu.com |
eu-w | Western Europe Data Center | https://openapi-weaz.tuyaeu.com |
in | India Data Center | https://openapi.tuyain.com |
v1.2.9 - Edge Case Device Support
v1.2.8 - BulbDevice
- PyPi Version 1.2.8
- Added additional error checking for BulbDevice type selection
- Added TinyTuya version logging for debug mode
- Fix bug in scan when color=False (Issue #63)
v1.2.7 - New Tuya Cloud IoT Setup Wizard
- PyPi Version 1.2.7
- Updated setup
wizard
to support new Tuya IoT Cloud signature method (Issue #57) - Added Bulb type C and manual setting function
set_bulb_type(type)
(PR #54) - Wizard creates
tuya-raw.json
to record raw response from Tuya IoT Platform - Fixed device22 bug on retry - Now returns ERR_DEVTYPE error, status() includes auto-retry (#56)
v1.2.6 - Improved Error Handling
- PyPi Version 1.2.6
- Added
wizard
handling to capture and display Tuya API server error responses (PR #45) - Added better error handling for BulbDevice
state()
function to not crash when dps values are missing in response (PR #46) - Added async examples using
send()
andreceive()
- Updated scan output to include device Local Key if known (PR #49 #50)
- Fixed print typo in examples/devices.py (PR #51)
v1.2.5 - Send and Receive Functions
- PyPi Version 1.2.5
- Added raw mode
send()
andreceive()
function to allow direct control of payload transfers. Useful to monitor state changes via threads or continuous loops. This example opens a Tuya device and watches for state changes (e.g. switch going on and off):
import tinytuya
d = tinytuya.OutletDevice('DEVICEID', 'DEVICEIP', 'DEVICEKEY')
d.set_version(3.3)
d.set_socketPersistent(True)
print(" > Send Initial Query for Status < ")
payload = d.generate_payload(tinytuya.DP_QUERY)
d.send(payload)
while(True):
# See if any data is available
data = d.receive()
print('Received Payload: %r' % data)
# Send a keyalive heartbeat ping
print(" > Send Heartbeat Ping < ")
payload = d.generate_payload(tinytuya.HEART_BEAT)
d.send(payload)
v1.2.4 - DPS Detection and Bug Fixes
- PyPi Version 1.2.4
- Added detect_available_dps() function
- Fixed bug in json_error() function
- Updated instruction for using Tuya iot.tuya.com to run Wizard
- Added option to disable deviceScan() automatic device polling
- Added better error handling processing Tuya messages (responses) Issue #39
- Fixed display bug in Wizard device polling to show correct On/Off state
v1.2.3 - Dimmer and Brightness Functions
- PyPi Version 1.2.3
- Added
set_dimmer()
to OutletDevice class. - Added
set_hsv()
to BulbDevice class. - Updated
set_brightness()
in BulbDevice to handle white and colour modes. Issue #30 - BulbDevice determines features of device and presents boolean variables
has_colour
,has_brightness
andhas_colourtemp
to ignore requests that do not exist (returns error).