home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
71.14k stars 29.82k forks source link

Xiaomi Vacuum Cleaner robot timeout / unavailable #9013

Closed olskar closed 6 years ago

olskar commented 7 years ago

Home Assistant release (hass --version): 0.51.2

Python release (python3 --version): 3.4.2

Component/platform: vacuum

Description of problem: I see that #8982 was closed @azogue but I am afraid I still have the same problem. The token is correct and mirobo can communicate without problems, all the times I have tried. As you can see it spawns those errors for more than 20 minutes.

2017-08-16 17:41:56 ERROR (Thread-10) [mirobo.device] Unable to discover a device at address 192.168.1.128
2017-08-16 17:41:56 WARNING (MainThread) [homeassistant.components.vacuum.xiaomi] Got exception while fetching the state: Unable to discover the device 192.168.1.128
2017-08-16 17:42:17 ERROR (Thread-3) [mirobo.device] Unable to discover a device at address 192.168.1.128
2017-08-16 17:42:17 WARNING (MainThread) [homeassistant.components.vacuum.xiaomi] Got exception while fetching the state: Unable to discover the device 192.168.1.128
2017-08-16 17:42:38 ERROR (Thread-6) [mirobo.device] Unable to discover a device at address 192.168.1.128
2017-08-16 17:42:38 WARNING (MainThread) [homeassistant.components.vacuum.xiaomi] Got exception while fetching the state: Unable to discover the device 192.168.1.128
2017-08-16 17:42:59 ERROR (Thread-6) [mirobo.device] Unable to discover a device at address 192.168.1.128
2017-08-16 17:42:59 WARNING (MainThread) [homeassistant.components.vacuum.xiaomi] Got exception while fetching the state: Unable to discover the device 192.168.1.128
2017-08-16 17:43:20 ERROR (Thread-5) [mirobo.device] Unable to discover a device at address 192.168.1.128
2017-08-16 17:43:20 WARNING (MainThread) [homeassistant.components.vacuum.xiaomi] Got exception while fetching the state: Unable to discover the device 192.168.1.128
2017-08-16 17:43:41 ERROR (Thread-2) [mirobo.device] Unable to discover a device at address 192.168.1.128
2017-08-16 17:43:41 WARNING (MainThread) [homeassistant.components.vacuum.xiaomi] Got exception while fetching the state: Unable to discover the device 192.168.1.128
2017-08-16 17:44:02 ERROR (Thread-2) [mirobo.device] Unable to discover a device at address 192.168.1.128
2017-08-16 17:44:02 WARNING (MainThread) [homeassistant.components.vacuum.xiaomi] Got exception while fetching the state: Unable to discover the device 192.168.1.128
2017-08-16 17:44:23 ERROR (Thread-3) [mirobo.device] Unable to discover a device at address 192.168.1.128
2017-08-16 17:44:23 WARNING (MainThread) [homeassistant.components.vacuum.xiaomi] Got exception while fetching the state: Unable to discover the device 192.168.1.128
2017-08-16 17:44:44 ERROR (Thread-10) [mirobo.device] Unable to discover a device at address 192.168.1.128
2017-08-16 17:44:44 WARNING (MainThread) [homeassistant.components.vacuum.xiaomi] Got exception while fetching the state: Unable to discover the device 192.168.1.128
2017-08-16 17:45:05 ERROR (Thread-10) [mirobo.device] Unable to discover a device at address 192.168.1.128
2017-08-16 17:45:05 WARNING (MainThread) [homeassistant.components.vacuum.xiaomi] Got exception while fetching the state: Unable to discover the device 192.168.1.128
2017-08-16 17:45:26 ERROR (Thread-11) [mirobo.device] Unable to discover a device at address 192.168.1.128
2017-08-16 17:45:26 WARNING (MainThread) [homeassistant.components.vacuum.xiaomi] Got exception while fetching the state: Unable to discover the device 192.168.1.128
2017-08-16 17:45:30 WARNING (MainThread) [homeassistant.helpers.entity] Update of sensor.vindruva_moisture is taking over 10 seconds
2017-08-16 17:45:47 ERROR (Thread-11) [mirobo.device] Unable to discover a device at address 192.168.1.128
2017-08-16 17:45:47 WARNING (MainThread) [homeassistant.components.vacuum.xiaomi] Got exception while fetching the state: Unable to discover the device 192.168.1.128
2017-08-16 17:46:08 ERROR (Thread-11) [mirobo.device] Unable to discover a device at address 192.168.1.128
2017-08-16 17:46:08 WARNING (MainThread) [homeassistant.components.vacuum.xiaomi] Got exception while fetching the state: Unable to discover the device 192.168.1.128
2017-08-16 17:46:29 ERROR (Thread-6) [mirobo.device] Unable to discover a device at address 192.168.1.128
2017-08-16 17:46:29 WARNING (MainThread) [homeassistant.components.vacuum.xiaomi] Got exception while fetching the state: Unable to discover the device 192.168.1.128
2017-08-16 17:46:50 ERROR (Thread-3) [mirobo.device] Unable to discover a device at address 192.168.1.128
2017-08-16 17:46:50 WARNING (MainThread) [homeassistant.components.vacuum.xiaomi] Got exception while fetching the state: Unable to discover the device 192.168.1.128
2017-08-16 17:47:11 ERROR (Thread-3) [mirobo.device] Unable to discover a device at address 192.168.1.128
2017-08-16 17:47:11 WARNING (MainThread) [homeassistant.components.vacuum.xiaomi] Got exception while fetching the state: Unable to discover the device 192.168.1.128
2017-08-16 17:47:32 ERROR (Thread-3) [mirobo.device] Unable to discover a device at address 192.168.1.128
2017-08-16 17:47:32 WARNING (MainThread) [homeassistant.components.vacuum.xiaomi] Got exception while fetching the state: Unable to discover the device 192.168.1.128
2017-08-16 17:47:53 ERROR (Thread-8) [mirobo.device] Unable to discover a device at address 192.168.1.128
2017-08-16 17:47:53 WARNING (MainThread) [homeassistant.components.vacuum.xiaomi] Got exception while fetching the state: Unable to discover the device 192.168.1.128
2017-08-16 17:48:14 ERROR (Thread-7) [mirobo.device] Unable to discover a device at address 192.168.1.128
2017-08-16 17:48:14 WARNING (MainThread) [homeassistant.components.vacuum.xiaomi] Got exception while fetching the state: Unable to discover the device 192.168.1.128
2017-08-16 17:48:35 ERROR (Thread-7) [mirobo.device] Unable to discover a device at address 192.168.1.128
2017-08-16 17:48:35 WARNING (MainThread) [homeassistant.components.vacuum.xiaomi] Got exception while fetching the state: Unable to discover the device 192.168.1.128
2017-08-16 17:48:56 ERROR (Thread-2) [mirobo.device] Unable to discover a device at address 192.168.1.128
2017-08-16 17:48:56 WARNING (MainThread) [homeassistant.components.vacuum.xiaomi] Got exception while fetching the state: Unable to discover the device 192.168.1.128
2017-08-16 17:49:17 ERROR (Thread-5) [mirobo.device] Unable to discover a device at address 192.168.1.128
2017-08-16 17:49:17 WARNING (MainThread) [homeassistant.components.vacuum.xiaomi] Got exception while fetching the state: Unable to discover the device 192.168.1.128
2017-08-16 17:49:38 ERROR (Thread-11) [mirobo.device] Unable to discover a device at address 192.168.1.128
2017-08-16 17:49:38 WARNING (MainThread) [homeassistant.components.vacuum.xiaomi] Got exception while fetching the state: Unable to discover the device 192.168.1.128
2017-08-16 17:49:59 ERROR (Thread-10) [mirobo.device] Unable to discover a device at address 192.168.1.128
2017-08-16 17:49:59 WARNING (MainThread) [homeassistant.components.vacuum.xiaomi] Got exception while fetching the state: Unable to discover the device 192.168.1.128
2017-08-16 17:50:20 ERROR (Thread-3) [mirobo.device] Unable to discover a device at address 192.168.1.128
2017-08-16 17:50:20 WARNING (MainThread) [homeassistant.components.vacuum.xiaomi] Got exception while fetching the state: Unable to discover the device 192.168.1.128
2017-08-16 17:50:41 ERROR (Thread-11) [mirobo.device] Unable to discover a device at address 192.168.1.128
2017-08-16 17:50:41 WARNING (MainThread) [homeassistant.components.vacuum.xiaomi] Got exception while fetching the state: Unable to discover the device 192.168.1.128
2017-08-16 17:51:02 ERROR (Thread-8) [mirobo.device] Unable to discover a device at address 192.168.1.128
2017-08-16 17:51:02 WARNING (MainThread) [homeassistant.components.vacuum.xiaomi] Got exception while fetching the state: Unable to discover the device 192.168.1.128
2017-08-16 17:51:23 ERROR (Thread-12) [mirobo.device] Unable to discover a device at address 192.168.1.128
2017-08-16 17:51:23 WARNING (MainThread) [homeassistant.components.vacuum.xiaomi] Got exception while fetching the state: Unable to discover the device 192.168.1.128
2017-08-16 17:51:44 ERROR (Thread-3) [mirobo.device] Unable to discover a device at address 192.168.1.128
2017-08-16 17:51:44 WARNING (MainThread) [homeassistant.components.vacuum.xiaomi] Got exception while fetching the state: Unable to discover the device 192.168.1.128
2017-08-16 17:52:05 ERROR (Thread-10) [mirobo.device] Unable to discover a device at address 192.168.1.128
2017-08-16 17:52:05 WARNING (MainThread) [homeassistant.components.vacuum.xiaomi] Got exception while fetching the state: Unable to discover the device 192.168.1.128
2017-08-16 17:52:26 ERROR (Thread-12) [mirobo.device] Unable to discover a device at address 192.168.1.128
2017-08-16 17:52:26 WARNING (MainThread) [homeassistant.components.vacuum.xiaomi] Got exception while fetching the state: Unable to discover the device 192.168.1.128
2017-08-16 17:52:47 ERROR (Thread-11) [mirobo.device] Unable to discover a device at address 192.168.1.128
2017-08-16 17:52:47 WARNING (MainThread) [homeassistant.components.vacuum.xiaomi] Got exception while fetching the state: Unable to discover the device 192.168.1.128
2017-08-16 17:53:08 ERROR (Thread-3) [mirobo.device] Unable to discover a device at address 192.168.1.128
2017-08-16 17:53:08 WARNING (MainThread) [homeassistant.components.vacuum.xiaomi] Got exception while fetching the state: Unable to discover the device 192.168.1.128
2017-08-16 17:53:29 ERROR (Thread-7) [mirobo.device] Unable to discover a device at address 192.168.1.128
2017-08-16 17:53:29 WARNING (MainThread) [homeassistant.components.vacuum.xiaomi] Got exception while fetching the state: Unable to discover the device 192.168.1.128
2017-08-16 17:53:50 ERROR (Thread-12) [mirobo.device] Unable to discover a device at address 192.168.1.128
2017-08-16 17:53:50 WARNING (MainThread) [homeassistant.components.vacuum.xiaomi] Got exception while fetching the state: Unable to discover the device 192.168.1.128
2017-08-16 17:54:11 ERROR (Thread-10) [mirobo.device] Unable to discover a device at address 192.168.1.128
2017-08-16 17:54:11 WARNING (MainThread) [homeassistant.components.vacuum.xiaomi] Got exception while fetching the state: Unable to discover the device 192.168.1.128
2017-08-16 17:54:32 ERROR (Thread-4) [mirobo.device] Unable to discover a device at address 192.168.1.128
2017-08-16 17:54:32 WARNING (MainThread) [homeassistant.components.vacuum.xiaomi] Got exception while fetching the state: Unable to discover the device 192.168.1.128
2017-08-16 17:54:53 ERROR (Thread-4) [mirobo.device] Unable to discover a device at address 192.168.1.128
2017-08-16 17:54:53 WARNING (MainThread) [homeassistant.components.vacuum.xiaomi] Got exception while fetching the state: Unable to discover the device 192.168.1.128
2017-08-16 17:55:14 ERROR (Thread-11) [mirobo.device] Unable to discover a device at address 192.168.1.128
2017-08-16 17:55:14 WARNING (MainThread) [homeassistant.components.vacuum.xiaomi] Got exception while fetching the state: Unable to discover the device 192.168.1.128
2017-08-16 17:55:35 ERROR (Thread-10) [mirobo.device] Unable to discover a device at address 192.168.1.128
2017-08-16 17:55:35 WARNING (MainThread) [homeassistant.components.vacuum.xiaomi] Got exception while fetching the state: Unable to discover the device 192.168.1.128
2017-08-16 17:55:56 ERROR (Thread-8) [mirobo.device] Unable to discover a device at address 192.168.1.128
2017-08-16 17:55:56 WARNING (MainThread) [homeassistant.components.vacuum.xiaomi] Got exception while fetching the state: Unable to discover the device 192.168.1.128
2017-08-16 17:56:17 ERROR (Thread-2) [mirobo.device] Unable to discover a device at address 192.168.1.128
2017-08-16 17:56:17 WARNING (MainThread) [homeassistant.components.vacuum.xiaomi] Got exception while fetching the state: Unable to discover the device 192.168.1.128
2017-08-16 17:56:38 ERROR (Thread-3) [mirobo.device] Unable to discover a device at address 192.168.1.128
2017-08-16 17:56:38 WARNING (MainThread) [homeassistant.components.vacuum.xiaomi] Got exception while fetching the state: Unable to discover the device 192.168.1.128
2017-08-16 17:57:20 ERROR (Thread-7) [mirobo.device] Unable to discover a device at address 192.168.1.128
2017-08-16 17:57:20 WARNING (MainThread) [homeassistant.components.vacuum.xiaomi] Got exception while fetching the state: Unable to discover the device 192.168.1.128
2017-08-16 17:59:26 ERROR (Thread-4) [mirobo.device] Unable to discover a device at address 192.168.1.128
2017-08-16 17:59:26 WARNING (MainThread) [homeassistant.components.vacuum.xiaomi] Got exception while fetching the state: Unable to discover the device 192.168.1.128
2017-08-16 17:59:47 ERROR (Thread-8) [mirobo.device] Unable to discover a device at address 192.168.1.128
2017-08-16 17:59:47 WARNING (MainThread) [homeassistant.components.vacuum.xiaomi] Got exception while fetching the state: Unable to discover the device 192.168.1.128
2017-08-16 18:00:29 ERROR (Thread-7) [mirobo.device] Unable to discover a device at address 192.168.1.128
2017-08-16 18:00:29 WARNING (MainThread) [homeassistant.components.vacuum.xiaomi] Got exception while fetching the state: Unable to discover the device 192.168.1.128
2017-08-16 18:02:13 ERROR (Thread-2) [mirobo.device] Unable to discover a device at address 192.168.1.128
2017-08-16 18:02:13 WARNING (MainThread) [homeassistant.components.vacuum.xiaomi] Got exception while fetching the state: Unable to discover the device 192.168.1.128
2017-08-16 18:02:34 ERROR (Thread-5) [mirobo.device] Unable to discover a device at address 192.168.1.128
2017-08-16 18:02:34 WARNING (MainThread) [homeassistant.components.vacuum.xiaomi] Got exception while fetching the state: Unable to discover the device 192.168.1.128
azogue commented 7 years ago

