From 3f38495819ef99523cbf5420455a90ee06338f38 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20RAMAGE?= Date: Wed, 15 Jul 2020 14:13:46 +0200 Subject: [PATCH] fix #192 --- tests/test_clusters.py | 3 +++ zigate/clusters.py | 2 +- zigate/version.py | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/tests/test_clusters.py b/tests/test_clusters.py index 60ff3439..96dfa0b6 100644 --- a/tests/test_clusters.py +++ b/tests/test_clusters.py @@ -18,6 +18,9 @@ def test_xiaomi_struct(self): self.assertEqual(data[101], 3937) # humidity self.assertEqual(data[102], 98981) # pressure self.assertEqual(data[6], '0100000000') # binary data + + rawdata = b'01219f0b03281e0421a81305219d0006240100000000082105140a21ed7721' + data = clusters.decode_xiaomi(rawdata) # lumi magnet sensor rawdata = b'0121030c0328100421a81305211f00062401000000000a210000' diff --git a/zigate/clusters.py b/zigate/clusters.py index c2c90e34..76431911 100644 --- a/zigate/clusters.py +++ b/zigate/clusters.py @@ -199,7 +199,7 @@ def decode_xiaomi(rawdata): rawdata = unhexlify(rawdata) data = {} i = 0 - while i < len(rawdata): + while i < len(rawdata) - 1: index = rawdata[i] _type = rawdata[i + 1] byteLength = (_type & 0x7) + 1 diff --git a/zigate/version.py b/zigate/version.py index 598baf5f..c081481d 100644 --- a/zigate/version.py +++ b/zigate/version.py @@ -6,4 +6,4 @@ # -__version__ = '0.40.1' +__version__ = '0.40.2'