dreame-vacuum: Memory leak / Causing HA to freeze

Describe the bug The integration produces error messages in a regular basis (few minutes / couple of seconds apart). Furthermore, the RAM and SWAP of the system steadily gets filled up. Once it reaches 100%, the system does not respond anymore.

To Reproduce Disconnect the robot (power off the robot or toggle WIFI off)

Expected behavior A clear and concise description of what you expected to happen.

Screenshots / Log

2022-12-26 09:47:38.054 ERROR (MainThread) [custom_components.dreame_vacuum] Update failed: Traceback (most recent call last):
  File "/config/custom_components/dreame_vacuum/coordinator.py", line 314, in _async_update_data
    await self.hass.async_add_executor_job(self.device.update)
  File "/usr/local/lib/python3.10/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/dreame_vacuum/dreame/device.py", line 982, in update
    self.connect_device()
  File "/config/custom_components/dreame_vacuum/dreame/device.py", line 714, in connect_device
    self.info = DreameVacuumDeviceInfo(self._protocol.connect())
  File "/config/custom_components/dreame_vacuum/dreame/protocol.py", line 482, in connect
    response = self.send("miIO.info", retry_count=retry_count)
  File "/config/custom_components/dreame_vacuum/dreame/protocol.py", line 509, in send
    raise DeviceException("Unable to discover the device over cloud") from None
custom_components.dreame_vacuum.dreame.exceptions.DeviceException: Unable to discover the device over cloud

2022-12-26 09:48:59.728 ERROR (MainThread) [custom_components.dreame_vacuum] Update failed: Traceback (most recent call last):
  File "/config/custom_components/dreame_vacuum/coordinator.py", line 314, in _async_update_data
    await self.hass.async_add_executor_job(self.device.update)
  File "/usr/local/lib/python3.10/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/dreame_vacuum/dreame/device.py", line 982, in update
    self.connect_device()
  File "/config/custom_components/dreame_vacuum/dreame/device.py", line 714, in connect_device
    self.info = DreameVacuumDeviceInfo(self._protocol.connect())
  File "/config/custom_components/dreame_vacuum/dreame/protocol.py", line 482, in connect
    response = self.send("miIO.info", retry_count=retry_count)
  File "/config/custom_components/dreame_vacuum/dreame/protocol.py", line 509, in send
    raise DeviceException("Unable to discover the device over cloud") from None
custom_components.dreame_vacuum.dreame.exceptions.DeviceException: Unable to discover the device over cloud

2022-12-26 09:50:21.339 ERROR (MainThread) [custom_components.dreame_vacuum] Update failed: Traceback (most recent call last):
  File "/config/custom_components/dreame_vacuum/coordinator.py", line 314, in _async_update_data
    await self.hass.async_add_executor_job(self.device.update)
  File "/usr/local/lib/python3.10/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/dreame_vacuum/dreame/device.py", line 982, in update
    self.connect_device()
  File "/config/custom_components/dreame_vacuum/dreame/device.py", line 714, in connect_device
    self.info = DreameVacuumDeviceInfo(self._protocol.connect())
  File "/config/custom_components/dreame_vacuum/dreame/protocol.py", line 482, in connect
    response = self.send("miIO.info", retry_count=retry_count)
  File "/config/custom_components/dreame_vacuum/dreame/protocol.py", line 509, in send
    raise DeviceException("Unable to discover the device over cloud") from None
custom_components.dreame_vacuum.dreame.exceptions.DeviceException: Unable to discover the device over cloud

2022-12-26 09:51:43.060 ERROR (MainThread) [custom_components.dreame_vacuum] Update failed: Traceback (most recent call last):
  File "/config/custom_components/dreame_vacuum/coordinator.py", line 314, in _async_update_data
    await self.hass.async_add_executor_job(self.device.update)
  File "/usr/local/lib/python3.10/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/dreame_vacuum/dreame/device.py", line 982, in update
    self.connect_device()
  File "/config/custom_components/dreame_vacuum/dreame/device.py", line 714, in connect_device
    self.info = DreameVacuumDeviceInfo(self._protocol.connect())
  File "/config/custom_components/dreame_vacuum/dreame/protocol.py", line 482, in connect
    response = self.send("miIO.info", retry_count=retry_count)
  File "/config/custom_components/dreame_vacuum/dreame/protocol.py", line 509, in send
    raise DeviceException("Unable to discover the device over cloud") from None