I see, those are a lot of errors...

Well, for now there isn't a solution for lazy botvacs, and I think these problems have to be handled within the python-mirobo library, not in Home Assistant (what do you think about, @rytilahti ?), so perhaps opening an issue there is the way to go.

I'm understanding that you normally can access the bot and control it from HA, but sometimes you enter in that bad-update loop for quite some time, I'm correct, @olskar ?

I myself have some of these bad updates from time to time, but I chose to ignore them, because I hadn't the time to investigate and, anyway, in practice, they do not pose any problem to the botvac control... The way to hide these is config the logger like that:

logger:
  default: warn
  logs:
    # Hide botvac connexion errors which happen sometimes:
    homeassistant.components.vacuum: error
    mirobo.device: critical

So you'll never see the messages, but that's obviously not a solution for the problem.

I could imagine some sugar-code in the HA component to handle these without so many logging, remembering the last good update and so, but it would be just that, not a real solution whatsoever. If that is wanted, I could do a PR about that this weekend...

olskar commented 7 years ago

Ok, I reopened it cause it seemed the person in the old issue resolved it by having the right token, but I got the same error even with the right token. If the error should be resolved in python-mirobo, I agree opening an issue there is the right way.

Do you know if this constant behavior might have a negative impact on performance in Home Assistant, or is it just cluttering the logs?

