Skip to content

Commit

Permalink
Add Aqara T1 relay (dev2)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexxIT committed Nov 30, 2020
1 parent 5044b2c commit fccd2da
Showing 1 changed file with 18 additions and 10 deletions.
28 changes: 18 additions & 10 deletions custom_components/xiaomi_gateway3/core/gateway3.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit fccd2da

Please sign in to comment.