From 15f5dd4301c15cc033d95472a2c316f97ab8aada Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jarkko=20P=C3=B6yry?= Date: Sun, 24 Sep 2023 19:49:27 +0300 Subject: [PATCH] Don't log error message when decoding valid discovery packets (#1824). --- miio/protocol.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/miio/protocol.py b/miio/protocol.py index 3902d35b6..bddb40b20 100644 --- a/miio/protocol.py +++ b/miio/protocol.py @@ -161,6 +161,11 @@ def _encode(self, obj, context, path): def _decode(self, obj, context, path) -> Union[Dict, bytes]: """Decrypts the payload using the token stored in the context.""" + # if there is no payload, decode to 0 bytes. Missing payload is expected for discovery messages. + # note that we don't have "token" in the context for discovery replies so we couldn't decode it + # anyway. + if obj == b"": + return b"" try: decrypted = Utils.decrypt(obj, context["_"]["token"]) decrypted = decrypted.rstrip(b"\x00")