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'