Skip to content

Commit

Permalink
Remove assert and just log error on invalid packet
Browse files Browse the repository at this point in the history
Should help with stability as reported here: kevinvincent#114 (comment)
Thanks to @raetha for this contribution.
  • Loading branch information
kevinvincent authored and jheizerita committed Aug 23, 2021
1 parent 8034c13 commit 93754ae
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions custom_components/wyzesense/wyzesense_custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,12 @@ def Parse(cls, s):
assert len(s) >= 7
s = s[:7]
payload = MAKE_CMD(cmd_type, b2)
else:
assert len(s) >= b2 + 4
elif len(s) >= b2 + 4:
s = s[: b2 + 4]
payload = s[5:-2]
else:
log.error("Invalid packet: %s", bytes_to_hex(s))
return None

cs_remote = (s[-2] << 8) | s[-1]
cs_local = checksum_from_bytes(s[:-2])
Expand Down

0 comments on commit 93754ae

Please sign in to comment.