Merge pull request #1424 from rospogrigio/fix_socket.send_exceptions

Fix for socket.send() exceptions in the logs
This commit is contained in:
rospogrigio
2023-06-07 12:27:31 +02:00
committed by GitHub
2 changed files with 5 additions and 6 deletions

View File

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

View File

@@ -766,10 +766,9 @@ class TuyaProtocol(asyncio.Protocol, ContextualLogger):
enc_payload = self._encode_message(payload)
self.transport.write(enc_payload)
try:
msg = await self.dispatcher.wait_for(seqno, payload.cmd)
except Exception as ex:
self.debug("Wait was aborted for seqno %d (%s)", seqno, ex)
if msg is None:
self.debug("Wait was aborted for seqno %d", seqno)
return None
# TODO: Verify stuff, e.g. CRC sequence number?
@@ -954,7 +953,7 @@ class TuyaProtocol(asyncio.Protocol, ContextualLogger):
json_payload = json.loads(payload)
except Exception as ex:
raise DecodeError(
"could not decrypt data: wrong local_key? (exception %s)", ex
"could not decrypt data: wrong local_key? (exception: %s)" % ex
)
# json_payload = self.error_json(ERR_JSON, payload)