-
-
Notifications
You must be signed in to change notification settings - Fork 561
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 Xiaomi Air Purifier availability blinking ({'code': -9999, 'message': 'user ack timeout'}) and Unable to discover a device at address #757
Comments
+1 |
@mihaicristianpetrescu requesting using miiocli does not currently save the sequence id, so that may explain your problem, see my response here: #762 (comment) . The issue with homeassistant is likely something else, as homeassistant keep using the same instance and the sequence numbers should be handled correctly. |
This was just a test, I'm using the python lib in my workflow. I'm making an AirPurifierMiot(ip, token) object and then calling the status() method and that fails with the same error I posted above in Python. |
Take a look at #762 (comment) . In the current git master the id is available through |
I have looked at the comment, but I don't understand where I'm suppose to get the sequence id from? |
The grand parent class of class is python-miio/miio/miioprotocol.py Line 258 in 30752c3
The parameter python-miio/miio/airhumidifier_miot.py Line 255 in 30752c3
|
I got to the Device.py and you're right. It start from 0 as defult and keeps on growing. So if I just use the same one over and over, as in 0 it should be fine, right? |
After a couple of status() calls it continuously gives me "miio.exceptions.DeviceException: Unable to discover the device ip" for every new call I make. |
No, you cannot use the sequence numbers. After all, the reason for them is to make it possible for the device to ignore duplicate/already handled messages. On top of that, it is possible that some devices simply stop responding to the messages if they think the client is spamming them with messages, or if they think that the message is otherwise invalid, e.g., based on the timestamps. Considering that these devices are pretty much blackboxes, it is really hard to debug such issues, so the two following things are done by the library based on empirical findings:
Now that I wrote that down, I realized that it's possible that diverging timestamps could play a role if longer time period has passed since the last request. But I don't think that's a problem in your case... For those "unable to discover" messages, are you simply running a script in a loop (with incrementing sequence numbers) that calls |
So I have a thread that calls status() every 3 seconds, and it uses the same object of AirPurifierMiot that has been instanced with value 1 as the sequence_number. It seems to be working fine now. Otherwise, if I don't use the sequence_number (same one) and I kill the process and restart it, it will stop working after 5-6 something kills/restarts. So having the same sequence_number seems to solve this issue. If I keep changing the sequence number per request...then I will have to unplug and plug back in the air purifier in order to make the library work agian. |
Okay, glad to hear it that you got it working, but I don't completely understand what you are doing without any code pieces... There should be no need for you to manually do any sequence number management, as long as you are using the same instance. Here's how I think the logic in miio device implementations works:
where the
|
I'm using the python-miio library as a standalone library in my project. I have a service that run a python script in which I have an object instance of the AirPurifierMiot on which I then run commands. |
That's just regular python: https://github.com/rytilahti/python-miio/blob/master/miio/airpurifier_miot.py#L54 So something like this should work:
edit: to add, please create a new issue (or simply join the matrix chat linked in the README) for further discussions, this is about the 'user ack timeout' error that is still unsolved :-) |
Indeed, you are correct. I just downloaded modified the library, exposed the inner class via init, repackaged and installed. In rergards to 'user ack timeout' I was getting it not related to any outside platform (such as homeassistant), but via miiocli or python execution due to the lack of start_id. |
Glad you got it working :-) Regarding to the 'user ack timeout', I'm not sure I'm understanding you correctly. Do you mean that if you store the sequence id and initialize it again later on, it is working just fine? With homeassistant, the instance is kept alive as long as homeassistant is kept running, so the the value gets increment automatically and it should in principle work (or that's working with some other devices so, at least). What I find odd is that the error happens only sometimes, to my understanding. A couple for those who have the 'user ack timeout' problem with homeassistant:
I'm wondering if the device could be confused if two devices are using different set of ids, or if the maximum id is different from other devices (they get rolled currently automatically after 9999, iirc) . |
So am I, getting more Xiaomi devices now to play with :) If I use the same sequence (ex:1) for every new class initialisation I'm doing for the same device it works just fine. If I don't use the same one, after I initialise the class a couple of times (script restart) it will get blocked by the device and I have to restart the device (unplug, plug back into the AC). Incrementing the sequence id is like KRYPTONITE! I want to be able to restart my python script (since it has the heart of the server) anytime I please without having to deal with unwanted consequences like having to reboot all my smart appliances due to that. After 5-6 or so class initialisations (where I don't use the sequence id) it locks up. |
I have totally the same issue since I bought my Air Purifier 3H from Xiaomi. |
hello,i have the same question.i install the python-miio,and use the token_extractor.py to get the token and ip,then run the miiocli -d device --ip 192.168.1.102 --token f88e12052063b21be1a7923c7f508aea raw_command set_properties"[{'did':'MYDID','siid':2,'piid':1}](i found it on the #901) ,and the result is: INFO:miio.cli:Debug mode active i dont know what's wrong and how to solve it |
This might be a common issue on these devices, maybe a similar fix that has been incorporated by homeassistant should be included directly in python-miio: home-assistant/core#56288 |
My device is Xiaomi Air Purifier 3 (zhimi.airpurifier.ma4), python-miio 0.5.2.1
It just doesn't respond very often.
I uesd
miiocli --debug airpurifiermiot --ip <ip> --token <token> status
and this is result (sometime it show: Unable to discover the device 192.168.100.227)Originally posted by @hoangtuit in #577 (comment)
The text was updated successfully, but these errors were encountered: