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

No working with Xiaowa (roborock.vacuum.c1 v1.3.0) #370

Closed
andrei-khveras opened this issue Aug 27, 2018 · 18 comments
Closed

No working with Xiaowa (roborock.vacuum.c1 v1.3.0) #370

andrei-khveras opened this issue Aug 27, 2018 · 18 comments

Comments

@andrei-khveras
Copy link

andrei-khveras commented Aug 27, 2018

Cleaner: roborock.vacuum.c1 v1.3.0
Ubuntu 18, python 3.6

After successful
mirobo discover --handshake true

Getting
Error: {'code': -32600, 'message': 'Req object invalid.'}
when executing
mirobo --ip=XXX --token=YYY status

When executing
mirobo --ip=XXX --token=YYY install_sound ru_maxim_universal.pkg
getting

  File "/home/ubuntu/.local/bin/mirobo", line 11, in <module>
    load_entry_point('python-miio==0.4.1', 'console_scripts', 'mirobo')()
  File "/home/ubuntu/.local/lib/python3.6/site-packages/miio/click_common.py", line 54, in __call__
    return self.main(*args, **kwargs)
  File "/home/ubuntu/.local/lib/python3.6/site-packages/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/home/ubuntu/.local/lib/python3.6/site-packages/click/core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/ubuntu/.local/lib/python3.6/site-packages/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/ubuntu/.local/lib/python3.6/site-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/home/ubuntu/.local/lib/python3.6/site-packages/click/decorators.py", line 64, in new_func
    return ctx.invoke(f, obj, *args[1:], **kwargs)
  File "/home/ubuntu/.local/lib/python3.6/site-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/home/ubuntu/.local/lib/python3.6/site-packages/miio/vacuum_cli.py", line 483, in install_sound
    click.echo(vac.install_sound(local_url, md5sum, sid))
  File "/home/ubuntu/.local/lib/python3.6/site-packages/click/utils.py", line 221, in echo
    message = text_type(message)
  File "/home/ubuntu/.local/lib/python3.6/site-packages/miio/vacuumcontainers.py", line 473, in __repr__
    " - progress: %s>" % (self.sid, self.state,
  File "/home/ubuntu/.local/lib/python3.6/site-packages/miio/vacuumcontainers.py", line 453, in sid
    return self.data.get('sid_in_progress', None)
AttributeError: 'str' object has no attribute 'get'
ERROR:miio.updater:No request was made..```
@andrei-khveras
Copy link
Author

@rytilahti I don't have experience in Python coding unfortunately,
but if I can help you with checking some things / collecting logs on my physical device, please, let me know.

@rytilahti
Copy link
Owner

For the first one, maybe this vacuum uses the same scheme as seen in #364? You could try mirobo raw_command user.get_status to see if that works.

For the second one you should try the command with -d to see what is being returned by the device.

(btw, when you use triple-backticks it will format multi-line code properly, I edited the initial message accordingly)

@andrei-khveras
Copy link
Author

andrei-khveras commented Aug 29, 2018

Hi @rytilahti .
Here's my update.
mirobo raw_command user.get_status
resulted in
[{'msg_ver': 8, 'msg_seq': 313, 'state': 8, 'battery': 100, 'clean_mode': 0, 'fan_power': 62, 'error_code': 0, 'map_present': 0, 'in_cleaning': 0, 'dnd_enabled': 1, 'begin_time': 1535557799, 'clean_time': 3635, 'clean_area': 0, 'clean_trigger': 2, 'back_trigger': 6, 'completed': 1}]

Enabling debug mode added the following to the install_sound command output:

DEBUG:miio.vacuum_cli:Read stored sequence ids: {'seq': 2, 'manual_seq': 0}
DEBUG:miio.vacuum_cli:Connecting to XXX with token YYY
Installing from ru_maxim_universal.pkg (md5: None) for id 10000
INFO:miio.updater:Serving on 0.0.0.0:43679, timeout 10
INFO:miio.updater:Using local ru_maxim_universal.pkg (md5: 46022838228679ffd598ec2b44a54b2d)
DEBUG:miio.updater:available interfaces: ['enp0s3']
DEBUG:miio.updater:Got addr: 192.168.0.101
Hosting file at http://192.168.0.101:43679/ru_maxim_universal.pkg
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\x05vAx\x00\x00\x04\x92' (total 16)
        value = Container: 
            length = 32
            unknown = 0
            device_id = b'\x05vAx' (total 4)
            ts = 1970-01-01 00:19:30
        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 05764178 with ts: 1970-01-01 00:19:30, token: b'00000000000000000000000000000000'
DEBUG:miio.device:192.168.0.100:54321 >>: {'id': 3, 'method': 'dnld_install_sound', 'params': {'url': 'http://192.168.0.101:43679/ru_maxim_universal.pkg', 'md5': '46022838228679ffd598ec2b44a54b2d', 'sid': 10000}}
DEBUG:miio.device:192.168.0.100:54321 (ts: 1970-01-01 00:19:30, id: 3) << {'result': ['OK'], 'id': 3}

The rest is the same traceback ending by 'No request was made..' as in my earlier message.

@rytilahti
Copy link
Owner

The API has changed for dlnd_install_sound, so that's the likely problem here. However, the format is also changed (see #348), so to get that working may require some more changes.

Anyway, the PR I linked should fix the basic functionality, it would be nice if you could give it a try and report back:

<activate your virtualenv>
pip install -e git+https://github.com/rytilahti/python-miio.git@refs/pull/372/head#egg=python-miio
mirobo --nextgen --ip=XXX --token=1234 <command>

@andrei-khveras
Copy link
Author

andrei-khveras commented Aug 30, 2018

Hi, @rytilahti
The command you provided above to upgrade python-miio from branch didn't work for me.

pip install -e git+https://github.com/rytilahti/python-miio.git@refs/pull/372/head#egg=python-miio
Obtaining python-miio from git+https://github.com/rytilahti/python-miio.git@refs/pull/372/head#egg=python-miio
  Updating ./src/python-miio clone (to refs/pull/372/head)
  Could not find a tag or branch 'refs/pull/372/head', assuming commit.
fatal: ambiguous argument 'refs/pull/372/head': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
Command "git reset --hard -q refs/pull/372/head" failed with error code 128 in /home/host/cleaner/src/python-miio

So I modified it to (that I am not sure if it is correct)
pip install --upgrade --force-reinstall -e git+https://github.com/rytilahti/python-miio.git@vacuum_gen2#egg=python-miio
and then selected '(w)ipe' option in dialog that appeared.
Executing
mirobo --nextgen --ip=XX --token=YYY status
resulted in
Error: {'code': -32600, 'message': 'Req object invalid.'} again.
Would you provide correct command to upgrade the package or confirm the command I used is correct? How can I make sure that I am running an upgraded version?

@andrei-khveras
Copy link
Author

P.S. Most likely I didn't pick up the latest update as when I try to use new commands you added in your merge request (locale, firmware_features) it says 'No such command'.

@rytilahti
Copy link
Owner

Yes, apparently it didn't work as expected. You could try to remove the existing source directory and try it again. Or check out https://help.github.com/articles/checking-out-pull-requests-locally/ and/or https://stackoverflow.com/questions/27567846/how-can-i-check-out-a-github-pull-request .

@andrei-khveras
Copy link
Author

andrei-khveras commented Sep 2, 2018

I cloned code from 'vacuum_gen2' branch to local folder and (after cleaning local packages) installed python-miio from there.
Result of mirobo --nextgen --ip=XXX --token=YYY status was the same as earlier.
@rytilahti please check if setup.py and the rest of things are correct so --nextgen command is not ignored.

@rytilahti
Copy link
Owner

It should not matter as setup.py is only used for version checking, so you have to either force the install or use -e (I think). If you do mirobo --help do you see the nextgen flag there?

@andrei-khveras
Copy link
Author

andrei-khveras commented Sep 3, 2018

It looks like I have correct mirobo version as mirobo --help output includes --nextgen option.
Again, I execute the command in the following way:
mirobo --nextgen --ip=XXX --token=YYY status
Is it possible, that I pass arguments not in correct order or I need to provide a value for --nextgen param?

@rytilahti
Copy link
Owner

Is it sending out the correct command? If you add -d or -dd you will see more information what is being done. Maybe there is a bug, I have not tested the code, just created an initial PR for someone (who has access to a device) to try and work on.

@andrei-khveras
Copy link
Author

Hi @rytilahti
This is full output for status command with --nextgen flag

mirobo -dd --nextgen --ip=XXX --token=YYY status
INFO:miio.vacuum_cli:Debug mode active
DEBUG:miio.vacuum_cli:Read stored sequence ids: {'seq': 6, 'manual_seq': 0}
DEBUG:miio.vacuum_cli:Connecting to XXX with token YYY
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\x05vAx\x00\x00\x02\x96' (total 16)
        value = Container: 
            length = 32
            unknown = 0
            device_id = b'\x05vAx' (total 4)
            ts = 1970-01-01 00:11: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: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\x05vAx\x00\x00\x02\x96' (total 16)
        value = Container: 
            length = 32
            unknown = 0
            device_id = b'\x05vAx' (total 4)
            ts = 1970-01-01 00:11: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 05764178 with ts: 1970-01-01 00:11:02, token: b'00000000000000000000000000000000'
DEBUG:miio.device:192.168.0.101:54321 >>: {'id': 7, 'method': 'user.get_status'}
DEBUG:miio.device:send (timeout 5): Container: 
    data = Container: 
        data = b'\xf9@\xc1\xc8M\xbd"\x05\xde\xec\x90\x089\x07\x10P'... (truncated, total 48)
        value = {'id': 7, 'method': 'user.get_status'}
        offset1 = 32
        offset2 = 80
        length = 48
    header = Container: 
        data = b'!1\x00P\x00\x00\x00\x00\x05vAx\x00\x00\x02\x97' (total 16)
        value = Container: 
            length = 80
            unknown = 0
            device_id = b'\x05vAx' (total 4)
            ts = 1970-01-01 00:11:03
        offset1 = 0
        offset2 = 16
        length = 16
    checksum = b'-\x90=Q\x1e\x84\xd0\xec\xf1\xc9B\x11\xd7$:5' (total 16)
DEBUG:miio.device:recv from 192.168.0.101: Container: 
    data = Container: 
        data = b'\xb7\xad\xa0\xd5\x1d\x12\xe5Y\xf3\x82\xf7\x1a\x1b\xb6\x1b\xcb'... (truncated, total 80)
        value = {'id': 7, 'error': {'code': -32600, 'message': 'Req object invalid.'}}
        offset1 = 32
        offset2 = 112
        length = 80
    header = Container: 
        data = b'!1\x00p\x00\x00\x00\x00\x05vAx\x00\x00\x02\x96' (total 16)
        value = Container: 
            length = 112
            unknown = 0
            device_id = b'\x05vAx' (total 4)
            ts = 1970-01-01 00:11:02
        offset1 = 0
        offset2 = 16
        length = 16
    checksum = b'.\xcb\xc6\x02M\xf4\xc6w?<\xdc\xe1\xfca\x11`' (total 16)
DEBUG:miio.device:192.168.0.101:54321 (ts: 1970-01-01 00:11:02, id: 7) << {'id': 7, 'error': {'code': -32600, 'message': 'Req object invalid.'}}
DEBUG:miio.click_common:Exception: {'code': -32600, 'message': 'Req object invalid.'}
Traceback (most recent call last):
  File "/home/host/tmp/python-miio/miio/click_common.py", line 54, in __call__
    return self.main(*args, **kwargs)
  File "/home/host/.local/lib/python3.6/site-packages/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/home/host/.local/lib/python3.6/site-packages/click/core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/host/.local/lib/python3.6/site-packages/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/host/.local/lib/python3.6/site-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/home/host/.local/lib/python3.6/site-packages/click/decorators.py", line 64, in new_func
    return ctx.invoke(f, obj, *args[1:], **kwargs)
  File "/home/host/.local/lib/python3.6/site-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/home/host/tmp/python-miio/miio/vacuum_cli.py", line 107, in status
    res = vac.status()
  File "/home/host/tmp/python-miio/miio/vacuum.py", line 161, in status
    return VacuumStatus(self.send("get_status")[0])
  File "/home/host/tmp/python-miio/miio/vacuum.py", line 56, in send
    return super().send(command, parameters, retry_count)
  File "/home/host/tmp/python-miio/miio/device.py", line 270, in send
    raise DeviceError(m.data.value["error"])
miio.exceptions.DeviceError: {'code': -32600, 'message': 'Req object invalid.'}
Error: {'code': -32600, 'message': 'Req object invalid.'}

Raw response is as follows

[{'msg_ver': 8, 'msg_seq': 480, 'state': 8, 'battery': 100, 'clean_mode': 0, 'fan_power': 75, 'error_code': 0, 'map_present': 0, 'in_cleaning': 0, 'dnd_enabled': 1, 'begin_time': 1536085396, 'clean_time': 139, 'clean_area': 0, 'clean_trigger': 2, 'back_trigger': 0, 'completed': 0}]

@rytilahti
Copy link
Owner

@andrei-khveras I think I found the problem (thanks to @Luc3as). I created a PR #408 (and cherry-picked that to vacuum_gen2), so if you update the PR you could check out if it helps! :-)

@andrei-khveras
Copy link
Author

@rytilahti this is a great news.
I am running into some local issue extracting tokens unfortunately.
I'll try to get back to it as soon as I sort it out (unless somebody else tests this)

rytilahti added a commit that referenced this issue Nov 16, 2018
* Force parameters to be an empty list if none is given

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

* Remove empty lists to use the new default

Fixes #348, #364 and #370.
@rytilahti
Copy link
Owner

This should now work in master (fixed by #408, no clue why this wasn't closed automatically).

@andrei-khveras
Copy link
Author

andrei-khveras commented Nov 17, 2018

Hi @rytilahti
First of all, thank you for your effort!

I picked up the latest changes from master with command

pip install git+https://github.com/rytilahti/python-miio

and tried to execute status and install-sound (former install_sound) commands.

While status command now provides consistent output, install-sound one still results into error:

mirobo -dd --ip=XXX --token=YYY install-sound ru_maxim_universal.pkg
INFO:miio.vacuum_cli:Debug mode active
DEBUG:miio.vacuum_cli:Read stored sequence ids: {'seq': 8, 'manual_seq': 0}
DEBUG:miio.vacuum_cli:Connecting to XXX with token YYY
Installing from ru_maxim_universal.pkg (md5: None) for id 10000
INFO:miio.updater:Serving on 0.0.0.0:41661, timeout 10
INFO:miio.updater:Using local ru_maxim_universal.pkg (md5: 46022838228679ffd598ec2b44a54b2d)
DEBUG:miio.updater:available interfaces: ['enp0s3']
DEBUG:miio.updater:Got addr: 192.168.0.104
Hosting file at http://192.168.0.104:41661/ru_maxim_universal.pkg
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\x05vAx\x00\x00\x06E' (total 16)
        value = Container: 
            length = 32
            unknown = 0
            device_id = b'\x05vAx' (total 4)
            ts = 1970-01-01 00:26:45
        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\x05vAx\x00\x00\x06E' (total 16)
        value = Container: 
            length = 32
            unknown = 0
            device_id = b'\x05vAx' (total 4)
            ts = 1970-01-01 00:26:45
        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 05764178 with ts: 1970-01-01 00:26:45, token: b'00000000000000000000000000000000'
DEBUG:miio.device:192.168.0.102:54321 >>: {'id': 9, 'method': 'dnld_install_sound', 'params': {'url': 'http://192.168.0.104:41661/ru_maxim_universal.pkg', 'md5': '46022838228679ffd598ec2b44a54b2d', 'sid': 10000}}
DEBUG:miio.device:send (timeout 5): Container: 
    data = Container: 
        data = b'>\xf6\xa6e\xdbxC\x93`,-%^\xa5]\xe8'... (truncated, total 176)
        value = {'id': 9, 'method': 'dnld_install_sound', 'params': {'url': 'http://192.168.0.104:41661/ru_maxim_universal.pkg', 'md5': '46022838228679ffd598ec2b44a54b2d', 'sid': 10000}}
        offset1 = 32
        offset2 = 208
        length = 176
    header = Container: 
        data = b'!1\x00\xd0\x00\x00\x00\x00\x05vAx\x00\x00\x06F' (total 16)
        value = Container: 
            length = 208
            unknown = 0
            device_id = b'\x05vAx' (total 4)
            ts = 1970-01-01 00:26:46
        offset1 = 0
        offset2 = 16
        length = 16
    checksum = b'\xc6\xc0;\xa6\xd5\xd813\x89\xbc\xe1-\x0fP\xba\xa8' (total 16)
DEBUG:miio.device:recv from 192.168.0.102: Container: 
    data = Container: 
        data = b'Q\xe1\xaf\x8e\x14\xbf\n9\xcc\xb6\xa2\x00a\x1f\x8a\xef'... (truncated, total 32)
        value = {'result': ['OK'], 'id': 9}
        offset1 = 32
        offset2 = 64
        length = 32
    header = Container: 
        data = b'!1\x00@\x00\x00\x00\x00\x05vAx\x00\x00\x06F' (total 16)
        value = Container: 
            length = 64
            unknown = 0
            device_id = b'\x05vAx' (total 4)
            ts = 1970-01-01 00:26:46
        offset1 = 0
        offset2 = 16
        length = 16
    checksum = b'V\x8f\xad\xb9\x12R\xcd\x81\x8f\xb3&7\x0b\x98\x1d\xb5' (total 16)
DEBUG:miio.device:192.168.0.102:54321 (ts: 1970-01-01 00:26:46, id: 9) << {'result': ['OK'], 'id': 9}
Traceback (most recent call last):
  File "/home/host/.local/bin/mirobo", line 11, in <module>
    load_entry_point('python-miio==0.4.3', 'console_scripts', 'mirobo')()
  File "/home/host/.local/lib/python3.6/site-packages/miio/click_common.py", line 54, in __call__
    return self.main(*args, **kwargs)
  File "/home/host/.local/lib/python3.6/site-packages/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/home/host/.local/lib/python3.6/site-packages/click/core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/host/.local/lib/python3.6/site-packages/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/host/.local/lib/python3.6/site-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/home/host/.local/lib/python3.6/site-packages/click/decorators.py", line 64, in new_func
    return ctx.invoke(f, obj, *args, **kwargs)
  File "/home/host/.local/lib/python3.6/site-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/home/host/.local/lib/python3.6/site-packages/miio/vacuum_cli.py", line 483, in install_sound
    click.echo(vac.install_sound(local_url, md5sum, sid))
  File "/home/host/.local/lib/python3.6/site-packages/click/utils.py", line 222, in echo
    message = text_type(message)
  File "/home/host/.local/lib/python3.6/site-packages/miio/vacuumcontainers.py", line 484, in __repr__
    " - progress: %s>" % (self.sid, self.state,
  File "/home/host/.local/lib/python3.6/site-packages/miio/vacuumcontainers.py", line 464, in sid
    return self.data.get('sid_in_progress', None)
AttributeError: 'str' object has no attribute 'get'
ERROR:miio.updater:No request was made..

Could you advise, maybe I am doing something not in right way?

@rytilahti
Copy link
Owner

It is returning OK there, so maybe this device does not support changing the language pack? Could you nevertheless create a new issue for this?

@andrei-khveras
Copy link
Author

Hi @rytilahti
I created #418 but please feel free to dismiss it if you think it's a duplicate of #168.

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

No branches or pull requests

2 participants