azogue commented 7 years ago

Do you know if this constant behavior might have a negative impact on performance in Home Assistant, or is it just cluttering the logs?

I think there is no real problem; if so, you could see some 'reset timer' in the logs or some side effects in cpu or memory usage, but it's not the case. That's why I chose to ignore them by now...

happyleavesaoc commented 7 years ago

Same problem here.

rytilahti commented 7 years ago

For some reason the vacuum is not always responsive to the initial handshake, but the reason is not yet known. This may be, however, related to this problem: https://github.com/rytilahti/python-mirobo/issues/48

syssi commented 7 years ago

The same issue is discussed here I think: https://github.com/aholstenson/miio/issues/59

antosiekd commented 6 years ago

Also have this log issue, though it does not seem to affect the operation of the vacuum at all. So for now I will ignore the log entries!

Ernst79 commented 6 years ago

For those who are ignoring the messages, I had to change the logger settings (see post from @azogue) since the update to 0.57.

In the last line, I had to change

mirobo.device: critical to miio.device: critical

ferdydek commented 6 years ago

Started seeing in logs today (not sure if related to bump from 0.57 or was there all along):

/usr/lib/python3.6/site-packages/homeassistant/components/vacuum/xiaomi_miio.py:90: DeprecationWarning: Please convert to using 'miio' package, this package will be removed at some point in the future
  from mirobo import Vacuum
