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

Miio Xiaomi Air Purifier availability blinking ({'code': -9999, 'message': 'user ack timeout'}) #36972

Closed
denysdovhan opened this issue Jun 21, 2020 · 37 comments · Fixed by #37422 or #50755

Comments

@denysdovhan
Copy link
Contributor

denysdovhan commented Jun 21, 2020

The problem

I have connected my Mi Air Purifier 3H (zhimi.airpurifier.mb3) via Xiaomi Air Purifier integration. This model is specified as a supported one.

However, I’ve noticed it gets offline from time to time, every 30-90 minutes.

image

If you take a closer look at the history graph, you’ll notice that availability is blinking and eventually it gets unavailable completely every few hours. Only rebooting a router and/or humidifier helps to get it back online.

image

Environment

  • Home Assistant Core release with the issue: 0.111.4 (latest)
  • Last working Home Assistant Core release (if known): don't know
  • Operating environment (Home Assistant/Supervised/Docker/venv): Home Assistant
  • Integration causing this issue: fan.xiaomi_miio
  • Link to integration documentation on our website: https://www.home-assistant.io/integrations/fan.xiaomi_miio/

Problem-relevant configuration.yaml

fan:
  - platform: xiaomi_miio
    name: purifier
    host: !secret purifier_host
    token: !secret purifier_token

Traceback/Error logs

2020-06-18 12:12:12 WARNING (MainThread) [homeassistant.components.fan] Platform xiaomi_miio not ready yet. Retrying in 90 seconds.
2020-06-18 12:13:48 ERROR (SyncWorker_3) [miio.miioprotocol] Unable to discover a device at address 192.168.0.188
2020-06-18 12:13:48 WARNING (MainThread) [homeassistant.components.fan] Platform xiaomi_miio not ready yet. Retrying in 120 seconds.

2020-06-18 12:31:38 WARNING (MainThread) [homeassistant.helpers.entity] Update of fan.purifier is taking over 10 seconds
2020-06-18 12:36:17 WARNING (MainThread) [homeassistant.helpers.entity] Update of fan.purifier is taking over 10 seconds
2020-06-18 12:36:17 ERROR (SyncWorker_8) [miio.miioprotocol] Unable to discover a device at address 192.168.0.188
2020-06-18 12:36:17 ERROR (MainThread) [homeassistant.components.xiaomi_miio.fan] Got exception while fetching the state: Unable to discover the device 192.168.0.188
2020-06-18 12:36:43 ERROR (MainThread) [homeassistant.components.xiaomi_miio.fan] Got exception while fetching the state: Unable to discover the device 192.168.0.188
2020-06-18 12:38:46 ERROR (MainThread) [homeassistant.components.xiaomi_miio.fan] Got exception while fetching the state: {'code': -9999, 'message': 'user ack timeout'}
2020-06-18 13:05:03 ERROR (MainThread) [homeassistant.components.xiaomi_miio.fan] Got exception while fetching the state: {'code': -9999, 'message': 'user ack timeout'}
2020-06-18 13:12:16 WARNING (MainThread) [homeassistant.helpers.entity] Update of fan.purifier is taking over 10 seconds
2020-06-18 13:12:16 ERROR (SyncWorker_3) [miio.miioprotocol] Unable to discover a device at address 192.168.0.188
2020-06-18 13:12:16 ERROR (MainThread) [homeassistant.components.xiaomi_miio.fan] Got exception while fetching the state: Unable to discover the device 192.168.0.188
2020-06-18 13:13:47 WARNING (MainThread) [homeassistant.helpers.entity] Update of fan.purifier is taking over 10 seconds
2020-06-18 13:15:51 WARNING (MainThread) [homeassistant.helpers.entity] Update of fan.purifier is taking over 10 seconds
2020-06-18 13:15:51 ERROR (SyncWorker_8) [miio.miioprotocol] Unable to discover a device at address 192.168.0.188
2020-06-18 13:15:51 ERROR (MainThread) [homeassistant.components.xiaomi_miio.fan] Got exception while fetching the state: Unable to discover the device 192.168.0.188
2020-06-18 13:17:23 WARNING (MainThread) [homeassistant.helpers.entity] Update of fan.purifier is taking over 10 seconds
2020-06-18 13:17:23 ERROR (SyncWorker_7) [miio.miioprotocol] Unable to discover a device at address 192.168.0.188
2020-06-18 13:17:23 ERROR (MainThread) [homeassistant.components.xiaomi_miio.fan] Got exception while fetching the state: Unable to discover the device 192.168.0.188
2020-06-18 13:17:23 ERROR (MainThread) [homeassistant.components.google_assistant.http] Request 
2020-06-18 13:18:56 ERROR (SyncWorker_1) [miio.miioprotocol] Unable to discover a device at address 192.168.0.188
2020-06-18 13:18:56 ERROR (MainThread) [homeassistant.components.xiaomi_miio.fan] Got exception while fetching the state: Unable to discover the device 192.168.0.188

The most interesting part here (from my point of view):

[homeassistant.components.xiaomi_miio.fan] Got exception while fetching the state: Unable to discover the device 192.168.0.188
[homeassistant.components.xiaomi_miio.fan] Got exception while fetching the state: {'code': -9999, 'message': 'user ack timeout'}

Additional information

Probably I've found relevant issues:

@probot-home-assistant
Copy link

xiaomi_miio documentation
xiaomi_miio source
(message by IssueLinks)

@probot-home-assistant
Copy link

Hey there @rytilahti, @syssi, mind taking a look at this issue as its been labeled with a integration (xiaomi_miio) you are listed as a codeowner for? Thanks!
(message by CodeOwnersMention)

@hapklaar
Copy link

hapklaar commented Jun 22, 2020

I suspect this to be a hardware issue. The 3H unit is responding very badly to pings and requests. I see a constant ping response time in the hundreds of ms and even timeouts, with the unit next to my access point.

@denysdovhan
Copy link
Contributor Author

Having bad pings is OK - it doesn’t break functionality. I’m worried about purifier getting completely unavailable after some time.

This usually happens every 6-12 hours for me and requires reboot of router and Home Assistant.

@hapklaar
Copy link

Having bad pings is indicative of the responsiveness of the unit, this will also reflect in its reachability from HA. However I don't have the issue where I need to restart anything to get it working again. It just doesn't respond very often.

image

@denysdovhan
Copy link
Contributor Author

Seems like I have managed to fix purifier getting completely unavailable every few hours. I manually specified my model:

fan:
  - platform: xiaomi_miio
    name: purifier
    model: zhimi.airpurifier.mb3 # I specified my model here
    host: !secret purifier_host
    token: !secret purifier_token

After that change, my purifier is still up for more than 48 hours.

However, general availability is still blinking:

Screenshot 2020-06-24 at 14 43 01

@mrfoxbit
Copy link

mrfoxbit commented Jul 2, 2020

I have the same issue

@rytilahti
Copy link
Member

Could it be related to cloud connectivity issues? Some xiaomi vacuums are known to have issues if the packets are simply dropped, see https://python-miio.readthedocs.io/en/latest/troubleshooting.html#intermittent-connection-issues-timeouts-xiaomi-vacuum

Sometimes 'user ack timeout' indicates that the command is not supported by the device, but consider it is working sometimes that shouldn't be the case..

@denysdovhan
Copy link
Contributor Author

After upgrade to 0.112, my purifier gets completely unavailable. Restarting HA, router, or purifier doesn't help.

@rytilahti
Copy link
Member

rytilahti commented Jul 2, 2020

See the already linked 'command error' issue which is the likely the cause, that is however a different problem than this 'user ack timeout' issue.

@denysdovhan
Copy link
Contributor Author

I've rolled back to the previous 0.111.* release.

@rytilahti
Copy link
Member

And it is working just fine with it? Maybe there are differences between devices/firmware version/something, that is causing the timeout instead of that command error. In that case this would be a duplicate of that issue.

@matteos1
Copy link

matteos1 commented Jul 3, 2020

ade to 0.112, my purifier gets completely unavailable. Restarting HA, router, or purifier doesn't help.

also for me, the update of ha to 0.102 has made the purifier 3h unusable. its status is: not available

@KoltesPunti
Copy link

After update i got the same problem :/
[homeassistant.components.xiaomi_miio.fan] Got exception while fetching the state: {'code': -5001, 'message': 'command error'}

@rytilahti
Copy link
Member

For 'command error', see #36993 which will be fixed with a new python-miio release, sorry for the inconvenience :(

@mrfoxbit
Copy link

mrfoxbit commented Jul 4, 2020

Still error in HA 0.112.2 and python-miio 0.5.2.1. My device is Xiaomi Air Purifier 3 (zhimi.airpurifier.ma4)

