Skip to content

Commit ac0339b

Browse files
authored
Merge pull request #625 from uzlonewolf/bulb-rewrite
Add Singapore datacenter, update BulbDevice for non-bulb devices again
2 parents fce1d3c + 97f608f commit ac0339b

File tree

4 files changed

+35
-13
lines changed

4 files changed

+35
-13
lines changed

tinytuya/BulbDevice.py

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,21 @@ class BulbDevice(Device):
120120
'value_max': 255,
121121
'value_hexformat': 'rgb8',
122122
}
123+
DEFAULT_DPSET['None'] = {
124+
'switch': 1,
125+
'mode': None,
126+
'brightness': None,
127+
'colourtemp': None,
128+
'colour': None,
129+
'scene': None,
130+
'scene_data': None,
131+
'timer': None,
132+
'music': None,
133+
'value_min': 0,
134+
'value_max': 255,
135+
'value_hexformat': 'rgb8',
136+
}
137+
123138

124139
# These attributes are obsolete and only kept for backwards compatibility
125140
DPS_INDEX_SETS = [20, 1] # starts at either DP 20 (Type B) or 1 (all others)
@@ -849,7 +864,11 @@ def detect_bulb(self, response=None, nowait=False):
849864
# Try to determine type of BulbDevice Type based on DPS indexes
850865
# 1+2 or 20+21 are required per https://developer.tuya.com/en/docs/iot/product-function-definition?id=K9tp155s4th6b
851866
# The rest are optional
852-
if '20' in response['dps'] and '21' in response['dps']:
867+
if '20' in response['dps'] and '1' in response['dps']:
868+
# both 1 and 20 in response, this probably isn't a bulb
869+
self.bulb_configured = True
870+
self.bulb_type = 'None'
871+
elif '20' in response['dps'] and '21' in response['dps']:
853872
self.bulb_configured = True
854873
self.bulb_type = 'B'
855874
elif '1' in response['dps'] and '2' in response['dps']:

tinytuya/Cloud.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -122,16 +122,18 @@ def setregion(self, apiRegion=None):
122122
apiRegion = self.apiRegion
123123
self.apiRegion = apiRegion.lower()
124124
self.urlhost = "openapi.tuyacn.com" # China Data Center
125-
if self.apiRegion == "us":
125+
if self.apiRegion == "us" or self.apiRegion == "az":
126126
self.urlhost = "openapi.tuyaus.com" # Western America Data Center
127-
if self.apiRegion == "us-e":
127+
elif self.apiRegion == "us-e" or self.apiRegion == "ue":
128128
self.urlhost = "openapi-ueaz.tuyaus.com" # Eastern America Data Center
129-
if self.apiRegion == "eu":
129+
elif self.apiRegion == "eu":
130130
self.urlhost = "openapi.tuyaeu.com" # Central Europe Data Center
131-
if self.apiRegion == "eu-w":
131+
elif self.apiRegion == "eu-w" or self.apiRegion == "we":
132132
self.urlhost = "openapi-weaz.tuyaeu.com" # Western Europe Data Center
133-
if self.apiRegion == "in":
133+
elif self.apiRegion == "in":
134134
self.urlhost = "openapi.tuyain.com" # India Datacenter
135+
elif self.apiRegion == "sg":
136+
self.urlhost = "openapi-sg.iotbing.com" # Singapore Data Center
135137

136138
def _tuyaplatform(self, uri, action='GET', post=None, ver='v1.0', recursive=False, query=None, content_type=None):
137139
"""

tinytuya/core/core.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@
9393
# Colorama terminal color capability for all platforms
9494
init()
9595

96-
version_tuple = (1, 17, 1) # Major, Minor, Patch
96+
version_tuple = (1, 17, 2) # Major, Minor, Patch
9797
version = __version__ = "%d.%d.%d" % version_tuple
9898
__author__ = "jasonacox"
9999

tinytuya/wizard.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -145,14 +145,15 @@ def wizard(color=True, retries=None, forcescan=False, nocloud=False, assume_yes=
145145
" currently registered in Tuya App (used to pull full list) or 'scan' to scan for one: " + normal)
146146
# TO DO - Determine apiRegion based on Device - for now, ask
147147
print("\n " + subbold + "Region List" + dim +
148-
"\n cn\tChina Data Center" +
149-
"\n us\tUS - Western America Data Center" +
150-
"\n us-e\tUS - Eastern America Data Center" +
148+
"\n cn\tChina Data Center (alias: AY)" +
149+
"\n us\tUS - Western America Data Center (alias: AZ)" +
150+
"\n us-e\tUS - Eastern America Data Center (alias: UE)" +
151151
"\n eu\tCentral Europe Data Center" +
152-
"\n eu-w\tWestern Europe Data Center" +
153-
"\n in\tIndia Data Center\n")
152+
"\n eu-w\tWestern Europe Data Center (alias: WE)" +
153+
"\n in\tIndia Data Center\n" +
154+
"\n sg\tSingapore Data Center")
154155
config['apiRegion'] = input(subbold + " Enter " + bold + "Your Region" + subbold +
155-
" (Options: cn, us, us-e, eu, eu-w, or in): " + normal)
156+
" (Options: cn, us, us-e, eu, eu-w, in, or sg): " + normal)
156157
# Write Config
157158
json_object = json.dumps(config, indent=4)
158159
with open(config_file, "w") as outfile:

0 commit comments

Comments
 (0)