Skip to content

Commit

Permalink
Don't log error message when decoding valid discovery packets (#1824).
Browse files Browse the repository at this point in the history
  • Loading branch information
gunjambi committed Sep 24, 2023
1 parent 8f567fe commit 15f5dd4
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions miio/protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit 15f5dd4

Please sign in to comment.