From 03f72b8be08f2b4cc008563efbc508a70d983bf9 Mon Sep 17 00:00:00 2001 From: Steven B <51370195+sdb9696@users.noreply.github.com> Date: Mon, 1 Jul 2024 14:33:28 +0100 Subject: [PATCH] Disable multi-request on unknown errors (#1027) Another P100 fix --- kasa/smartprotocol.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/kasa/smartprotocol.py b/kasa/smartprotocol.py index f7551e33..e6741bc4 100644 --- a/kasa/smartprotocol.py +++ b/kasa/smartprotocol.py @@ -154,10 +154,14 @@ class SmartProtocol(BaseProtocol): try: self._handle_response_error_code(response_step, batch_name) except DeviceError as ex: - # P100 sometimes raises JSON_DECODE_FAIL_ERROR on batched request so - # disable batching + # P100 sometimes raises JSON_DECODE_FAIL_ERROR or INTERNAL_UNKNOWN_ERROR + # on batched request so disable batching if ( - ex.error_code is SmartErrorCode.JSON_DECODE_FAIL_ERROR + ex.error_code + in { + SmartErrorCode.JSON_DECODE_FAIL_ERROR, + SmartErrorCode.INTERNAL_UNKNOWN_ERROR, + } and self._multi_request_batch_size != 1 ): self._multi_request_batch_size = 1