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

WIP: Initial support for nextgen vacuums (with prefixed methods) #372

Closed
wants to merge 3 commits into from

Conversation

rytilahti
Copy link
Owner

This adds initial support for vacuums using a different call convention (prefixing some calls with user.). Passing --nextgen (name will probably change or get dropped) option sets this mode active.

This should fix #348, #364 and #370, but testing is needed.

TODO:

  • Status reports (v8 compared to v4 from gen1) contain new values which are not currently exposed: clean_mode, begin_time, clean_trigger, back_trigger, clean_strategy, and completed
    • Help from someone with a device would be appreciated here.
  • Find the best way to autodetect which convention to use without passing a flag.

# clean_mode, begin_time, clean_trigger,
# back_trigger, clean_strategy, and completed
#
#{"msg_ver":8,"msg_seq":60,"state":5,"battery":93,"clean_mode":0,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

block comment should start with '# '

@coveralls
Copy link

coveralls commented Aug 29, 2018

Coverage Status

Coverage decreased (-0.1%) to 72.798% when pulling 7f0f62f on vacuum_gen2 into a271245 on master.

@andrei-khveras
Copy link

@rytilahti I am here and in #370 to help with device.

@rytilahti
Copy link
Owner Author

The status report contains new information (listed in the PR description), it would be nice if you could do some testing to see what values those can be (especially clean_mode, clean_trigger, back_trigger, and clean_strategy).

@andrei-khveras
Copy link

@rytilahti over last days I tried to reverse engineer MI Home APK to find out clean_mode as well as other values meaning in source code w/o any luck. I'll try to analyze status responses that my cleaner will send in different modes during next few weeks and try to figure out how they change. This will not give the full list of possible values though.

@rytilahti
Copy link
Owner Author

rytilahti commented Sep 5, 2018

Ok, thanks. It is not that important anyway. I suppose the modes are something like "scheduled cleaning", "user initiated cleaning" or so. which isn't necessarily so important. Is this working for you know otherwise?

