From fccd2da5d969f98bf28c70eeaebc45f87e73be65 Mon Sep 17 00:00:00 2001 From: Alexey Khit Date: Mon, 30 Nov 2020 21:28:01 +0300 Subject: [PATCH] Add Aqara T1 relay (dev2) --- .../xiaomi_gateway3/core/gateway3.py | 28 ++++++++++++------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/custom_components/xiaomi_gateway3/core/gateway3.py b/custom_components/xiaomi_gateway3/core/gateway3.py index 6830c654..0504baee 100644 --- a/custom_components/xiaomi_gateway3/core/gateway3.py +++ b/custom_components/xiaomi_gateway3/core/gateway3.py @@ -710,16 +710,24 @@ def process_pair(self, raw: bytes): def send(self, device: dict, data: dict): # convert hass prop to lumi prop - params = [{ - 'res_name': next(p[0] for p in device['params'] if p[2] == k), - 'value': v - } for k, v in data.items()] - - payload = { - 'cmd': 'write', - 'did': device['did'], - 'params': params, - } + if '2.1' in data: + v = bool(data['2.1']) + payload = { + 'cmd': 'write', + 'did': device['did'], + 'mi_spec': [{'siid': 2, 'piid': 1, 'value': v}], + } + else: + params = [{ + 'res_name': next(p[0] for p in device['params'] if p[2] == k), + 'value': v + } for k, v in data.items()] + + payload = { + 'cmd': 'write', + 'did': device['did'], + 'params': params, + } self.debug(f"{device['did']} {device['model']} => {payload}") payload = json.dumps(payload, separators=(',', ':')).encode()