-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
[miio] Add support for viomi S9 vacuum (v18) #9878
Conversation
@marcelrv I tried and yes, it works very well on the Xiaomi Cloud - thanks a bunch! Could you tell me how you've been able to find out about the changes required regarding the API? I tried my luck with
Also I'm willing to investigate further regarding the timeouts - I just need a few more pointers I guess. |
for cloud, I'm using android device that runs through mitmproxy. You indeed need to import the certificates. For the development way back on the UDP protocol, indeed wiresharking and there was the initial version of a javascript library that helped comparing my calculated encryption against their implementation. |
Are you sure the mihome app communicates direct with the device (outside maybe the first handshake/miio ping) |
I rechecked - after I set the timeout quite low (5) the whole thing works fairly well locally. Lots of timeouts or empty responses but in general it's usable. |
The responses assignment to the calling requests seem to mix up themselves:
or
Breakpoint at MiioAsyncCommunication.java#254: To "fix" this I changed |
Indeed that is something funcky that needs looking after. I think the MiioAsyncCommunication expects the device to respond to the request just issued... but long time I haven't looked at that code so I'll need to check. Can you share a debug log of a full refresh, so it is clear which channels (siid/piids) respond and which not. Identified manual actions for execution Esp the starting/stopping ones would be good to have confirmed working as well |
For the refresh: Regarding actions: the vacuum-start-sweep command worked, although the logs stated no response. Same applies to vacuum-stop-sweeping. When I find the time I will try out other actions. |
I think your timeout indeed is rather low, esp as the viomies have poor performance wrt response times. Will go over your gist in more detail and update the json. |
Hi Marcel! Accessing those endpoints with the same method results in So I'm wondering, does it use a different authentication method? EDIT: Found it myself - using e.g. 5.5.66 lets me view what I need :) in the aforementioned request the parameter |
yes... those seem to be the magic parameters :) Actually the binding works without any issue with the v2 api as well (meaning if all requests are done through the v2 api rather than without v2) |
ddc9805
to
efb487f
Compare
Signed-off-by: Marcel Verpaalen <marcel@verpaalen.com>
Signed-off-by: Marcel Verpaalen <marcel@verpaalen.com>
596be96
to
eaafe24
Compare
@Hilbrand included wider columns in this readme update |
bundles/org.openhab.binding.miio/src/main/resources/database/viomi.vacuum.v18-miot.json
Outdated
Show resolved
Hide resolved
bundles/org.openhab.binding.miio/src/main/resources/database/viomi.vacuum.v18-miot.json
Outdated
Show resolved
Hide resolved
Co-authored-by: Connor Petty <mistercpp2000@gmail.com> Signed-off-by: Marcel Verpaalen marcel@verpaalen.com
194b33d
to
e19a118
Compare
Hi @marcelrv - sorry for pinging you again in this already merged PRs but I'm not sure where else to ask: I'm trying to find out the commands that are sent when adding entries to the "cleaning plan". This used to be easy to find out with an older version (e.g. 5.5.66) of the Xiaomi app due to unencrypted messages but now it complains that it needs a newer version when opening the Viomi robot. Is there an alternative way to read or decrypt the plain text commands? |
yes, that's nowadays a bit tricky. The way I log traffic is by using the cloud communication rather than the local communication. I think the other way is to wireshark the communication between device and phone, and decode it using the token... there are some python/node scripts that help with it. But I found that always a even more tricky setup. |
If you manage to set it up, please share a log of the regular communicaton. If it is anything like the rockrobo's, during the communication you see the URL location of the map file, you can download these map files by copying the url to the browser. If you can't make the logging with mitmproxy to work, you can share your device (in the mihome app) for a few days and I can log it for you. |
I'm also logging the traffic successfully with this combination (for future reference):
College Proxy sounds easier, though. The issue I'm having is that even the POST requests to /home/rpc/ are encrypted as well so I can't read what's going on. I did not find a python or node script to decrypt the communication apart from this but it relies on UDP traffic. Can you point me to the scripts you mentioned? I do plan to take a look at the Map situation as well and contribute accordingly! I'm just not sure yet when :) |
ah, okay, did not get that... so the communication to the cloud is also encrypted that is a new 'feature' I think something like this can be used, but it may be similar to the link you gave. The fallback can be to analyse the code of the plugin for your device. |
Yes regarding the encryption - I tried lots of old Xiaomi Home app versions and it seems encryption was enabled around the time 5.5.66 was released (so September 2019). Encryption is active on every part of the API, so rpc + everything else (except some specific ones, such as /app/service/getappconfig or /version/online_version). I guess unencrypted communication is still possible for backward compatibility. I tried the python script: import miio
data = 'lWZ7SRZRHpjWUY4Hdh+DYNMlDp4aG0mvrklbqk65r/UsH8gjwu/SNpRD2vxHqin2e76gnfFiKiVTKIZOs+htpRPc2EwKj/fcK8Q1uzI8ba6H6K2tq4mypNf1Nxll9jYlSwImVCFxChgS0O7xLN1YaOZ+j+vUjClZTH64Dpu6JMOHFlTMnAnA5vQLdBaoFYdGyzStynSeVTkXGg=='
array = data.encode('utf-8')
decrypted = miio.decrypt('***'.encode('utf-8'), array)
if decrypted:
print(decrypted.decode('UTF-8')) but it fails with an error "Invalid padding bytes." |
The python tool is for decrypting the traffic between device and phone. Seems the cloud command encryption is different. Do you see this for all devices/commands or just for the viomi vacuum? (in other words, is it something specific to the device or general change) I indeed still have bit of older mihome version installed for logging. I havn;'t seen this encrypted traffic. |
Can you tell me which version you're using of the mihome app? Maybe yours is newer than what I found to be the last unencrypted version. The traffic is also encrypted for a Xiaomi Mi Robot so I guess the change is in general. I'll see what I can find out regarding the newer APK with the old version. |
For reference: |
yes, that was what I meant with
I'll confirm the mihome version I have tonight, but I recall it is 5.5.23 |
I checked, my version is 5.6.74 (android) I can see the traffic unencrypted |
That version also works with the latest Viomi module - thanks for the hint! |
* [miio] Add support for viomi S9 vacuum (v18) * [miio] improved translations & wider columns readme * [miio] Apply review suggestions Signed-off-by: Marcel Verpaalen marcel@verpaalen.com Signed-off-by: John Marshall <john.marshall.au@gmail.com>
Can you attach please an example of how to start a room cleaning? p.s. I found the solution: |
* [miio] Add support for viomi S9 vacuum (v18) * [miio] improved translations & wider columns readme * [miio] Apply review suggestions Signed-off-by: Marcel Verpaalen marcel@verpaalen.com
* [miio] Add support for viomi S9 vacuum (v18) * [miio] improved translations & wider columns readme * [miio] Apply review suggestions Signed-off-by: Marcel Verpaalen marcel@verpaalen.com
Signed-off-by: Marcel Verpaalen marcel@verpaalen.com
@jonasbark would you mind testing the json file with OH3