edit: apparently not (wrt. discussion in #364). maybe that device does not use the same prefix as roborock.vacuum.e2? What is the device name (from mirobo discover)? How did you get that raw response you mentined there, when the user.get_status did not work?

@cj-arnas-navasinskas
Copy link

Do we know when this will be done ? any help needed ? My robot is awaiting automation !

@rytilahti
Copy link
Owner Author

Is this PR working for you? And which vacuum is it (roborock.vacuum.e2 or roborock.vacuum.c1?)? The automatic fallback to the user. prefixed variants is still a TODO before this can be merged.

@cj-arnas-navasinskas
Copy link

Its roborock.vacuum.c1.

I am using this lib altogether with www.home-assistant.io, would be too much hassle to build it myself just for this.

Anyway if needed, I can try this separately from home automation to test stuff.

@Luc3as
Copy link

Luc3as commented Nov 9, 2018

I tried this PR with Xiaowa E352 model, with RAW command I can get status from vacuum, however there is some erro with cleanup() function.

# mirobo --ip 192.168.1.117 --token 1234 raw-command user.get_clean_summary
Sending cmd user.get_clean_summary with params []
[2920, 29000000, 11, [1540004728, 1540008817, 1540009764, 1541779483, 1541782385, 1541790714, 1541791384, 1541792324, 1541799577]]
Traceback (most recent call last):
  File "/usr/local/bin/mirobo", line 11, in <module>
    load_entry_point('python-miio', 'console_scripts', 'mirobo')()
  File "/root/src/python-miio/miio/click_common.py", line 54, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.6/site-packages/click/core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.6/site-packages/click/core.py", line 1102, in _process_result
    **ctx.params)
  File "/usr/local/lib/python3.6/site-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/click/decorators.py", line 64, in new_func
    return ctx.invoke(f, obj, *args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
TypeError: cleanup() takes 1 positional argument but 2 were given

@rytilahti
Copy link
Owner Author

For this PR you should pass --next-gen for now until it's decided how to handle this different API. Could you please try other commands directly, and also post the output of info command?

@Luc3as
Copy link

Luc3as commented Nov 10, 2018

yup, when I try with --nextgen switch I got timeout and no response from device

Sending cmd user.get_clean_summary with params []
ERROR:miio.device:Got error when receiving: timed out
Error: No response from the device

@rytilahti
Copy link
Owner Author

That would be mirobo --nextgen cleaning-history, nextgen simply adds the user. prefix when deemed necessary, otherwise there is no changes in the protocol so it shouldn't really timeout on it.

@Luc3as
Copy link

Luc3as commented Nov 10, 2018 via email

@Luc3as
Copy link

Luc3as commented Nov 10, 2018

So I tried to check the code but I am unable to understand how things works deeply enough.
My findings, when I run mirobo -dd raw-command get_status even without nextgen option, I get bunch of errors but somewhere down there is json with actual status from device.

Sending cmd get_status with params []
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\x04L\xdar\x00\x01\x17\x1a' (total 16)
        value = Container:
            length = 32
            unknown = 0
            device_id = b'\x04L\xdar' (total 4)
            ts = 1970-01-01 19:50:50
        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: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\x04L\xdar\x00\x01\x17\x1a' (total 16)
        value = Container:
            length = 32
            unknown = 0
            device_id = b'\x04L\xdar' (total 4)
            ts = 1970-01-01 19:50:50
        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 044cda72 with ts: 1970-01-01 19:50:50, token: b'00000000000000000000000000000000'
DEBUG:miio.device:192.168.1.117:54321 >>: {'id': 1, 'method': 'get_status', 'params': []}
DEBUG:miio.device:send (timeout 5): Container:
    data = Container:
        data = b'\xa1\x8dz\xf95\xc8\xa4\xb9\xf2\xd0\x91\x1e\xf3\xa3\xacX'... (truncated, total 64)
        value = {'id': 1, 'method': 'get_status', 'params': []}
        offset1 = 32
        offset2 = 96
        length = 64
    header = Container:
        data = b'!1\x00`\x00\x00\x00\x00\x04L\xdar\x00\x01\x17\x1b' (total 16)
        value = Container:
            length = 96
            unknown = 0
            device_id = b'\x04L\xdar' (total 4)
            ts = 1970-01-01 19:50:51
        offset1 = 0
        offset2 = 16
        length = 16
    checksum = b'`=\x12\n\x13\xf0\xf6\xaa\xed\x87\xb9\x9f\x1bV\xe4\xfd' (total 16)
DEBUG:miio.device:recv from 192.168.1.117: Container:
    data = Container:
        data = b'\x08\\ZC\xde\x9f\x9b\x00\x18S|\xa6\xdbf\xd7\xdc'... (truncated, total 304)
        value = {'result': [{'msg_ver': 8, 'msg_seq': 918, 'state': 8, 'battery': 100, 'clean_mode': 0, 'fan_power': 68, 'error_code': 0, 'map_present': 1, 'in_cleaning': 0, 'dnd_enabled': 0, 'begin_time': 1541855166, 'clean_time': 665, 'clean_area': 14287500, 'clean_trigger': 1, 'back_trigger': 6, 'completed': 1, 'clean_strategy': 0}], 'id': 1}
        offset1 = 32
        offset2 = 336
        length = 304
    header = Container:
        data = b'!1\x01P\x00\x00\x00\x00\x04L\xdar\x00\x01\x17\x1a' (total 16)
        value = Container:
            length = 336
            unknown = 0
            device_id = b'\x04L\xdar' (total 4)
            ts = 1970-01-01 19:50:50
        offset1 = 0
        offset2 = 16
        length = 16
    checksum = b'\x85\x1a\xe6\x04\xdb\x1eW2\xc4\xadh\x1f\xbf\x96\xf2g' (total 16)
DEBUG:miio.device:192.168.1.117:54321 (ts: 1970-01-01 19:50:50, id: 1) << {'result': [{'msg_ver': 8, 'msg_seq': 918, 'state': 8, 'battery': 100, 'clean_mode': 0, 'fan_power': 68, 'error_code': 0, 'map_present': 1, 'in_cleaning': 0, 'dnd_enabled': 0, 'begin_time': 1541855166, 'clean_time': 665, 'clean_area': 14287500, 'clean_trigger': 1, 'back_trigger': 6, 'completed': 1, 'clean_strategy': 0}], 'id': 1}
[{'msg_ver': 8, 'msg_seq': 918, 'state': 8, 'battery': 100, 'clean_mode': 0, 'fan_power': 68, 'error_code': 0, 'map_present': 1, 'in_cleaning': 0, 'dnd_enabled': 0, 'begin_time': 1541855166, 'clean_time': 665, 'clean_area': 14287500, 'clean_trigger': 1, 'back_trigger': 6, 'completed': 1, 'clean_strategy': 0}]
Traceback (most recent call last):
  File "/usr/local/bin/mirobo", line 11, in <module>
    load_entry_point('python-miio', 'console_scripts', 'mirobo')()
  File "/root/src/python-miio/miio/click_common.py", line 54, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.6/site-packages/click/core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.6/site-packages/click/core.py", line 1102, in _process_result
    **ctx.params)
  File "/usr/local/lib/python3.6/site-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/click/decorators.py", line 64, in new_func
    return ctx.invoke(f, obj, *args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
TypeError: cleanup() takes 1 positional argument but 2 were given

when I try mirobo status

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\x04L\xdar\x00\x01\x18\x04' (total 16)
        value = Container:
            length = 32
            unknown = 0
            device_id = b'\x04L\xdar' (total 4)
            ts = 1970-01-01 19:54:44
        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: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\x04L\xdar\x00\x01\x18\x04' (total 16)
        value = Container:
            length = 32
            unknown = 0
            device_id = b'\x04L\xdar' (total 4)
            ts = 1970-01-01 19:54:44
        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 044cda72 with ts: 1970-01-01 19:54:44, token: b'00000000000000000000000000000000'
DEBUG:miio.device:192.168.1.117:54321 >>: {'id': 1, 'method': 'get_status'}
DEBUG:miio.device:send (timeout 5): Container:
    data = Container:
        data = b'\xa1\x8dz\xf95\xc8\xa4\xb9\xf2\xd0\x91\x1e\xf3\xa3\xacX'... (truncated, total 48)
        value = {'id': 1, 'method': 'get_status'}
        offset1 = 32
        offset2 = 80
        length = 48
    header = Container:
        data = b'!1\x00P\x00\x00\x00\x00\x04L\xdar\x00\x01\x18\x05' (total 16)
        value = Container:
            length = 80
            unknown = 0
            device_id = b'\x04L\xdar' (total 4)
            ts = 1970-01-01 19:54:45
        offset1 = 0
        offset2 = 16
        length = 16
    checksum = b':\xbcOVi?\xfb\xaf!2~"E\xd5\xe2\x1f' (total 16)
DEBUG:miio.device:recv from 192.168.1.117: Container:
    data = Container:
        data = b'\xf2\xe2\xaa\xaf\x9e\xae\xcca\xb7G{\x1f|\x9eM\xd8'... (truncated, total 80)
        value = {'id': 1, 'error': {'code': -32600, 'message': 'Req object invalid.'}}
        offset1 = 32
        offset2 = 112
        length = 80
    header = Container:
        data = b'!1\x00p\x00\x00\x00\x00\x04L\xdar\x00\x01\x18\x05' (total 16)
        value = Container:
            length = 112
            unknown = 0
            device_id = b'\x04L\xdar' (total 4)
            ts = 1970-01-01 19:54:45
        offset1 = 0
        offset2 = 16
        length = 16
    checksum = b'<$A\xc8\xa2w!\x06\x87\xc7\x9bv\x9a\xa2s\x98' (total 16)
DEBUG:miio.device:192.168.1.117:54321 (ts: 1970-01-01 19:54:45, id: 1) << {'id': 1, 'error': {'code': -32600, 'message': 'Req object invalid.'}}
DEBUG:miio.click_common:Exception: {'code': -32600, 'message': 'Req object invalid.'}
Traceback (most recent call last):
  File "/root/src/python-miio/miio/click_common.py", line 54, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.6/site-packages/click/core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.6/site-packages/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.6/site-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/click/decorators.py", line 64, in new_func
    return ctx.invoke(f, obj, *args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/root/src/python-miio/miio/vacuum_cli.py", line 107, in status
    res = vac.status()
  File "/root/src/python-miio/miio/vacuum.py", line 161, in status
    return VacuumStatus(self.send("get_status")[0])
  File "/root/src/python-miio/miio/vacuum.py", line 56, in send
    return super().send(command, parameters, retry_count)
  File "/root/src/python-miio/miio/device.py", line 268, in send
    raise DeviceError(m.data.value["error"])
miio.exceptions.DeviceError: {'code': -32600, 'message': 'Req object invalid.'}
Error: {'code': -32600, 'message': 'Req object invalid.'}

with mirobo --nextgen -dd status exactly the same.

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\x04L\xdar\x00\x01\x18\x1f' (total 16)
        value = Container:
            length = 32
            unknown = 0
            device_id = b'\x04L\xdar' (total 4)
            ts = 1970-01-01 19:55:11
        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: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\x04L\xdar\x00\x01\x18\x1f' (total 16)
        value = Container:
            length = 32
            unknown = 0
            device_id = b'\x04L\xdar' (total 4)
            ts = 1970-01-01 19:55:11
        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 044cda72 with ts: 1970-01-01 19:55:11, token: b'00000000000000000000000000000000'
DEBUG:miio.device:192.168.1.117:54321 >>: {'id': 1, 'method': 'user.get_status'}
DEBUG:miio.device:send (timeout 5): Container:
    data = Container:
        data = b'\xa1\x8dz\xf95\xc8\xa4\xb9\xf2\xd0\x91\x1e\xf3\xa3\xacX'... (truncated, total 48)
        value = {'id': 1, 'method': 'user.get_status'}
        offset1 = 32
        offset2 = 80
        length = 48
    header = Container:
        data = b'!1\x00P\x00\x00\x00\x00\x04L\xdar\x00\x01\x18 ' (total 16)
        value = Container:
            length = 80
            unknown = 0
            device_id = b'\x04L\xdar' (total 4)
            ts = 1970-01-01 19:55:12
        offset1 = 0
        offset2 = 16
        length = 16
    checksum = b'\xe9\xe9!\xb3F\xa5\xa1t\\t9\xa9\xdd\xf7D\x12' (total 16)
DEBUG:miio.device:recv from 192.168.1.117: Container:
    data = Container:
        data = b'\xf2\xe2\xaa\xaf\x9e\xae\xcca\xb7G{\x1f|\x9eM\xd8'... (truncated, total 80)
        value = {'id': 1, 'error': {'code': -32600, 'message': 'Req object invalid.'}}
        offset1 = 32
        offset2 = 112
        length = 80
    header = Container:
        data = b'!1\x00p\x00\x00\x00\x00\x04L\xdar\x00\x01\x18 ' (total 16)
        value = Container:
            length = 112
            unknown = 0
            device_id = b'\x04L\xdar' (total 4)
            ts = 1970-01-01 19:55:12
        offset1 = 0
        offset2 = 16
        length = 16
    checksum = b"\xe1#\xe8\xb4\t\xc0'M\xab\xe0\xb0a\xce_\xfa\xf1" (total 16)
DEBUG:miio.device:192.168.1.117:54321 (ts: 1970-01-01 19:55:12, id: 1) << {'id': 1, 'error': {'code': -32600, 'message': 'Req object invalid.'}}
DEBUG:miio.click_common:Exception: {'code': -32600, 'message': 'Req object invalid.'}
Traceback (most recent call last):
  File "/root/src/python-miio/miio/click_common.py", line 54, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.6/site-packages/click/core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.6/site-packages/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.6/site-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/click/decorators.py", line 64, in new_func
    return ctx.invoke(f, obj, *args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/root/src/python-miio/miio/vacuum_cli.py", line 107, in status
    res = vac.status()
  File "/root/src/python-miio/miio/vacuum.py", line 161, in status
    return VacuumStatus(self.send("get_status")[0])
  File "/root/src/python-miio/miio/vacuum.py", line 56, in send
    return super().send(command, parameters, retry_count)
  File "/root/src/python-miio/miio/device.py", line 268, in send
    raise DeviceError(m.data.value["error"])
miio.exceptions.DeviceError: {'code': -32600, 'message': 'Req object invalid.'}
Error: {'code': -32600, 'message': 'Req object invalid.'}

Output of info

roborock.vacuum.e2 v1.3.0_0542 (78:11:DC:5E:9C:A5) @ 192.168.1.117 - token: 1234
Traceback (most recent call last):
  File "/usr/local/bin/mirobo", line 11, in <module>
    load_entry_point('python-miio', 'console_scripts', 'mirobo')()
  File "/root/src/python-miio/miio/click_common.py", line 54, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.6/site-packages/click/core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.6/site-packages/click/core.py", line 1102, in _process_result
    **ctx.params)
  File "/usr/local/lib/python3.6/site-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/click/decorators.py", line 64, in new_func
    return ctx.invoke(f, obj, *args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
TypeError: cleanup() takes 1 positional argument but 2 were given

info with nextgen is timeout

INFO:miio.vacuum_cli:Debug mode active
DEBUG:miio.vacuum_cli:Connecting to 192.168.1.117 with token 1234
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\x04L\xdar\x00\x01\x190' (total 16)
        value = Container:
            length = 32
            unknown = 0
            device_id = b'\x04L\xdar' (total 4)
            ts = 1970-01-01 19:59:44
        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: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\x04L\xdar\x00\x01\x190' (total 16)
        value = Container:
            length = 32
            unknown = 0
            device_id = b'\x04L\xdar' (total 4)
            ts = 1970-01-01 19:59:44
        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 044cda72 with ts: 1970-01-01 19:59:44, token: b'00000000000000000000000000000000'
DEBUG:miio.device:192.168.1.117:54321 >>: {'id': 1, 'method': 'user.miIO.info', 'params': []}
DEBUG:miio.device:send (timeout 5): Container:
    data = Container:
        data = b'\xa1\x8dz\xf95\xc8\xa4\xb9\xf2\xd0\x91\x1e\xf3\xa3\xacX'... (truncated, total 64)
        value = {'id': 1, 'method': 'user.miIO.info', 'params': []}
        offset1 = 32
        offset2 = 96
        length = 64
    header = Container:
        data = b'!1\x00`\x00\x00\x00\x00\x04L\xdar\x00\x01\x191' (total 16)
        value = Container:
            length = 96
            unknown = 0
            device_id = b'\x04L\xdar' (total 4)
            ts = 1970-01-01 19:59:45
        offset1 = 0
        offset2 = 16
        length = 16
    checksum = b'\xde\xf0\x0b\x8d>\xfe\xfa\x11U\x1e\xb2\x13\x98\x02\xd7\x1a' (total 16)
DEBUG:miio.device:Retrying with incremented id, retries left: 3
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\x04L\xdar\x00\x01\x195' (total 16)
        value = Container:
            length = 32
            unknown = 0
            device_id = b'\x04L\xdar' (total 4)
            ts = 1970-01-01 19:59:49
        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: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\x04L\xdar\x00\x01\x195' (total 16)
        value = Container:
            length = 32
            unknown = 0
            device_id = b'\x04L\xdar' (total 4)
            ts = 1970-01-01 19:59:49
        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 044cda72 with ts: 1970-01-01 19:59:49, token: b'00000000000000000000000000000000'
DEBUG:miio.device:192.168.1.117:54321 >>: {'id': 102, 'method': 'user.user.miIO.info', 'params': []}
DEBUG:miio.device:send (timeout 5): Container:
    data = Container:
        data = b'\xd5\xdb`\x87\xb1TrO\x05\x94h\tP\xc4\xc7\xff'... (truncated, total 64)
        value = {'id': 102, 'method': 'user.user.miIO.info', 'params': []}
        offset1 = 32
        offset2 = 96
        length = 64
    header = Container:
        data = b'!1\x00`\x00\x00\x00\x00\x04L\xdar\x00\x01\x196' (total 16)
        value = Container:
            length = 96
            unknown = 0
            device_id = b'\x04L\xdar' (total 4)
            ts = 1970-01-01 19:59:50
        offset1 = 0
        offset2 = 16
        length = 16
    checksum = b'xv\x89\x93\xbelV\x9d\xba\xe1s\xd8\xe2\x93\xcb\xb9' (total 16)
DEBUG:miio.device:Retrying with incremented id, retries left: 2
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\x04L\xdar\x00\x01\x19:' (total 16)
        value = Container:
            length = 32
            unknown = 0
            device_id = b'\x04L\xdar' (total 4)
            ts = 1970-01-01 19:59:54
        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: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\x04L\xdar\x00\x01\x19:' (total 16)
        value = Container:
            length = 32
            unknown = 0
            device_id = b'\x04L\xdar' (total 4)
            ts = 1970-01-01 19:59:54
        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 044cda72 with ts: 1970-01-01 19:59:54, token: b'00000000000000000000000000000000'
DEBUG:miio.device:192.168.1.117:54321 >>: {'id': 203, 'method': 'user.user.user.miIO.info', 'params': []}
DEBUG:miio.device:send (timeout 5): Container:
    data = Container:
        data = b'\xf8\x1e@9\xe3s\xe1&i\xa0\xa0|SX\x19K'... (truncated, total 80)
        value = {'id': 203, 'method': 'user.user.user.miIO.info', 'params': []}
        offset1 = 32
        offset2 = 112
        length = 80
    header = Container:
        data = b'!1\x00p\x00\x00\x00\x00\x04L\xdar\x00\x01\x19;' (total 16)
        value = Container:
            length = 112
            unknown = 0
            device_id = b'\x04L\xdar' (total 4)
            ts = 1970-01-01 19:59:55
        offset1 = 0
        offset2 = 16
        length = 16
    checksum = b',\xea\x8ae*O\x04Ha8\x125F\x98\xc3\xa2' (total 16)
DEBUG:miio.device:Retrying with incremented id, retries left: 1
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\x04L\xdar\x00\x01\x19?' (total 16)
        value = Container:
            length = 32
            unknown = 0
            device_id = b'\x04L\xdar' (total 4)
            ts = 1970-01-01 19:59:59
        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: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\x04L\xdar\x00\x01\x19?' (total 16)
        value = Container:
            length = 32
            unknown = 0
            device_id = b'\x04L\xdar' (total 4)
            ts = 1970-01-01 19:59:59
        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 044cda72 with ts: 1970-01-01 19:59:59, token: b'00000000000000000000000000000000'
DEBUG:miio.device:192.168.1.117:54321 >>: {'id': 304, 'method': 'user.user.user.user.miIO.info', 'params': []}
DEBUG:miio.device:send (timeout 5): Container:
    data = Container:
        data = b'\x8b\xf0\x88/[\xb7xB[1E\x93\x04]\xdd('... (truncated, total 80)
        value = {'id': 304, 'method': 'user.user.user.user.miIO.info', 'params': []}
        offset1 = 32
        offset2 = 112
        length = 80
    header = Container:
        data = b'!1\x00p\x00\x00\x00\x00\x04L\xdar\x00\x01\x19@' (total 16)
        value = Container:
            length = 112
            unknown = 0
            device_id = b'\x04L\xdar' (total 4)
            ts = 1970-01-01 20:00:00
        offset1 = 0
        offset2 = 16
        length = 16
    checksum = b'\xe4\x9dU\xa1P\x1c\x0b\xe5N\xff\xb1X\x87\xdan\x9e' (total 16)
ERROR:miio.device:Got error when receiving: timed out
DEBUG:miio.click_common:Exception: No response from the device
Traceback (most recent call last):
  File "/root/src/python-miio/miio/device.py", line 255, in send
    data, addr = s.recvfrom(1024)
socket.timeout: timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/root/src/python-miio/miio/device.py", line 255, in send
    data, addr = s.recvfrom(1024)
socket.timeout: timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/root/src/python-miio/miio/device.py", line 255, in send
    data, addr = s.recvfrom(1024)
socket.timeout: timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/root/src/python-miio/miio/device.py", line 255, in send
    data, addr = s.recvfrom(1024)
socket.timeout: timed out

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/root/src/python-miio/miio/click_common.py", line 54, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.6/site-packages/click/core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.6/site-packages/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.6/site-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/click/decorators.py", line 64, in new_func
    return ctx.invoke(f, obj, *args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/root/src/python-miio/miio/vacuum_cli.py", line 403, in info
    res = vac.info()
  File "/root/src/python-miio/miio/device.py", line 315, in info
    return DeviceInfo(self.send("miIO.info", []))
  File "/root/src/python-miio/miio/vacuum.py", line 56, in send
    return super().send(command, parameters, retry_count)
  File "/root/src/python-miio/miio/device.py", line 284, in send
    return self.send(command, parameters, retry_count - 1)
  File "/root/src/python-miio/miio/vacuum.py", line 56, in send
    return super().send(command, parameters, retry_count)
  File "/root/src/python-miio/miio/device.py", line 284, in send
    return self.send(command, parameters, retry_count - 1)
  File "/root/src/python-miio/miio/vacuum.py", line 56, in send
    return super().send(command, parameters, retry_count)
  File "/root/src/python-miio/miio/device.py", line 284, in send
    return self.send(command, parameters, retry_count - 1)
  File "/root/src/python-miio/miio/vacuum.py", line 56, in send
    return super().send(command, parameters, retry_count)
  File "/root/src/python-miio/miio/device.py", line 287, in send
    raise DeviceException("No response from the device") from ex
miio.exceptions.DeviceException: No response from the device
Error: No response from the device

Do you have chance what is wrong and point me to some direction what can I try to change ?

@rytilahti
Copy link
Owner Author

rytilahti commented Nov 10, 2018

@Luc3as Ah, now I think I know what is happening. Your vacuum expects the "old-style" commands, I suppose, but requires that the parameters list is passed along with it. Could you please try #408 to see if that helps?

Related to the cleanup callback, could you also post pip freeze|grep click? There has been some changes in newer click versions, which may cause that. Could you create a separate issue for that though, thanks!

edit: to add, I cherry-picked the #408 here, as it seems to be necessary for making the vacuums expecting empty parameters if none are given. To sum it up:

This seems to work fine with yeelight and gen1 vacuum,
however, more testing is needed with other devices and/or this change
should only be done for the vacuum.

Related to #348 / Xiaowa E352
@cj-arnas-navasinskas
Copy link

cj-arnas-navasinskas commented Nov 13, 2018

Hi, roborock.vacuum.c1 here.

Everything works (all the cleaning functions, status, timers, etc.) using --nextgen, apart from:
mirobo --debug --nextgen serial-number

INFO:miio.vacuum_cli:Debug mode active
DEBUG:miio.vacuum_cli:Read stored sequence ids: {'seq': 133, 'manual_seq': 0}
DEBUG:miio.vacuum_cli:Connecting to 1.1.1.90 with token ccf5863d202af55e3855b96fb3e5c269
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\x05\x0c\xe8\x18\x00\x00U\x90' (total 16)
        value = Container:
            length = 32
            unknown = 0
            device_id = b'\x05\x0c\xe8\x18' (total 4)
            ts = 1970-01-01 06:05:04
        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 050ce818 with ts: 1970-01-01 06:05:04, token: b'00000000000000000000000000000000'
DEBUG:miio.device:1.1.1.90:54321 >>: {'id': 134, 'method': 'user.get_serial_number', 'params': []}
DEBUG:miio.device:1.1.1.90:54321 (ts: 1970-01-01 06:05:05, id: 134) << {'result': ['OK'], 'id': 134}
Traceback (most recent call last):
  File "C:\Program Files\Python\Python37\Scripts\mirobo-script.py", line 11, in <module>
    load_entry_point('python-miio==0.4.9', 'console_scripts', 'mirobo')()
  File "c:\program files\python\python37\lib\site-packages\python_miio-0.4.9-py3.7.egg\miio\click_common.py", line 54, in __call__
    return self.main(*args, **kwargs)
  File "c:\program files\python\python37\lib\site-packages\click\core.py", line 717, in main
    rv = self.invoke(ctx)
  File "c:\program files\python\python37\lib\site-packages\click\core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "c:\program files\python\python37\lib\site-packages\click\core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "c:\program files\python\python37\lib\site-packages\click\core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "c:\program files\python\python37\lib\site-packages\click\decorators.py", line 64, in new_func
    return ctx.invoke(f, obj, *args, **kwargs)
  File "c:\program files\python\python37\lib\site-packages\click\core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "c:\program files\python\python37\lib\site-packages\python_miio-0.4.9-py3.7.egg\miio\vacuum_cli.py", line 506, in serial_number
    click.echo("Serial#: %s" % vac.serial_number())
  File "c:\program files\python\python37\lib\site-packages\python_miio-0.4.9-py3.7.egg\miio\vacuum.py", line 373, in serial_number
    return self.send("get_serial_number")[0]["serial_number"]
TypeError: string indices must be integers

mirobo --debug --nextgen sound

INFO:miio.vacuum_cli:Debug mode active
DEBUG:miio.vacuum_cli:Read stored sequence ids: {'seq': 133, 'manual_seq': 0}
DEBUG:miio.vacuum_cli:Connecting to 1.1.1.90 with token ccf5863d202af55e3855b96fb3e5c269
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\x05\x0c\xe8\x18\x00\x00U\xe8' (total 16)
        value = Container:
            length = 32
            unknown = 0
            device_id = b'\x05\x0c\xe8\x18' (total 4)
            ts = 1970-01-01 06:06:32
        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 050ce818 with ts: 1970-01-01 06:06:32, token: b'00000000000000000000000000000000'
DEBUG:miio.device:1.1.1.90:54321 >>: {'id': 134, 'method': 'user.get_current_sound', 'params': []}
DEBUG:miio.device:1.1.1.90:54321 (ts: 1970-01-01 06:06:32, id: 134) << {'result': ['OK'], 'id': 134}
Traceback (most recent call last):
  File "C:\Program Files\Python\Python37\Scripts\mirobo-script.py", line 11, in <module>
    load_entry_point('python-miio==0.4.9', 'console_scripts', 'mirobo')()
  File "c:\program files\python\python37\lib\site-packages\python_miio-0.4.9-py3.7.egg\miio\click_common.py", line 54, in __call__
    return self.main(*args, **kwargs)
  File "c:\program files\python\python37\lib\site-packages\click\core.py", line 717, in main
    rv = self.invoke(ctx)
  File "c:\program files\python\python37\lib\site-packages\click\core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "c:\program files\python\python37\lib\site-packages\click\core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "c:\program files\python\python37\lib\site-packages\click\core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "c:\program files\python\python37\lib\site-packages\click\decorators.py", line 64, in new_func
    return ctx.invoke(f, obj, *args, **kwargs)
  File "c:\program files\python\python37\lib\site-packages\click\core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "c:\program files\python\python37\lib\site-packages\python_miio-0.4.9-py3.7.egg\miio\vacuum_cli.py", line 444, in sound
    click.echo("Current sound: %s" % vac.sound_info())
  File "c:\program files\python\python37\lib\site-packages\python_miio-0.4.9-py3.7.egg\miio\vacuumcontainers.py", line 423, in __repr__
    self.current,
  File "c:\program files\python\python37\lib\site-packages\python_miio-0.4.9-py3.7.egg\miio\vacuumcontainers.py", line 415, in current
    return self.data['sid_in_use']
TypeError: string indices must be integers

And if I ask for status after these commands throwing, status also throws:

mirobo --debug status

INFO:miio.vacuum_cli:Debug mode active
DEBUG:miio.vacuum_cli:Read stored sequence ids: {'seq': 174, 'manual_seq': 0}
DEBUG:miio.vacuum_cli:Connecting to 1.1.1.90 with token ccf5863d202af55e3855b96fb3e5c269
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\x05\x0c\xe8\x18\x00\x00\\\xa6' (total 16)
        value = Container:
            length = 32
            unknown = 0
            device_id = b'\x05\x0c\xe8\x18' (total 4)
            ts = 1970-01-01 06:35:18
        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 050ce818 with ts: 1970-01-01 06:35:18, token: b'00000000000000000000000000000000'
DEBUG:miio.device:1.1.1.90:54321 >>: {'id': 175, 'method': 'get_status', 'params': []}
DEBUG:miio.device:1.1.1.90:54321 (ts: 1970-01-01 06:35:18, id: 175) << {'result': ['OK'], 'id': 175}
Traceback (most recent call last):
  File "C:\Program Files\Python\Python37\Scripts\mirobo-script.py", line 11, in <module>
    load_entry_point('python-miio==0.4.10', 'console_scripts', 'mirobo')()
  File "c:\program files\python\python37\lib\site-packages\python_miio-0.4.10-py3.7.egg\miio\click_common.py", line 54, in __call__
    return self.main(*args, **kwargs)
  File "c:\program files\python\python37\lib\site-packages\click\core.py", line 717, in main
    rv = self.invoke(ctx)
  File "c:\program files\python\python37\lib\site-packages\click\core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "c:\program files\python\python37\lib\site-packages\click\core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "c:\program files\python\python37\lib\site-packages\click\core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "c:\program files\python\python37\lib\site-packages\click\decorators.py", line 64, in new_func
    return ctx.invoke(f, obj, *args, **kwargs)
  File "c:\program files\python\python37\lib\site-packages\click\core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "c:\program files\python\python37\lib\site-packages\python_miio-0.4.10-py3.7.egg\miio\vacuum_cli.py", line 110, in status
    if res.error_code:
  File "c:\program files\python\python37\lib\site-packages\python_miio-0.4.10-py3.7.egg\miio\vacuumcontainers.py", line 81, in error_code
    return int(self.data["error_code"])
TypeError: string indices must be integers

Asking for successful stuff (like stop) will return a correct status once again, I guess maybe status returns last error which we're unable to parse or something like that.

@Luc3as
Copy link

Luc3as commented Nov 13, 2018 via email

@cj-arnas-navasinskas
Copy link

roborock.vacuum.c1

With #408 it works without --nextgen same as with this with --nextgen.

@rytilahti
Copy link
Owner Author

Thanks @Arnasnn for reporting back! I think that this PR is then completely unnecessary (except for the parts of new status information provided by those vacuums) and can be superseded with #408 when it'
s ready!

@rytilahti
Copy link
Owner Author

Obsoleted by #408.

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

Successfully merging this pull request may close these issues.

Support for new vacuum model Xiaowa E20
6 participants