From 6fab7763531e8313cc8f8403e37f70e3e808df88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20RAMAGE?= Date: Sat, 18 Jul 2020 08:04:58 +0200 Subject: [PATCH] Fix xiaomi vibration sensor --- tests/test_devices.py | 5 +++++ zigate/core.py | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/tests/test_devices.py b/tests/test_devices.py index ae1378e9..5bccdc04 100644 --- a/tests/test_devices.py +++ b/tests/test_devices.py @@ -242,6 +242,11 @@ def test_quirks(self): 102: 99041, 10: 0}) self.assertEqual(device.get_property_value('battery_voltage'), 2.835) + + def test_available_actions(self): + device = core.Device({'addr': '1234', 'ieee': '0123456789abcdef'}, self.zigate) + device.set_attribute(1, 0, {'attribute': 5, 'lqi': 255, 'data': 'lumi.vibration.aq1'}) + self.assertEqual(device.available_actions(), {1: []}) if __name__ == '__main__': diff --git a/zigate/core.py b/zigate/core.py index 5e01bfcb..0bececfc 100644 --- a/zigate/core.py +++ b/zigate/core.py @@ -2512,7 +2512,8 @@ def available_actions(self, endpoint_id=None): # except device 0x010a because Tradfri Outlet don't have level control # but still have endpoint 8... actions[ep_id].append(ACTIONS_LEVEL) - if 0x0101 in endpoint['in_clusters']: + if 0x0101 in endpoint['in_clusters'] and self.receiver_on_when_idle(): + # because of xiaomi vibration sensor actions[ep_id].append(ACTIONS_LOCK) if 0x0102 in endpoint['in_clusters']: actions[ep_id].append(ACTIONS_COVER)