Reduced logging level for 'Command %d timed out waiting for sequence number'; set v.5.1.0

This commit is contained in:
rospogrigio
2023-05-24 11:24:09 +02:00
parent a987d35429
commit 9d92cadef3
2 changed files with 9 additions and 8 deletions

View File

@@ -10,5 +10,5 @@
"iot_class": "local_push", "iot_class": "local_push",
"issue_tracker": "https://github.com/rospogrigio/localtuya/issues", "issue_tracker": "https://github.com/rospogrigio/localtuya/issues",
"requirements": [], "requirements": [],
"version": "5.0.1" "version": "5.1.0"
} }

View File

@@ -449,7 +449,7 @@ class MessageDispatcher(ContextualLogger):
try: try:
await asyncio.wait_for(self.listeners[seqno].acquire(), timeout=timeout) await asyncio.wait_for(self.listeners[seqno].acquire(), timeout=timeout)
except asyncio.TimeoutError: except asyncio.TimeoutError:
self.warning( self.debug(
"Command %d timed out waiting for sequence number %d", cmd, seqno "Command %d timed out waiting for sequence number %d", cmd, seqno
) )
del self.listeners[seqno] del self.listeners[seqno]
@@ -766,8 +766,9 @@ class TuyaProtocol(asyncio.Protocol, ContextualLogger):
enc_payload = self._encode_message(payload) enc_payload = self._encode_message(payload)
self.transport.write(enc_payload) self.transport.write(enc_payload)
try:
msg = await self.dispatcher.wait_for(seqno, payload.cmd) msg = await self.dispatcher.wait_for(seqno, payload.cmd)
if msg is None: except Exception as ex:
self.debug("Wait was aborted for seqno %d", seqno) self.debug("Wait was aborted for seqno %d", seqno)
return None return None
@@ -887,7 +888,7 @@ class TuyaProtocol(asyncio.Protocol, ContextualLogger):
try: try:
# self.debug("decrypting=%r", payload) # self.debug("decrypting=%r", payload)
payload = cipher.decrypt(payload, False, decode_text=False) payload = cipher.decrypt(payload, False, decode_text=False)
except Exception: except Exception as ex:
self.debug("incomplete payload=%r (len:%d)", payload, len(payload)) self.debug("incomplete payload=%r (len:%d)", payload, len(payload))
return self.error_json(ERR_PAYLOAD) return self.error_json(ERR_PAYLOAD)
@@ -913,7 +914,7 @@ class TuyaProtocol(asyncio.Protocol, ContextualLogger):
try: try:
# self.debug("decrypting=%r", payload) # self.debug("decrypting=%r", payload)
payload = cipher.decrypt(payload, False) payload = cipher.decrypt(payload, False)
except Exception: except Exception as ex:
self.debug("incomplete payload=%r (len:%d)", payload, len(payload)) self.debug("incomplete payload=%r (len:%d)", payload, len(payload))
return self.error_json(ERR_PAYLOAD) return self.error_json(ERR_PAYLOAD)
@@ -944,7 +945,7 @@ class TuyaProtocol(asyncio.Protocol, ContextualLogger):
self.debug("Deciphered data = %r", payload) self.debug("Deciphered data = %r", payload)
try: try:
json_payload = json.loads(payload) json_payload = json.loads(payload)
except Exception: except Exception as ex:
raise DecodeError("could not decrypt data: wrong local_key?") raise DecodeError("could not decrypt data: wrong local_key?")
# json_payload = self.error_json(ERR_JSON, payload) # json_payload = self.error_json(ERR_JSON, payload)
@@ -980,7 +981,7 @@ class TuyaProtocol(asyncio.Protocol, ContextualLogger):
# self.debug("decrypting %r using %r", payload, self.real_local_key) # self.debug("decrypting %r using %r", payload, self.real_local_key)
cipher = AESCipher(self.real_local_key) cipher = AESCipher(self.real_local_key)
payload = cipher.decrypt(payload, False, decode_text=False) payload = cipher.decrypt(payload, False, decode_text=False)
except Exception: except Exception as ex:
self.debug( self.debug(
"session key step 2 decrypt failed, payload=%r (len:%d)", "session key step 2 decrypt failed, payload=%r (len:%d)",
payload, payload,