From d1a60010f8723d23527e4457009fda712053ad8b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20RAMAGE?= Date: Thu, 16 Jul 2020 22:37:51 +0200 Subject: [PATCH] handle xiaomi special attribute --- tests/test_devices.py | 2 +- zigate/core.py | 8 +++++++- zigate/version.py | 2 +- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/tests/test_devices.py b/tests/test_devices.py index 00ac7296..ae1378e9 100644 --- a/tests/test_devices.py +++ b/tests/test_devices.py @@ -230,7 +230,7 @@ def test_fast_change(self): self.assertEqual(device.get_property_value('onoff'), False) def test_quirks(self): - device = core.Device({'addr': '1234', 'ieee': '0123456789abcdef'}) + device = core.Device({'addr': '1234', 'ieee': '0123456789abcdef'}, self.zigate) device.set_attribute(1, 0x0000, {'attribute': 0xff01, 'lqi': 255, 'data': '0121130b0421a84305211300062401000000006429ed0965219513662be18201000a210000'}) self.assertEqual(device.get_property_value('xiaomi'), {1: 2835, diff --git a/zigate/core.py b/zigate/core.py index 12dd7d3f..5e01bfcb 100644 --- a/zigate/core.py +++ b/zigate/core.py @@ -3070,8 +3070,14 @@ def _handle_quirks(self, attribute): LOGGER.debug('Handle special xiaomi attribute %s', attribute) values = attribute['value'] # Battery voltage - self.set_attribute(0x0001, 0x0001, {'attribute': 0x0020, 'data': values[1] / 100.}) + data_map = [(0x01, 0x0001, 0x0020, values[1] / 100.),] # TODO: Handle more special attribute + if self.get_type(False) == 'lumi.sensor_motion.aq2': + data_map += [(0x01, 0x0406, 0x0000, values[100]), + (0x01, 0x0400, 0x0000, values[11]) + ] + for endpoint_id, cluster_id, attribute_id, value in data_map: + self.set_attribute(endpoint_id, cluster_id, {'attribute': attribute_id, 'data': value}) def _delay_change(self, endpoint_id, cluster_id, data): ''' diff --git a/zigate/version.py b/zigate/version.py index c081481d..a1948701 100644 --- a/zigate/version.py +++ b/zigate/version.py @@ -6,4 +6,4 @@ # -__version__ = '0.40.2' +__version__ = '0.40.3'