rytilahti / python-miio

Python library & console tool for controlling Xiaomi smart appliances
https://python-miio.readthedocs.io
GNU General Public License v3.0
3.73k stars 558 forks source link

Xiaomi Mi Home Air Conditioner Companion support #76

Closed syssi closed 6 years ago

syssi commented 7 years ago

https://github.com/mac-zhou/homeassistant-mi-acpartner

First step: Implement the AC partner device. Second step: Provide a PR to migrate from python-miio to python-mirobo.

mouth4war commented 7 years ago

Is this for the Aqara AC companion?

syssi commented 7 years ago

No. It's a full featured air condition.

cxlwill commented 6 years ago

Hi, @syssi I'm one of contributors of this component. It keep updating and works very well in HA 0.58.1 and together with present miio version now. I have finished HA docs and ready for PR to HA main stream. But I think it is reasonable to change the platform even core to xiao_miio for synchronicity. Could I ask for your help here?

cxlwill commented 6 years ago

Also latest firmware for ac_companion has already opened LAN functions on it. Now this device get gateway port and function. We can add this info to docs as well?

syssi commented 6 years ago

You are right. Please rename the component. I will support your contribution and review your component as soon as possible. We should implement a miio device class to reduce the complexity of the HA component.

cxlwill commented 6 years ago

I have PR it. See here. Thanks for your help~

syssi commented 6 years ago

@cxlwill Could you provide a link to the product (f.e. at gearbest)?

cxlwill commented 6 years ago

Here is Aqara one and Xiaomi one.

syssi commented 6 years ago

Is this for the Aqara AC companion?

@mouth4war I must revoke my answer. The component is for the Xiaomi AC Companion. :-)

cxlwill commented 6 years ago

Yes, this one is AC companion. Xiaomi did produce the air conditioner under Smartmi Brand. See here. But, I think it is not worth to buy it out of China.

syssi commented 6 years ago

Do you like to provide write permission for https://github.com/cxlwill/home-assistant? I think it's easier as talking about the needed changes. :-)

syssi commented 6 years ago

Another interesting piece is the output of: mirobo --ip 10.0.1.8 --token a3d7f95... -d info

cxlwill commented 6 years ago

https://github.com/cxlwill/home-assistant/invitations

cxlwill commented 6 years ago
DEBUG:mirobo.device:Got a response: Container:
    data = Container:
        length = 0
        offset1 = 32
        data =  (total 0)
        offset2 = 32
        value =  (total 0)
    header = Container:
        length = 16
        offset1 = 0
        data = !1\x00 \x00\x00\x00\x00\x03\x91.\xf6\x00\x01\x12\xb3 (total 16)
        offset2 = 16
        value = Container:
            length = 32
            unknown = 0
            devtype = 913
            serial = 12022
            ts = 1970-01-01 19:32:03
    checksum = \x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00 (total 16)
DEBUG:mirobo.device:Discovered 913 12022 with ts: 1970-01-01 19:32:03, token: b'00000000000000000000000000000000'
DEBUG:mirobo.device:192.168.50.236:54321 >>: {'method': 'miIO.info', 'id': 1, 'params': []}
DEBUG:mirobo.device:192.168.50.236:54321 (ts: 1970-01-01 19:32:04, id: 1) << {'result': {'cfg_time': 0, 'mmfree': 171856, 'ott_stat': [0, 0, 0, 0], 'model': 'lumi.acpartner.v2', 'wifi_fw_ver': 'SD878x-14.76.36.p84-702.1.0-WM', 'hw_ver': 'MW300', 'mac': '34:CE:00:96:5B:F1', 'otu_stat': [80, 44, 2586, 0, 2586, 76], 'ap': {'bssid': '60:45:CB:AE:13:48', 'rssi': -55, 'ssid': 'xxxxx'}, 'life': 70324, 'ot': 'otu', 'mcu_fw_ver': '0143', 'fw_ver': '1.4.1_141', 'netif': {'mask': '255.255.255.0', 'gw': '192.168.50.1', 'gw_mac': '60:45:CB:AE:13:48', 'localIp': '192.168.50.236'}, 'token': '073777fef58687ae4b83xxxxxxxxxxxx'}, 'id': 1}
lumi.acpartner.v2 v1.4.1_141 (34:CE:00:96:5B:F1) @ 192.168.50.236 - token: 073777fef58687ae4b836c4xxxxxxxx
DEBUG:mirobo.vacuum_cli:Full response: {'ap': {'bssid': '60:45:CB:AE:13:48', 'rssi': -55, 'ssid': 'XYZ_Family'},
 'cfg_time': 0,
 'fw_ver': '1.4.1_141',
 'hw_ver': 'MW300',
 'life': 70324,
 'mac': '34:CE:00:96:5B:F1',
 'mcu_fw_ver': '0143',
 'mmfree': 171856,
 'model': 'lumi.acpartner.v2',
 'netif': {'gw': '192.168.50.1',
           'gw_mac': '60:45:CB:AE:13:48',
           'localIp': '192.168.50.236',
           'mask': '255.255.255.0'},
 'ot': 'otu',
 'ott_stat': [0, 0, 0, 0],
 'otu_stat': [80, 44, 2586, 0, 2586, 76],
 'token': '073777fef58687ae4b83xxxxxxxxxxxx',
 'wifi_fw_ver': 'SD878x-14.76.36.p84-702.1.0-WM'}
DEBUG:mirobo.vacuum_cli:Writing {'manual_seq': 0, 'seq': 1} to /tmp/python-mirobo.seq
syssi commented 6 years ago

Could you also provide the output of:

mirobo --ip 10.0.1.8 --token a3d7f95... -d raw_command get_model_and_state '[]'

Thanks in advance!

cxlwill commented 6 years ago
INFO:mirobo.vacuum_cli:Debug mode active
DEBUG:mirobo.vacuum_cli:Read stored sequence ids: {'manual_seq': 0, 'seq': 2}
DEBUG:mirobo.vacuum_cli:Connecting to 192.168.50.236 with token 073777fef58687ae4b836c49a9xxxxxx
Sending cmd get_model_and_state with params []
DEBUG:mirobo.protocol:Unable to decrypt, returning raw bytes.
DEBUG:mirobo.device:Got a response: Container:
    data = Container:
        offset2 = 32
        length = 0
        value =  (total 0)
        offset1 = 32
        data =  (total 0)
    header = Container:
        offset2 = 16
        length = 16
        value = Container:
            length = 32
            unknown = 0
            devtype = 913
            serial = 12022
            ts = 1970-01-01 22:47:04
        offset1 = 0
        data = !1\x00 \x00\x00\x00\x00\x03\x91.\xf6\x00\x01@h (total 16)
    checksum = \x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00 (total 16)
DEBUG:mirobo.device:Discovered 913 12022 with ts: 1970-01-01 22:47:04, token: b'00000000000000000000000000000000'
DEBUG:mirobo.device:192.168.50.236:54321 >>: {'params': [], 'method': 'get_model_and_state', 'id': 3}
DEBUG:mirobo.device:192.168.50.236:54321 (ts: 1970-01-01 22:47:05, id: 3) << {'result': ['010500978022222102', '010201190280222221', '2'], 'id': 3}
['010500978022222102', '010201190280222221', '2']
DEBUG:mirobo.vacuum_cli:Writing {'manual_seq': 0, 'seq': 3} to /tmp/python-mirobo.seq
mouth4war commented 6 years ago

Looks like I'm late. I have one of these and can help with testing in the future. Any plans for a HASS component, @syssi :)