Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Discover not working with Mi AirHumidifier CA1 #514

Closed
tolikheha opened this issue Jun 2, 2019 · 8 comments
Closed

Discover not working with Mi AirHumidifier CA1 #514

tolikheha opened this issue Jun 2, 2019 · 8 comments
Assignees

Comments

@tolikheha
Copy link

Hi. I have python-miio 0.4.5 in python venv and Mi AirHumidifier CA1 with 1.6.6.1029 firmware. Device and pc are in same network.

Running miiocli airhumidifierca1 --ip 192.168.1.114 --token 0c070cc4b006361703e46bc70af3a3bf status fails with Error: Unable to discover the device 192.168.1.144
Execution of mirobo --ip=192.168.1.114 --token=0c070cc4b006361703e46bc70af3a3bf -d is even more interesting, because after first try it prints same as miiocli

First run
$ mirobo --ip=192.168.1.114 --token=0c070cc4b006361703e46bc70af3a3bf -d
INFO:miio.vacuum_cli:Debug mode active
DEBUG:miio.vacuum_cli:Read stored sequence ids: {'seq': 9, 'manual_seq': 0}
DEBUG:miio.vacuum_cli:Connecting to 192.168.1.114 with token 0c070cc4b006361703e46bc70af3a3bf
ERROR:miio.device:Unable to discover a device at address 192.168.1.114
DEBUG:miio.click_common:Exception: Unable to discover the device 192.168.1.114
Traceback (most recent call last):
  File "/tmp/miio/lib/python3.7/site-packages/miio/click_common.py", line 54, in __call__
    return self.main(*args, **kwargs)
  File "/tmp/miio/lib/python3.7/site-packages/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/tmp/miio/lib/python3.7/site-packages/click/core.py", line 1114, in invoke
    return Command.invoke(self, ctx)
  File "/tmp/miio/lib/python3.7/site-packages/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/tmp/miio/lib/python3.7/site-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/tmp/miio/lib/python3.7/site-packages/click/decorators.py", line 17, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/tmp/miio/lib/python3.7/site-packages/miio/vacuum_cli.py", line 69, in cli
    ctx.invoke(status)
  File "/tmp/miio/lib/python3.7/site-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/tmp/miio/lib/python3.7/site-packages/click/decorators.py", line 64, in new_func
    return ctx.invoke(f, obj, *args, **kwargs)
  File "/tmp/miio/lib/python3.7/site-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/tmp/miio/lib/python3.7/site-packages/miio/vacuum_cli.py", line 105, in status
    res = vac.status()
  File "/tmp/miio/lib/python3.7/site-packages/miio/vacuum.py", line 171, in status
    return VacuumStatus(self.send("get_status")[0])
  File "/tmp/miio/lib/python3.7/site-packages/miio/device.py", line 224, in send
    self.do_discover()
  File "/tmp/miio/lib/python3.7/site-packages/miio/device.py", line 162, in do_discover
    raise DeviceException("Unable to discover the device %s" % self.ip)
miio.exceptions.DeviceException: Unable to discover the device 192.168.1.114
Error: Unable to discover the device 192.168.1.114

But second run produce different output

Seond run
$ mirobo --ip=192.168.1.114 --token=0c070cc4b006361703e46bc70af3a3bf -d
INFO:miio.vacuum_cli:Debug mode active
DEBUG:miio.vacuum_cli:Read stored sequence ids: {'seq': 9, 'manual_seq': 0}
DEBUG:miio.vacuum_cli:Connecting to 192.168.1.114 with token 0c070cc4b006361703e46bc70af3a3bf
DEBUG:miio.protocol:Unable to decrypt, returning raw bytes: b''
DEBUG:miio.device:Got a response: Container: 
    data = Container: 
        data = b'' (total 0)
        value = b'' (total 0)
        offset1 = 32
        offset2 = 32
        length = 0
    header = Container: 
        data = b'!1\x00 \x00\x00\x00\x00\x07\xe8X\x0b\x00\x00\x8ak' (total 16)
        value = Container: 
            length = 32
            unknown = 0
            device_id = b'\x07\xe8X\x0b' (total 4)
            ts = 1970-01-01 09:50:35
        offset1 = 0
        offset2 = 16
        length = 16
    checksum = b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' (total 16)