2020-07-04 17:48:52 ERROR (MainThread) [homeassistant.components.xiaomi_miio.fan] Got exception while fetching the state: {'code': -9999, 'message': 'user ack timeout'}
2020-07-04 18:24:04 ERROR (SyncWorker_10) [miio.miioprotocol] Unable to discover a device at address 192.168.100.227
2020-07-04 18:24:04 ERROR (MainThread) [homeassistant.components.xiaomi_miio.fan] Got exception while fetching the state: Unable to discover the device 192.168.100.227
2020-07-04 18:39:28 ERROR (MainThread) [homeassistant.components.xiaomi_miio.fan] Got exception while fetching the state: {'code': -9999, 'message': 'user ack timeout'}
2020-07-04 19:03:17 ERROR (SyncWorker_9) [miio.miioprotocol] Unable to discover a device at address 192.168.100.227
2020-07-04 19:03:17 ERROR (MainThread) [homeassistant.components.xiaomi_miio.fan] Got exception while fetching the state: Unable to discover the device 192.168.100.227
2020-07-04 19:05:21 ERROR (SyncWorker_14) [miio.miioprotocol] Unable to discover a device at address 192.168.100.227
2020-07-04 19:05:21 ERROR (MainThread) [homeassistant.components.xiaomi_miio.fan] Got exception while fetching the state: Unable to discover the device 192.168.100.227
2020-07-04 19:21:22 ERROR (SyncWorker_4) [miio.miioprotocol] Unable to discover a device at address 192.168.100.227
2020-07-04 19:21:22 ERROR (MainThread) [homeassistant.components.xiaomi_miio.fan] Got exception while fetching the state: Unable to discover the device 192.168.100.227
2020-07-04 20:26:52 ERROR (MainThread) [homeassistant.components.xiaomi_miio.fan] Got exception while fetching the state: {'code': -9999, 'message': 'user ack timeout'}
2020-07-04 20:39:16 ERROR (MainThread) [homeassistant.components.xiaomi_miio.fan] Got exception while fetching the state: {'code': -9999, 'message': 'user ack timeout'}
2020-07-04 20:51:18 ERROR (SyncWorker_13) [miio.miioprotocol] Unable to discover a device at address 192.168.100.227
2020-07-04 20:51:18 ERROR (MainThread) [homeassistant.components.xiaomi_miio.fan] Got exception while fetching the state: Unable to discover the device 192.168.100.227
2020-07-04 21:01:02 ERROR (SyncWorker_16) [miio.miioprotocol] Unable to discover a device at address 192.168.100.227
2020-07-04 21:01:02 ERROR (MainThread) [homeassistant.components.xiaomi_miio.fan] Got exception while fetching the state: Unable to discover the device 192.168.100.227
2020-07-04 21:22:13 ERROR (SyncWorker_7) [miio.miioprotocol] Unable to discover a device at address 192.168.100.227
2020-07-04 21:22:13 ERROR (MainThread) [homeassistant.components.xiaomi_miio.fan] Got exception while fetching the state: Unable to discover the device 192.168.100.227
2020-07-04 21:25:19 ERROR (SyncWorker_5) [miio.miioprotocol] Unable to discover a device at address 192.168.100.227
2020-07-04 21:25:19 ERROR (MainThread) [homeassistant.components.xiaomi_miio.fan] Got exception while fetching the state: Unable to discover the device 192.168.100.227
2020-07-04 21:39:46 ERROR (SyncWorker_9) [miio.miioprotocol] Unable to discover a device at address 192.168.100.227
2020-07-04 21:39:46 ERROR (MainThread) [homeassistant.components.xiaomi_miio.fan] Got exception while fetching the state: Unable to discover the device 192.168.100.227
2020-07-04 21:51:14 ERROR (SyncWorker_10) [miio.miioprotocol] Unable to discover a device at address 192.168.100.227
2020-07-04 21:51:14 ERROR (MainThread) [homeassistant.components.xiaomi_miio.fan] Got exception while fetching the state: Unable to discover the device 192.168.100.227
2020-07-04 21:52:02 ERROR (MainThread) [homeassistant.components.xiaomi_miio.fan] Got exception while fetching the state: {'code': -9999, 'message': 'user ack timeout'}

@denysdovhan
Copy link
Contributor Author

@balloob please, reopen this issue. The error message persists in logs.

@AdrinkBeer
Copy link

FYI, I have upgraded to HA 0.113.3 (with the bump of python-miio) but still have an issue (Xiaomi Air Purifier 3H).

2020-08-02 16:16:50 ERROR (MainThread) [homeassistant.components.xiaomi_miio.fan] Got exception while fetching the state: {'code': -9999, 'message': 'user ack timeout'}

No discovery issues in my logs (python miio fix).

@rytilahti
Copy link
Member

Okay, let's reopen this, but I don't really know what would be a suitable fix for this. That {'code': -9999, 'message': 'user ack timeout'} message is coming from the device itself, so for some reason it fails to execute the called method.

