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

STYJ02YM Unable to decrypt error #701

Closed
bram2202 opened this issue May 22, 2020 · 10 comments
Closed

STYJ02YM Unable to decrypt error #701

bram2202 opened this issue May 22, 2020 · 10 comments
Labels

Comments

@bram2202
Copy link

I tried to control my Xiaomi STYJ02YM (firmware 3.5.3_0017)

Ran: miio discover --handshake 1
(paired with the Xiaomi home app)

And got

Device ID: <ID>
Model info: Unknown
Address: <IP>
Token: ??? 
Support: Unknown

Next I tried miiocli viomivacuum --ip <IP> --token <TOKEN> info
And got a timeout (No response from the device)

With debug flag:

INFO:miio.cli:Debug mode active
DEBUG:miio.protocol:Unable to decrypt, returning raw bytes: b''
DEBUG:miio.miioprotocol: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\x13\x9c6\x94^\xc7\xe3y' (total 16)
        value = Container:
            length = 32
            unknown = 0
            device_id = unhexlify('139c3694')
            ts = 2020-05-22 14:36:41
        offset1 = 0
        offset2 = 16
        length = 16
    checksum = b'\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff' (total 16)
DEBUG:miio.miioprotocol:Discovered 139c3694 with ts: 2020-05-22 14:36:41, token: b'ffffffffffffffffffffffffffffffff'
DEBUG:miio.miioprotocol:<IP>:54321 >>: {'id': 1, 'method': 'miIO.info', 'params': []}

I checked the used token two different ways, and both times they were the same.

@rytilahti
Copy link
Owner

These errors are hard to debug, as timeout just means that the device is not responding to the request. Considering it is answering to the handshake, the common problem is invalid token..

@bram2202
Copy link
Author

that's also what I thought, so i retried the Tokens from backup method, and got the same token again.

I tried another command mirobo discover
and got this response:

INFO:miio.discovery:Discovering devices with mDNS, press any key to quit...
WARNING:miio.discovery:Found unsupported device viomi-vacuum-v8_miio329004692._miio._udp.local. at <IP>, please report to developers

@rytilahti
Copy link
Owner

Can you try some other command besides info, just in case it's just info that is not working?

@bram2202
Copy link
Author

I tried these commands:

miiocli vacuum --ip <IP> --token <TOKEN> status
miiocli viomivacuum --ip <IP> --token <TOKEN> status
miiocli vacuum --ip <IP> --token <TOKEN> home
miiocli viomivacuum --ip <IP> --token <TOKEN> home

and all got this as response:

Running command <COMMAND>
ERROR:miio.miioprotocol:Got error when receiving: timed out
Error: No response from the device

@bram2202
Copy link
Author

I did a port scan on the vacuum, and only port 53 is open.
Not 54321 as used by miio, could that be the problem?

A read somewhere (cant find source) that the local API is closed after paring with the App?

@bram2202
Copy link
Author

So i was playing around with miio itself, and used the command to store the token locally.

After this i ran miio inspect <IP> and got a valid response!

Device ID: <ID>
Model info: viomi.vacuum.v8
Address: <IP>
Token: <TOKEN> via stored token
Support: At least generic

Type info: miio
Capabilities:

Firmware version: 3.5.3_0017
Hardware version: Linux

WiFi: <WIFI_NAME> (<MAC>) RSSI:

Remote access (Mi Home App): Maybe

After this i ran miiocli device info and again got valid info

Model: viomi.vacuum.v8
Hardware version: Linux
Firmware version: 3.5.3_0017
Network: {'localIp': '<IP>', 'mask': '255.255.255.0', 'gw': '<GATEWAY>'}
AP: {'ssid': '<WIFI_NAME>', 'bssid': '<MAC>'}

Even miiocli viomivacuum info gave the same response.

The stragest thing is that i looks like running the miio inspect command opens the api for other command, but only for a few secconds, after this a Error: No response from the device is thrown.

running the miiocli viomivacuum status within this time resulted in a error:

INFO:miio.cli:Debug mode active
DEBUG:miio.protocol:Unable to decrypt, returning raw bytes: b''
DEBUG:miio.miioprotocol: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\x13\x9c6\x94^\xcb\xca0' (total 16)
        value = Container:
            length = 32
            unknown = 0
            device_id = unhexlify('139c3694')
            ts = 2020-05-25 13:37:52
        offset1 = 0
        offset2 = 16
        length = 16
    checksum = b'\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff' (total 16)
DEBUG:miio.miioprotocol:Discovered 139c3694 with ts: 2020-05-25 13:37:52, token: b'ffffffffffffffffffffffffffffffff'
DEBUG:miio.miioprotocol:<IP>:54321 >>: {'id': 1, 'method': 'get_prop', 'params': ['run_state', 'mode', 'err_state', 'battary_life', 'box_type', 'mop_type', 's_time', 's_area', 'suction_grade', 'water_grade', 'remember_map', 'has_map', 'is_mop', 'has_newmap']}
DEBUG:miio.miioprotocol:<IP>:54321 (ts: 2020-05-25 13:37:52, id: 1) << {'result': [5, 0, 2105, 100, 1, 0, 32, 32.03, 2, 13, 1, 1, 0, 0], 'id': 1}
Traceback (most recent call last):
  File "/usr/local/bin/miiocli", line 11, in <module>
    sys.exit(create_cli())
  File "/usr/local/lib/python3.6/dist-packages/miio/cli.py", line 44, in create_cli
    return cli(auto_envvar_prefix="MIIO")
  File "/usr/local/lib/python3.6/dist-packages/miio/click_common.py", line 59, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.6/dist-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.6/dist-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.6/dist-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.6/dist-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.6/dist-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.6/dist-packages/miio/click_common.py", line 285, in wrap
    result_msg = result_msg_fmt.format(**kwargs)
AttributeError: 'ViomiVacuumStatus' object has no attribute 'box_type'

@rytilahti
Copy link
Owner

The cli error about box_type and others were recently fixed in git master, so that will be fixed in the future releases. I don't know what miio inspect does, but if the device becomes unresponsive to miio packets after a while I don't think there's much we can do here (if the inspect isn't just the common handshake?).

@bram2202
Copy link
Author

bram2202 commented Jun 4, 2020

updated to 0.5.1, and now everything works!

@bram2202 bram2202 closed this as completed Jun 4, 2020
@meteo88
Copy link

meteo88 commented Jul 29, 2020

Hi,

i have the exact same issue, but i use python_miio 0.5.3.

I have an Xiaomi Vacuum Cleaner Pro ("model": "viomi.vacuum.v8"Firmware version: 3.5.3_0017)

With the command:
/usr/local/bin/mirobo discover --handshake 1

i get as answer:
INFO:miio.miioprotocol:Sending discovery to <broadcast> with timeout of 5s.. INFO:miio.miioprotocol: IP 192.168.1.6 (ID: 139df008) - token: b'ffffffffffffffffffffffffffffffff' INFO:miio.miioprotocol:Discovery done

The only command that works is the info command:

miiocli vacuum --ip 192.168.1.6 --token TOKENTOKENTOKENTOKENTOKEN info

Model: viomi.vacuum.v8
Hardware version: Linux
Firmware version: 3.5.3_0017
Network: {'localIp': '192.168.1.6', 'mask': '255.255.255.0', 'gw': '192.168.1.1'}
AP: {'ssid': 'SSID', 'bssid': 'xx:xx:xx:xx:xx:xx'}

But any other command leads to a timeout....

Example:

miiocli vacuum --ip 192.168.1.6 --token TOKENTOKENTOKENTOKENTOKEN status`
Running command status
ERROR:miio.miioprotocol:Got error when receiving: timed out
Error: No response from the device

i tried already to downgrade to another python-miio Version, but nothing is working...
Can you help me please?

Best regards,
Dominik

@rytilahti
Copy link
Owner

@meteo88 you have to use miiocli viomivacuum for viomi vacuums, then it should work.

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

No branches or pull requests

3 participants