...
...
/usr/lib/python3.6/site-packages/homeassistant/components/vacuum/xiaomi_miio.py:203: DeprecationWarning: Call to deprecated function dnd (Use vacuum's dnd_status() instead, which is more accurate).
  STATE_ON if self.vacuum_state.dnd else STATE_OFF,
rytilahti commented 6 years ago

That's not related to this issue, the backend library got bumped without converting the code to use the new package name (the first warning) and dnd_status() (the second warning).

joq3 commented 6 years ago

@ferdydek I have the same issue in my log. @rytilahti is there a fix?

STATE_ON if self.vacuum_state.dnd else STATE_OFF,
/usr/src/app/homeassistant/components/vacuum/xiaomi_miio.py:203: DeprecationWarning: Call to deprecated function dnd (Use vacuum's dnd_status() instead, which is more accurate).
rytilahti commented 6 years ago

The solution is to avoid calling dnd, which is what was proposed here https://github.com/home-assistant/home-assistant/pull/9733 . The problem was that this broke the unit tests horribly and I haven't had time to look how to fix those properly.

joq3 commented 6 years ago

@rytilahti But I don't call dnd, I have the Xiaomi Mi Vacuum component active in my configuration, I haven't done anything else. Is there something I can do to fix this?

ferdydek commented 6 years ago

@joq3 there is nothing broken, its just log info, not actual drop in functionality. @rytilahti if I could code Id gladly help, but if you need tests done poke me here or on discord, always happy to assist. ... also the "unable to discover" ... doesnt this come from attempt to autodiscover the device by the lib ?

rytilahti commented 6 years ago

@joq3 it is coming from the platform requesting dnd status which does not respond with an accurate information and the warning is to show that it should be changed by developers.

@ferdydek the "unable to discover" comes from the library indeed. At the moment the library will try to do a discovery every time before it sends a command to the device, why it fails sometimes is unclear. The tests for this broke as calling dnd_status() instead of reading it from the status message introduces new calls and the tests are looking for a specific ordering of calls, instead of whether those were just called. I'll try to look into fixing it for good before the next release.

olskar commented 6 years ago

I still get those errors even with #10839 merged :/ @rytilahti

ajfriesen commented 6 years ago

Yeah me too.

rytilahti commented 6 years ago

That PR fixes just deprecated warnings which is unrelated to unavailable/timeout issues, I just linked it here as people started discussing about those here. The cause for timeout / unavailable issues is unknown and may be related to local network setups.

ferdydek commented 6 years ago

I have similar impression as @rytilahti regarding the cause of the timeouts.

I do get from time to time "Can't upload the map die to low connection speed. Check your network" in HiMome App just after the "Getting info..." disappears. image

I don't think it has anything to do with my local LAN/WLAN, rather suspect somewhere in the process of getting information a query to Chinese mi servers is passed and that is causing a cascading timeout. When I will get some free time will try to wireshark the info to verify this suspicion (or maybe someone here could do that faster than me?).

rytilahti commented 6 years ago

I think there are users having this problem even when they have blocked the external network access for the device, so that cannot be the only reason. To debug this, we would require testing through various versions to see at what point it stopped working (git bisect may help here) to pinpoint that change.

jghaanstra commented 6 years ago

Just chipping in here. I dont use home-assistant but the same issue occurs on a nodejs library (miio) to control the Xiaomi Mi Robot Vacuum Cleaner. It was introduced with the lastest firmware update of the device with version number 3.3.9_003077. It's described here: https://github.com/aholstenson/miio/issues/59

I lack the knowledge to do a proper inspect of the traffic with a MITM attack but that seems the only way to really troubleshoot what's happening.

Ernst79 commented 6 years ago

@jghaanstra The issue you are referring to is closed. You should consider reopening the issue, if it isn’t solved.

rytilahti commented 6 years ago

Getting time-outs from the device just means that the device is not answering for a reason or another, there's no simple way to pinpoint what is causing this, but the 3077 firmware incorporated more strict checking of the communication (incl. order of messages, thereby increasing msgids, timestamp handling, ..).

That being said, there may very well be something that's been overlooked, but it is not so simple to find out the real causes on real use-cases with heterogeneous network setups. For many python-miio (or miio in JS) is working just fine, where-as some encounter problems with no apparent / easy to find out reason.

If someone has ideas how to debug these issues please report into issue tracker of those upstream projects where possible, thanks!

brent20 commented 6 years ago

Just received a new Mi Robot - was getting this issue on the first setup in HA. Unavailable in UI and timeouts in the logs.

2017-12-22 09:41:12 ERROR (SyncWorker_0) [miio.device] Got error when receiving: timed out

2017-12-22 09:41:12 WARNING (SyncWorker_0) [miio.device] Retrying with incremented id, retries left: 3

iMicknl commented 6 years ago

I have the same issue. It can't connect to the Xiaomi Vacuum from HomeAssistant, but the mirobo Python library works like a charm on my Mac. (with the same IP + token). Anything I can do to help debugging this issue?

danielpalstra commented 6 years ago

Extracting a new token from a recent IOS backup and upgrading the python-miio package to 0.3.3 fixed the issue for me. I am running the 0.60 version of the Home Assistant Docker image.

iMicknl commented 6 years ago

@danielpalstra which firmware do you run on the Xiaomi Vacuum?

danielpalstra commented 6 years ago

@iMicknl I updated today to the latest.

TribuneX commented 6 years ago

Whats the latest version at the moment? I can`t check, since I only use the vacuum via HASS. With 0.3.3 the vacuum becomes unavailable for me in HASS 0.60

iMicknl commented 6 years ago

I just updated to 3.3.9_003094, python-miio 0.3.3 works like a charm locally. However from within HomeAssistant it is unavailable and times out.

danielpalstra commented 6 years ago

I couldn't find any setting in the MiHome IOS that displays the current firmware.

danielpalstra commented 6 years ago

After restarting Home Assistant running into the same issue again

root@homeserver:/config# tail home-assistant.log
2017-12-27 22:06:48 WARNING (MainThread) [homeassistant.helpers.entity] Update of vacuum.xiaomi_vacuum_cleaner is taking over 10 seconds
2017-12-27 22:06:48 ERROR (SyncWorker_1) [miio.device] Got error when receiving: timed out
2017-12-27 22:06:48 WARNING (SyncWorker_1) [miio.device] Retrying with incremented id, retries left: 2
2017-12-27 22:06:53 ERROR (SyncWorker_1) [miio.device] Got error when receiving: timed out
2017-12-27 22:06:53 WARNING (SyncWorker_1) [miio.device] Retrying with incremented id, retries left: 1
2017-12-27 22:06:58 WARNING (MainThread) [homeassistant.components.vacuum] Updating xiaomi_miio vacuum took longer than the scheduled update interval 0:00:20
2017-12-27 22:06:58 ERROR (SyncWorker_1) [miio.device] Got error when receiving: timed out
2017-12-27 22:06:58 WARNING (SyncWorker_1) [homeassistant.components.vacuum.xiaomi_miio] Got exception while fetching the state:
2017-12-27 22:07:24 ERROR (SyncWorker_6) [miio.device] Got error when receiving: timed out
2017-12-27 22:07:24 WARNING (SyncWorker_6) [miio.device] Retrying with incremented id, retries left: 3

However, still inside the docker container running the mirobo command

root@homeserver:/config# mirobo --ip 192.168.1.xx --token TOKEN status
State: Charging
Battery: 100 %
Fanspeed: 60 %
Cleaning since: 0:00:10
Cleaned area: 0.0 m²
root@homeserver:/config#
ferdydek commented 6 years ago

@danielpalstra your errors are not related to this issue. I guess the other issues were fixed with your update and you are left with the point 3 below. But this is not the issue for that problem.

I think we need to close this issue as it begins to suck up all possible issues with miio. To close the topic @rytilahti correct me if Im wrong:

  1. The depreciated and discovery errors are now corrected (this is what this issue was created for with https://github.com/home-assistant/home-assistant/pull/10839).
  2. The updated library that broke the component at some point was fixed.
  3. The source of disconnects and timeouts is currently unknown and is investigated. Please don't add to this issue, create separate issue for that topic instead.
rytilahti commented 6 years ago

I think those may be related, but as this issue has started to cover so many different issues, it's starting to get hard to keep track on all of it.

Thanks for summarizing it all to those three points, however, to my understanding it was only the point 3 what was being tracked in this issue, those two others being just unfortunate, unrelated problems. Number 2 was never tracked here (in homeassistant's issue tracker), and I think the fix is still to be released with the next homeassistant release.

The insight that it works with the mirobo tool is an interesting one though, as if that's true then there must be a way to fix it and that the problem has to have something to do with the state handling (the mirobo tool keeps just the msgid stored between executions where-as the platform keeps the whole instance around). What makes it hard to debug is 1) different people have different kinds of network setups, and they all think they are hit by this issue even if it may be just caused by their network setup and 2) this is working for quite a few people just fine, or so I'd assume.

Coffee-lover commented 6 years ago

Hey guys, I just connected my Xiaomi Me to home-assistant but it is displayed as "unavailable". It prompts: "[miio.device] Unable to discover a device at address xxx.xxx.xxx.xxx" Token and ID were copy - pasted to config-file, so there is no reason to believe in typing mistakes. Probably I'm suffering the same issue discussed above. Best regards

danielpalstra commented 6 years ago

@rytilahti how can I help to gain more insight into "issue 3"?

joq3 commented 6 years ago

I am having the same issues after updating Home Assistant to v.60. The Mi Vacuum shows up as unavailable. Before the update everything worked great!

RDumais commented 6 years ago

Same issue as above users.

EDIT: My original reply was beyond useless. I have solved my issue and will post it here in hopes of helping someone. My Hass.io version is 60.0.

My problem was I grabbed my token from my iOS device using a .sqlite DB explorer and got a 96 character token. This was not working for me, so I used miio (miio --discover) and got a 32 character token. I tried using this token, but still not working. I would run --discover after pairing the device to my network and my MiHome app, but the token would should '???' when I ran 'miio --discover'... weird.

The solution for me was to take the original 96 character token and decode it to a 32 character token. I forget the website I used, but there are probably a hundred of them that can do the same thing.

rytilahti commented 6 years ago

Getting the token is described in https://python-miio.readthedocs.io/en/latest/discovery.html#tokens-from-backups . The most reliable way is to extract them from backups, and works with all supported devices. Tokens of vacuums have not been discoverable through other means for a while now. The miio-extract-tokens tool will do decoding if needed automatically for you, and this works for both android & ios backups.

@danielpalstra considering it works in the console, it most likely has something to do with either 1) timing or 2) msg id -- you could enable debug mode and check the timing between the handshake and the status request, maybe the time difference is too great and the robot ignores the request because of that. For message ids, they should always be incremented, so if you see out-of-order msgids that could be something to investigate.

danielpalstra commented 6 years ago

@rytilahti took a spin with the dev Docker image and it seems to be working better. Will double check network and time settings.

olskar commented 6 years ago

Is this perhaps solved by #11232 ? Haven't received any error messages after upgrading python-miio to 0.3.3

Edit: No, still same problem :(

jaimemrjm commented 6 years ago
mirobo --ip 192.168.1.15 --token xxxxxx
State: Charging
Battery: 100 %
Fanspeed: 60 %
Cleaning since: 0:58:56
Cleaned area: 56.6575 m²

but since I have updated to HomeAssistant 0.63, I receive the same error: Unable to discover the device. Version of python-mio: 0.3.5

rytilahti commented 6 years ago

Please make sure you are using the latest version of construct, maybe that will help. What kind of network setup you have, e.g. are you blocking vacuum's access to the xiaomi cloud or not? The error is so generic (which just says that the robot is not responding to your queries) that it's hard to pinpoint where the problem is if you are not receiving any other errors or warnings.

jaimemrjm commented 6 years ago

By updating to python-miio to 0.3.6 solves the issue but HA downgrades the library on boot always: feb 15 23:10:42 camelberry hass[25477]: 2018-02-15 23:10:42 INFO (Thread-5) [homeassistant.util.package] Attempting install of python-miio==0.3.5 How can force the newest python-miio version?

syssi commented 6 years ago

You could start HA by bin/hass --skip-pip

jaimemrjm commented 6 years ago

Yes, I have updated the homeassistant.service file to use --skip-pip as temporary solution.

ferdydek commented 6 years ago

Still getting:

Feb 25 22:38:31 MrMeeSeeks hass[29480]: 2018-02-25 22:38:31 WARNING (Thread-5) [homeassistant.components.vacuum.xiaomi_miio] Got exception while fetching the state: Unable to discover the device 192.168.2.198
Feb 25 22:39:29 MrMeeSeeks hass[29480]: 2018-02-25 22:39:29 ERROR (Thread-9) [miio.device] Got error when receiving: timed out
Feb 25 22:39:29 MrMeeSeeks hass[29480]: 2018-02-25 22:39:29 WARNING (Thread-9) [miio.device] Retrying with incremented id, retries left: 3

info: construct==2.9.31 homeassistant==0.64.0 python-miio==0.3.7 firmware 3.3.9_003096, HW: ver 1

There is no issue with functionality or sensors. Vacuum works fine.

syssi commented 6 years ago

This is fine. The device doesn't respond sometimes. The second try / retry was successful in your case.

beatmag commented 6 years ago

I have construct==2.9.31 homeassistant==0.64.1 python-miio==0.3.7

The issue with my gen2 roborock is that it’s unable to discover it anymore. It was working fine with 0.64. Then I started to add lifx lights which vacuum still worked. But after setting up homebridge and homebridge home assistant plugin after a restart of home assistant vacuum no longer responds.

Mirobo command line tool also doesn’t work anymore.

Is this because the vacuum token has changed? My vacuum does not have access to Internet. It was working fine pre 0.64 for a whole week. I would get some b’fffffffffff errors though.

Any ideas? Tried downgrading same thing. Surprised mirobo command line isn’t working anymore. I can check the token again tonight but is the token suppose to change? The vacuum still pings.

syssi commented 6 years ago

Please check your token. It has possibly changed. There is not much known about the 2gen vacuum yet.