DEBUG:miio.device:Discovered 07e8580b with ts: 1970-01-01 09:50:35, token: b'00000000000000000000000000000000'
DEBUG:miio.device:192.168.1.114:54321 >>: {'id': 10, 'method': 'get_status', 'params': []}
DEBUG:miio.device:192.168.1.114:54321 (ts: 1970-01-01 09:50:36, id: 10) << {'error': {'code': -9999, 'message': 'UART timeout'}, 'id': 10}
DEBUG:miio.click_common:Exception: {'code': -9999, 'message': 'UART timeout'}
Traceback (most recent call last):
  File "/tmp/miio/lib/python3.7/site-packages/miio/click_common.py", line 54, in __call__
    return self.main(*args, **kwargs)
  File "/tmp/miio/lib/python3.7/site-packages/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/tmp/miio/lib/python3.7/site-packages/click/core.py", line 1114, in invoke
    return Command.invoke(self, ctx)
  File "/tmp/miio/lib/python3.7/site-packages/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/tmp/miio/lib/python3.7/site-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/tmp/miio/lib/python3.7/site-packages/click/decorators.py", line 17, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/tmp/miio/lib/python3.7/site-packages/miio/vacuum_cli.py", line 69, in cli
    `ctx.invoke(status)`
  File "/tmp/miio/lib/python3.7/site-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/tmp/miio/lib/python3.7/site-packages/click/decorators.py", line 64, in new_func
    return ctx.invoke(f, obj, *args, **kwargs)
  File "/tmp/miio/lib/python3.7/site-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/tmp/miio/lib/python3.7/site-packages/miio/vacuum_cli.py", line 105, in status
    res = vac.status()
  File "/tmp/miio/lib/python3.7/site-packages/miio/vacuum.py", line 171, in status
    return VacuumStatus(self.send("get_status")[0])
  File "/tmp/miio/lib/python3.7/site-packages/miio/device.py", line 275, in send
    raise DeviceError(error)
miio.exceptions.DeviceError: {'code': -9999, 'message': 'UART timeout'}
Error: {'code': -9999, 'message': 'UART timeout'}

Similar situation with mirobo --ip=192.168.1.114 --token=0c070cc4b006361703e46bc70af3a3bf -d status.
However, some commands still works

`mirobo --ip=192.168.1.114 --token=0c070cc4b006361703e46bc70af3a3bf -d info`
mirobo --ip=192.168.1.114 --token=0c070cc4b006361703e46bc70af3a3bf -d info
INFO:miio.vacuum_cli:Debug mode active
DEBUG:miio.vacuum_cli:Read stored sequence ids: {'seq': 9, 'manual_seq': 0}
DEBUG:miio.vacuum_cli:Connecting to 192.168.1.114 with token 0c070cc4b006361703e46bc70af3a3bf
DEBUG:miio.protocol:Unable to decrypt, returning raw bytes: b''
DEBUG:miio.device:Got a response: Container: 
    data = Container: 
        data = b'' (total 0)
        value = b'' (total 0)
        offset1 = 32
        offset2 = 32
        length = 0
    header = Container: 
        data = b'!1\x00 \x00\x00\x00\x00\x07\xe8X\x0b\x00\x00\x8d\x1a' (total 16)
        value = Container: 
            length = 32
            unknown = 0
            device_id = b'\x07\xe8X\x0b' (total 4)
            ts = 1970-01-01 10:02:02
        offset1 = 0
        offset2 = 16
        length = 16
    checksum = b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' (total 16)
