Skip to content

Commit 788911f

Browse files
authored
Merge pull request #640 from blackw1ng/patch-1
Add constructor option to specify configfile
2 parents ad91c8e + 736ba67 commit 788911f

File tree

3 files changed

+18
-4
lines changed

3 files changed

+18
-4
lines changed

RELEASE.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# RELEASE NOTES
22

3+
## 1.17.4 - Cloud Config
4+
5+
- Cloud: Add `configFile` option to the Cloud constructor, allowing users to specify the config file location (default remains 'tinytuya.json') by @blackw1ng in https://github.com/jasonacox/tinytuya/pull/640
6+
37
## v1.17.3 - Colorama Optional
48

59
* 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 lor dependency limited platforms. Update by @uzlonewolf in https://github.com/jasonacox/tinytuya/pull/637.

tinytuya/Cloud.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,21 @@
4747
########################################################
4848

4949
class Cloud(object):
50-
def __init__(self, apiRegion=None, apiKey=None, apiSecret=None, apiDeviceID=None, new_sign_algorithm=True, initial_token=None, **extrakw):
50+
def __init__(self, apiRegion=None, apiKey=None, apiSecret=None, apiDeviceID=None, new_sign_algorithm=True, initial_token=None, configFile=CONFIGFILE, **extrakw):
5151
"""
5252
Tuya Cloud IoT Platform Access
5353
5454
Args:
55-
initial_token: The auth token from a previous run. It will be refreshed if it has expired
55+
apiRegion (str, optional): Tuya API region code (e.g., 'us', 'eu', 'cn', 'in').
56+
apiKey (str, optional): Tuya Cloud API key.
57+
apiSecret (str, optional): Tuya Cloud API secret.
58+
apiDeviceID (str, optional): Device ID for initial API calls.
59+
new_sign_algorithm (bool, optional): Use new sign algorithm for API requests. Default: True.
60+
initial_token (str, optional): The auth token from a previous run. It will be refreshed if expired.
61+
configFile (str, optional): Path to the config file to use for credentials. Default: 'tinytuya.json'.
62+
**extrakw: Additional keyword arguments for future compatibility.
63+
64+
If apiKey or apiSecret are not provided, credentials will be loaded from the config file.
5665
5766
Playload Construction - Header Data:
5867
Parameter Type Required Description
@@ -77,7 +86,7 @@ def __init__(self, apiRegion=None, apiKey=None, apiSecret=None, apiDeviceID=None
7786
* https://iot.tuya.com/cloud/products/detail
7887
"""
7988
# Class Variables
80-
self.CONFIGFILE = 'tinytuya.json'
89+
self.CONFIGFILE = configFile
8190
self.apiRegion = apiRegion
8291
self.apiKey = apiKey
8392
self.apiSecret = apiSecret
@@ -894,3 +903,4 @@ def getmappings( self, devices ):
894903
self.getmapping( productid, devid )
895904

896905
return self.mappings
906+

tinytuya/core/core.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@
101101
if HAVE_COLORAMA:
102102
init()
103103

104-
version_tuple = (1, 17, 3) # Major, Minor, Patch
104+
version_tuple = (1, 17, 4) # Major, Minor, Patch
105105
version = __version__ = "%d.%d.%d" % version_tuple
106106
__author__ = "jasonacox"
107107

0 commit comments

Comments
 (0)