Skip to content

Commit

Permalink
Add sw to _DEFAULTS for deviceInfo
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonacox committed Oct 9, 2020
1 parent 8ece4b0 commit 5d11e87
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -110,3 +110,4 @@ test.sh
sandbox/
.DS_Store
jason.py
tinytuya
12 changes: 4 additions & 8 deletions tuyapower/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
api_ver = "unknown"

name = "tuyapower"
version_tuple = (0, 0, 24)
version_tuple = (0, 0, 25)
version = version_string = __version__ = "%d.%d.%d" % version_tuple
__author__ = "jasonacox"

Expand All @@ -68,7 +68,7 @@
RETRY = 5

# default polling response for error condition
_DEFAULTS = (-99, -99, -99) # w, mA, V
_DEFAULTS = (False, -99, -99, -99) # w, mA, V

# UDP packet payload decryption - credit to tuya-convert
pad = lambda s: s + (16 - len(s) % 16) * chr(16 - len(s) % 16)
Expand Down Expand Up @@ -99,8 +99,9 @@ def deviceInfo(deviceid, ip, key, vers):
watchdog = 0
now = datetime.datetime.utcnow()
iso_time = now.strftime("%Y-%m-%dT%H:%M:%SZ")

while True:
w, mA, V = _DEFAULTS
sw, w, mA, V = _DEFAULTS
try:
if(api == "tinytuya"):
d = tinytuya.OutletDevice(deviceid, ip, key)
Expand All @@ -116,7 +117,6 @@ def deviceInfo(deviceid, ip, key, vers):
"CANCEL: Received interrupt from user while polling plug %s [%s]."
% (deviceid, ip)
)
sw = False
return (sw, w, mA, V, "User Interrupt")

except:
Expand All @@ -126,7 +126,6 @@ def deviceInfo(deviceid, ip, key, vers):
"TIMEOUT: No response from plug %s [%s] after %s attempts."
% (deviceid, ip, RETRY)
)
sw = False
return (sw, w, mA, V, "Timeout polling device")
try:
sleep(2)
Expand All @@ -135,7 +134,6 @@ def deviceInfo(deviceid, ip, key, vers):
"CANCEL: Received interrupt from user while polling plug %s [%s]."
% (deviceid, ip)
)
sw = False
return (sw, w, mA, V, "User Interrupt")

try:
Expand All @@ -160,7 +158,6 @@ def deviceInfo(deviceid, ip, key, vers):
log.info(str(info))
else:
log.info("Incomplete response from plug %s [%s]." % (deviceid,ip))
sw = False
key = "Incomplete response"
return (sw, w, mA, V, key)

Expand All @@ -181,7 +178,6 @@ def deviceInfo(deviceid, ip, key, vers):
"CANCEL: Received interrupt from user while polling plug %s [%s]."
% (deviceid, ip)
)
sw = False
return (sw, w, mA, V, "User Interrupt")

# (dps) = tuyapower.deviceInfo(id, ip, key, vers)
Expand Down

0 comments on commit 5d11e87

Please sign in to comment.