DEBUG:miio.device:Discovered 07e8580b with ts: 1970-01-01 10:02:02, token: b'00000000000000000000000000000000'
DEBUG:miio.device:192.168.1.114:54321 >>: {'id': 10, 'method': 'miIO.info', 'params': []}
DEBUG:miio.device:192.168.1.114:54321 (ts: 1970-01-01 10:02:02, id: 10) << {'result': {'life': 36122, 'token': '0c070cc4b006361703e46bc70af3a3bf', 'mac': '04:CF:8C:9B:C7:39', 'fw_ver': '1.6.6', 'hw_ver': 'MTK7697', 'uid': '1673598557', 'model': 'zhimi.humidifier.ca1', 'mcu_fw_ver': '1029', 'wifi_fw_ver': '20190313111057', 'config_type': 'app', 'ap': {'rssi': -28, 'ssid': 'OpenWrt', 'bssid': '50:64:2B:5C:BB:85'}, 'netif': {'localIp': '192.168.1.114', 'mask': '255.255.255.0', 'gw': '192.168.1.1', 'gw_mac': '50:64:2B:5C:BB:84'}, 'mmfree': 65880}, 'id': 10}
zhimi.humidifier.ca1 v1.6.6 (04:CF:8C:9B:C7:39) @ 192.168.1.114 - token: 0c070cc4b006361703e46bc70af3a3bf
DEBUG:miio.vacuum_cli:Full response: {'ap': {'bssid': '50:64:2B:5C:BB:85', 'rssi': -28, 'ssid': 'OpenWrt'},
 'config_type': 'app',
 'fw_ver': '1.6.6',
 'hw_ver': 'MTK7697',
 'life': 36122,
 'mac': '04:CF:8C:9B:C7:39',
 'mcu_fw_ver': '1029',
 'mmfree': 65880,
 'model': 'zhimi.humidifier.ca1',
 'netif': {'gw': '192.168.1.1',
           'gw_mac': '50:64:2B:5C:BB:84',
           'localIp': '192.168.1.114',
           'mask': '255.255.255.0'},
 'token': '0c070cc4b006361703e46bc70af3a3bf',
 'uid': '1673598557',
 'wifi_fw_ver': '20190313111057'}
DEBUG:miio.vacuum_cli:Writing {'seq': 10, 'manual_seq': 0} to /home/tolik/.cache/python-miio/python-mirobo.seq


Probably, relates to #383

@syssi
Copy link
Collaborator

syssi commented Jun 2, 2019

May be the available properties has changed. Could you provide the output of:

for PROP in power mode humidity buzzer led_b child_lock limit_hum use_time hw_version temp_dec speed depth dry
do
  mirobo --ip IP --token TOKEN raw-command get_prop "['$PROP']"
done

If you don't have a shell please call each command manually:

mirobo --ip IP --token TOKEN raw-command get_prop "['power']"
mirobo --ip IP --token TOKEN raw-command get_prop "['mode']"
mirobo --ip IP --token TOKEN raw-command get_prop "['humidity']"
...

@syssi syssi self-assigned this Jun 2, 2019
@tolikheha
Copy link
Author

Sending cmd get_prop with params ['power']
['on']
Sending cmd get_prop with params ['mode']
['auto']
Sending cmd get_prop with params ['humidity']
[67]
Sending cmd get_prop with params ['buzzer']
['on']
Sending cmd get_prop with params ['led_b']
[1]
Sending cmd get_prop with params ['child_lock']
['off']
Sending cmd get_prop with params ['limit_hum']
[70]
Sending cmd get_prop with params ['use_time']
[33258]
Sending cmd get_prop with params ['hw_version']
['0001']
Sending cmd get_prop with params ['temp_dec']
[250]
Sending cmd get_prop with params ['speed']
[704]
Sending cmd get_prop with params ['depth']
[125]
Sending cmd get_prop with params ['dry']
['on']

But this was 2nd try. At start again was Error: Unable to discover the device 192.168.1.144.

@syssi
Copy link
Collaborator

syssi commented Jun 2, 2019

You should use the new command line interface to use the CA1 specific implementation:

miiocli airhumidifierca1 --ip IP --token TOKEN info
miiocli airhumidifierca1 --ip IP --token TOKEN status
miiocli airhumidifierca1 --ip IP --token TOKEN on
miiocli airhumidifierca1 --ip IP --token TOKEN fff
miiocli airhumidifierca1 --ip IP --token TOKEN
...

And please make sure your WiFi is stable. The communication is UDP and unstable on packet loss.

@tolikheha
Copy link
Author

tolikheha commented Jun 2, 2019

None of them works. Same issue, Error: Unable to discover the device 192.168.1.144.
And wifi looks stable. I pinging other PC while checking all this.

@syssi
Copy link
Collaborator

syssi commented Jun 2, 2019

This is strange and hard to debug. Could you tell me the manufacturer of your access point?

@tolikheha
Copy link
Author

mi router 3g with OpenWrt 18.06.1 r7258-5eb055306f

@syssi
Copy link
Collaborator

syssi commented Jun 2, 2019

Good choice & setup. ;-) Did you block the internet access of the Air Humidifier?

@tolikheha
Copy link
Author

tolikheha commented Jun 2, 2019

Internet access is not blocked.

I tried to use phone as access point and everything worked fine. So this isn't issue of python-miio. I'll try to find out what's wrong with my access point and after update this issue, but I think it can be closed now, as it not related directly to python-miio.
Thanks!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants