-
Notifications
You must be signed in to change notification settings - Fork 354
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 >= 0.15.1] Mi Vacuum Cleaner Robot connection issue #94
Comments
Thank you for the details! As you said it would be great if more people could add details about their own setups and we'll see if we can work out what's wrong together. |
Here is some extra info. I had to remove tokens.json from my Windows profile to have miio CLI-tool discover the robot again. Using the tokens update command does not seem to regenerate a new tokens.json anymore. But when setting the token manually in the CLI-tool or in example.js I still recieve the error
Sometimes when trying to connect to the robot I get a lot of the errors as below. This seems sporadically but afterwards I'm seeying data from the robot coming in.
|
Thanks! That gives me a few ideas. It looks like the library connects to the vacuum sometimes then. Which is confusing. The dwaal-error is unrelated, it was for an experimental naming feature, but it doesn't play nice with Windows so I have removed it in 0.15.2. But if it works sometimes it might an issue with the vacuum sleeping or otherwise not responding to network requests. But I would think that it wouldn't respond to the initial handshake if that was case. I'm going to look into two things based on your log:
|
I've installed latest |
@350d Thanks for adding some additional details! I don't think that plugin has been updated to be compatible with 0.15.x yet, some work is needed by the plugin author to support the new version. That might affect things for you. |
@jghaanstra I've added a bit more debug info to the master-branch, if you have the possibility it would be great if you could test it out. The new debug-info should provide some more clues to how tokens are used and which ports is used to receive data. I'm especially interested in the difference between the cases where you are able to connect and those where you are not. |
@aholstenson thank you for your efforts. Below are some logs again, one of a not working discovery attempt (DUMP 1) and one of a working connection using example.js and setting the token as option of miio.device() (DUMP 2). I noticed that I was never able to connect using the local token storage. I have added tokens.json manually as When setting the token as option of miio.device() manually in example.js I get a succes ratio of about 5%. I have added a log (DUMP 4) using the working example.js where it does not connect. The error suggests the token might be wrong but this is not the case as it works with this token sometimes. Another strange thing, I have installed the latest Mi Home app and the token fields in miio2.db are all empty for my devices. It seems Xiaomi is gonna make it harder to control their devices through third party integration. Anyway, here are the dumps: DUMP 1 - token registered in tokens.json and trying discovery through CLI or example.js (gives the same error)
DUMP 2 - working connection with example.js and token as option in miio.device()
DUMP 3 - using miio tokens update
DUMP 4 - working example.js with token as option of miio.device() but no connection
|
Thank you for taking the time to put that together! Sadly I can't quite figure out what's wrong, it just seems like the vacuum sometimes doesn't respond, almost like it's a sleep mode where it doesn't listen to the local network. I've pushed 0.15.3 and 0.15.4 which contains some fixes to issues with token handling when they are being updated via the CLI. It shouldn't affect the overall connectivity though. If anyone else is having similar issues or ideas about what is wrong, please do add details to this issue. Any information helps! |
I was afraid of that. Thanx for putting in the effort though. When I find some time I'll see if I have more success with the python-miio, a comparable library written in Python. If this shows similar behaviour I can pinpoint it on my network or configuration, if this works I can pinpoint it to the library and comparing them would be the next step. One last question, on what Xiaomi server have you set up your Mi Robot? |
Sounds good, comparing is always a good thing. I think my vacuum is connected to the old US-server. I have also avoided updating the firmware, so I'm probably running a really old firmware by now. |
In retrospect I should have stayed on an older firmware too. Could you explain a little what the difference is between the miio discovery and miio.device() in relation to the token? Discovery seems to always detect my device when I have not set the token in tokens.json, when I do it never finds my device. While miio.device() only connects works 5% of the time either using token in token.json or set it manually as option. I'm trying to pinpoint where it fails. Looking at the log it doesnt seem to be a sleep issue to me but the robot just does not respond to WORKING miIO.info COMMAND
NON WORKING miIO.info COMMAND
|
There is currently an issue with discovery treating connection failures as non-existent devices. I'm rewriting the discovery a bit right now, so in the next version it will return a "placeholder device" that can be used to update the token via code. I've been looking at your dumps as well, did some manual testing to verify that the token has been set and that the checksums are correctly calculated with it. Everything checks out, so nothing new to report from my end, sorry. I also read through rytilahti/python-miio/issues/92 where a few users seem to have the same connection issue. Most seems to have an issue with their token though, which isn't the case for you. |
Although the token is correct I'm not excluding it as a possible cause somehow. The current results of not connecting could for many users suggest the token is not correct (the actual error of your library even suggest so, and perhaps miio-python shows a similar token related error). I need to set up a python enviroment to test this in further detail, but I'm not to familiar with python so this will take me some time. Something else I want to add to this issue for further troubleshooting. I have noticed that when I try to connect to the device it mostly works the first time after some cooling down periode. Trying to connect shortly after will not work. The suggests it's also not a sleep issue (but more an awake issue :-) ). |
Instead of setting up a new linux based enviroment I went with WinPython and have setup python-miio on my Windows machine. I can confirm that I do not have any issues with connecting to the Mi Robot using python-miio. This pinpoints my connection issues to this specific miio library and the next step is comparing this library against the python-miio library. This is gonna be challinging for me as my javascript knowledge is limited and my python knowledge is pretty much non existent. But it's a step ahead ... It would be great if more knowledgeable users with a similar issue could chip in though. |
That's very interesting. Does running |
Here is some debugging output:
Something I noticed is the miio-python works with sequence numbers for the commands. Not sure why but if this is to prevent some sort of caching I could match that with the fact that I'm able to connect once with this library and then it doesnt work for some time. That's a long shot though. Another unrelated question, how do I retrieve the status. It seems device.state() returns a bit of info, but not the actual state anymore. |
Thanks, I noticed the sequence numbers as well. I pushed a change to the repository does something similar on errors, could you see if that helps with the connection issues? Regarding the state, I've added a few examples to the docs here: https://github.com/aholstenson/miio/blob/master/docs/devices/vacuum.md I need to document the vacuum a lot more though, the state has been split into several different capabilities, such as one indicating if is charging, one if its cleaning, one if it has an error and so on. It's on my todo, going to try to get to soon. |
JACKPOT!!! I'm able to connect now every time using the latest commit. I do notice the first connection is slightly faster then the following ones. I'm assuming your implementation of sequence numbers kicks in after it fails. Not too big a deal but it could be optimized to always use some sort of sequencing to avoid this issue. Thanx a million for figuring this out! |
Awesome! The fixes have been pushed to NPM in version 0.15.5. Closing this issue and then we can see if we can do some optimization in a later version. |
This is a new issue for the Mi Robot Vacuum Cleaner. It seems for some users it works and for others it doesnt (anymore). I had it working fine until I installed firmware 3.3.9_003077 on the robot, it then stopped working. I was hoping the new miio version would fix the issue but for me it doesnt. So this Github issue is intended to gather as much information as possible that can explain the difference in results. It would be nice if more people could chip in to see if we can find a pattern.
I'm including DNS info as some have suggested that timeout issues are related to certain DNS services being blocked by Xiaomi. It does not seem relevant in this case as it's LAN traffic but who knows ...
When using miio.device() in the example.js with the token added manually in the code the following error is thrown:
The text was updated successfully, but these errors were encountered: