Skip to content
This repository has been archived by the owner on Sep 4, 2021. It is now read-only.

partial dps decode removed #42

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions pytuya/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,18 +268,18 @@ def status(self):
if not isinstance(result, str):
result = result.decode()
result = json.loads(result)
elif result.startswith(PROTOCOL_VERSION_BYTES):
# got an encrypted payload, happens occasionally
# expect resulting json to look similar to:: {"devId":"ID","dps":{"1":true,"2":0},"t":EPOCH_SECS,"s":3_DIGIT_NUM}
# NOTE dps.2 may or may not be present
result = result[len(PROTOCOL_VERSION_BYTES):] # remove version header
result = result[16:] # remove (what I'm guessing, but not confirmed is) 16-bytes of MD5 hexdigest of payload
cipher = AESCipher(self.local_key)
result = cipher.decrypt(result)
log.debug('decrypted result=%r', result)
if not isinstance(result, str):
result = result.decode()
result = json.loads(result)
#elif result.startswith(PROTOCOL_VERSION_BYTES):
# # got an encrypted payload, happens occasionally
# # expect resulting json to look similar to:: {"devId":"ID","dps":{"1":true,"2":0},"t":EPOCH_SECS,"s":3_DIGIT_NUM}
# # NOTE dps.2 may or may not be present
# result = result[len(PROTOCOL_VERSION_BYTES):] # remove version header
# result = result[16:] # remove (what I'm guessing, but not confirmed is) 16-bytes of MD5 hexdigest of payload
# cipher = AESCipher(self.local_key)
# result = cipher.decrypt(result)
# log.debug('decrypted result=%r', result)
# if not isinstance(result, str):
# result = result.decode()
# result = json.loads(result)
else:
log.error('Unexpected status() payload=%r', result)

Expand Down