custom_components.dreame_vacuum.dreame.exceptions.DeviceException: Unable to discover the device over cloud

2022-12-26 09:53:04.939 ERROR (MainThread) [custom_components.dreame_vacuum] Update failed: Traceback (most recent call last):
  File "/config/custom_components/dreame_vacuum/coordinator.py", line 314, in _async_update_data
    await self.hass.async_add_executor_job(self.device.update)
  File "/usr/local/lib/python3.10/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/dreame_vacuum/dreame/device.py", line 982, in update
    self.connect_device()
  File "/config/custom_components/dreame_vacuum/dreame/device.py", line 714, in connect_device
    self.info = DreameVacuumDeviceInfo(self._protocol.connect())
  File "/config/custom_components/dreame_vacuum/dreame/protocol.py", line 482, in connect
    response = self.send("miIO.info", retry_count=retry_count)
  File "/config/custom_components/dreame_vacuum/dreame/protocol.py", line 509, in send
    raise DeviceException("Unable to discover the device over cloud") from None
custom_components.dreame_vacuum.dreame.exceptions.DeviceException: Unable to discover the device over cloud

2022-12-26 09:54:26.638 ERROR (MainThread) [custom_components.dreame_vacuum] Update failed: Traceback (most recent call last):
  File "/config/custom_components/dreame_vacuum/coordinator.py", line 314, in _async_update_data
    await self.hass.async_add_executor_job(self.device.update)
  File "/usr/local/lib/python3.10/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/dreame_vacuum/dreame/device.py", line 982, in update
    self.connect_device()
  File "/config/custom_components/dreame_vacuum/dreame/device.py", line 714, in connect_device
    self.info = DreameVacuumDeviceInfo(self._protocol.connect())
  File "/config/custom_components/dreame_vacuum/dreame/protocol.py", line 482, in connect
    response = self.send("miIO.info", retry_count=retry_count)
  File "/config/custom_components/dreame_vacuum/dreame/protocol.py", line 509, in send
    raise DeviceException("Unable to discover the device over cloud") from None
custom_components.dreame_vacuum.dreame.exceptions.DeviceException: Unable to discover the device over cloud

2022-12-26 09:55:48.313 ERROR (MainThread) [custom_components.dreame_vacuum] Update failed: Traceback (most recent call last):
  File "/config/custom_components/dreame_vacuum/coordinator.py", line 314, in _async_update_data
    await self.hass.async_add_executor_job(self.device.update)
  File "/usr/local/lib/python3.10/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/dreame_vacuum/dreame/device.py", line 982, in update
    self.connect_device()
  File "/config/custom_components/dreame_vacuum/dreame/device.py", line 714, in connect_device
    self.info = DreameVacuumDeviceInfo(self._protocol.connect())
  File "/config/custom_components/dreame_vacuum/dreame/protocol.py", line 482, in connect
    response = self.send("miIO.info", retry_count=retry_count)
  File "/config/custom_components/dreame_vacuum/dreame/protocol.py", line 509, in send
    raise DeviceException("Unable to discover the device over cloud") from None
custom_components.dreame_vacuum.dreame.exceptions.DeviceException: Unable to discover the device over cloud

Additional Information (please complete the following information)

  • Model Name: dreame_bot_w10
  • Firmware Version [e.g. 1156]:
  • Home Assistant Version: 2022.12.8
  • Configuration Type [With or without map support]: with map - cloud preferred
  • Errors or warnings shown in the HA logs (if applicable): (see above)

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 1
  • Comments: 22 (11 by maintainers)

Most upvoted comments

Same problem here with 2.0.0b6 on a Debian HA core installation: After starting HA with my Dreame D10 Plus offline, the HA log is spammed with the message quoted above by @ImpieYay. This creates more and more stale CLOSE_WAIT TCP-sessions leading to a HA crash after a few hours. Low resolution map on or off doesn’t make a difference here. There must be a way to stop spamming the log and to regularly close these sessions, thus avoiding the crash - I hope 😉

I have fixed this on both v1.0.2 and v2.0.0b9 versions.