On potential way to alleviate this would be either to retry (or ignore it from homeassistant's side and keep the old state) but it feels a bit hacky solution.

@rytilahti rytilahti reopened this Aug 2, 2020
@alive-corpse
Copy link

The same issue (user ack timeout) with model zhimi.humidifier.ca1 (Air Humidifier v2)
Home Assistant 0.113.1
python-miio==0.5.2.1

On potential way to alleviate this would be either to retry (or ignore it from homeassistant's side and keep the old state) but it feels a bit hacky solution.

I think it's really better than got log full of this messages.

@syssi
Copy link
Member

syssi commented Nov 19, 2020

@alive-corpse Could you check the error of your device (CA1) a second time? It's a "user ack timeout" or "UART timeout"?

@0rsa
Copy link

0rsa commented Dec 3, 2020

I add myself to this thread
Using
miiocli device --ip IP --token TOKEN info
It works:
Model: zhimi.airpurifier.mb3 Hardware version: esp32 Firmware version: 2.0.5

Using
miiocli airpurifiermiot --ip IP --token TOKEN status
It doesn't work:
Error: {'code': -9999, 'message': 'user ack timeout'}

miiocli, version 0.5.4

@freddieleeman
Copy link

I'm getting a lot of these too:

    Got exception while fetching the state: Unable to discover the device 192.168.254.156
    Got exception while fetching the state: {'code': -9999, 'message': 'user ack timeout'}

Retrying the call with a small timeout and a limit of x retries would probably be a good fix.

@xiaomihomeDomo
Copy link

I'm getting a lot of these too:

    Got exception while fetching the state: Unable to discover the device 192.168.254.156
    Got exception while fetching the state: {'code': -9999, 'message': 'user ack timeout'}

Retrying the call with a small timeout and a limit of x retries would probably be a good fix.

How ??

@freddieleeman
Copy link

I'm getting a lot of these too:

    Got exception while fetching the state: Unable to discover the device 192.168.254.156
    Got exception while fetching the state: {'code': -9999, 'message': 'user ack timeout'}

Retrying the call with a small timeout and a limit of x retries would probably be a good fix.

How ??

I don't know, I'm still learning Python. But as a quick fix setting self._available (line 1097) of fan.py to True would probably fix the unavailable messages. But this is not a good fix in any way, so we should probably wait for someone with more talent then me to resolve this issue.

@Seba200086
Copy link

Got the same problem (with Xiaomi Air Purifier 3H):
[homeassistant.components.xiaomi_miio.fan] Got exception while fetching the state: {'code': -9999, 'message': 'user ack timeout'}
Would be nice to have some working solution

@0rsa
Copy link

0rsa commented Jan 11, 2021

Restart your purifier.
If you connect to it after restarting, I agee that it happens when you are querying your purifier too many times in a short delay. I use node red and I can set querying delay, I have no more problem increasing this delay.

@gislis2
Copy link

gislis2 commented Jan 11, 2021

Restart your purifier.
If you connect to it after restarting, I agee that it happens when you are querying your purifier too many times in a short delay. I use node red and I can set querying delay, I have no more problem increasing this delay.

Great suggestion
Mind sharing your nodered recipe?

@0rsa
Copy link

0rsa commented Jan 11, 2021

I use https://python-miio.readthedocs.io/en/latest/ with an "exec" node (executes a system command)
image
I increased querying time from 5s to 30s.

@syssi
Copy link
Member

syssi commented Jan 11, 2021

If you want to reduce the update interval you could change the scan_interval. cp.

https://www.home-assistant.io/docs/configuration/platform_options/

@SeraphimSerapis
Copy link
Contributor

Where does the component increase the scan_interval? fan by default uses 30s and I haven't seen any different in xiaomi_miio:

SCAN_INTERVAL = timedelta(seconds=30)

@syssi
Copy link
Member

syssi commented Jan 11, 2021

@SeraphimSerapis You are right. The component uses the default value.

@freddieleeman
Copy link

I've tried adjusting the scan_interval, but it doesn't solve the issue for me. Although less, I still get 'unavailable' status.

@Seba200086
Copy link

Same here - set scan_interval: 60, but I'm still getting:
[homeassistant.components.xiaomi_miio.fan] Got exception while fetching the state: {'code': -9999, 'message': 'user ack timeout'}

Additionally, I noticed that this parameter has no real impact on refreshing, e.g. AQI value refreshes irregularly every 3 to 20 minutes.
I also noticed that with longer refresh intervals it helps to use Mi Home application (it forces values to refresh).

@colethegamer123
Copy link

I'm getting a lot of these too:

    Got exception while fetching the state: Unable to discover the device 192.168.254.156
    Got exception while fetching the state: {'code': -9999, 'message': 'user ack timeout'}

Retrying the call with a small timeout and a limit of x retries would probably be a good fix.

Totally Same problem.

@vampywiz17
Copy link

Same problem, but i not get discover problem, only "-9999" message.

It not affect the working, only trash the log.

@koldogut
Copy link

Same problem here with HA core-2021.4.6

Got exception while fetching the state: {'code': -9999, 'message': 'user ack timeout'}

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