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()