diff --git a/miio/protocol.py b/miio/protocol.py index bddb40b20..0a7a0158d 100644 --- a/miio/protocol.py +++ b/miio/protocol.py @@ -161,11 +161,9 @@ 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"" + # Missing payload is expected for discovery messages. + if not obj: + return obj try: decrypted = Utils.decrypt(obj, context["_"]["token"]) decrypted = decrypted.rstrip(b"\x00")