Add Map to Xiaomi vacuum cleaner

Dear all,

I was just wondering if it should be possible to add the MAP the vacuum cleaner creates on each new cleaning session and show those in Front-End?

I would love this feature, to be able to remove the Mi Home app would mean I have all my home automation in one app/site only :smiley:

1 Like

Exactly .that’s a good point

May be of some help for the technically-inclined that may want to tackle this:

Would love this!!

This is interesting, I will look into this and see what I can do with this.

Ok. So I have looked into this now and it is doable, however it is a huge pile of work that includes setting up the vacuum to be rooted more user-friendly and then providing an api on the machine (or it could actually run hass itself :smiley: ).

If I get some help on this one it would be great! I will try to fix the dustcloud server or create a new service to run on the machine as soon as I have rooted mine (have been unsuccessful so far).

1 Like

Nice seeing progress here :wink:

I would love this feature, I could control what the little industrious thing is doing without opening the app on the phone, but from my desktop while I’m working. Also, we are here because we want everything integrated in one app, so…
I don’t think the “rooting/hacking” way is the right one. Although it’s possible it’s not for the fainted of heart, and it would void the product’s guarantee.
Component improvement would be much better to me (but I’m absolutely unable to do it!)

1 Like

I’d love a map, but even more than that, I’d love for the component to be fixed: it no more works in 62.0 and 62.1, don’t upgrade!

The map would be a great feature if we could get rid of the app and the amount of tracking that comes along with it, that would be nice. But the component definitely needs to be fixed before anything new can be implemented.

It has been fixed already, that’s the thing. There is nothing else that can be done by the python-miio developers. The only solution currently for a map is to have a rooted device, fetch the sqlite database from it and create maps with https://github.com/dgiese/dustcloud/blob/master/xiaomi.vacuum.gen1/mapextractor/extractor.py . Maybe this will be added later on in a form or another to python-miio, to make it simpler.

1 Like

It has not been fixed for me, I just tried uncommenting the vacuum section in my config to see and it still gives me this error:

2018-02-06 16:37:37 ERROR (MainThread) [homeassistant.components.vacuum] Error while setting up platform xiaomi_miio
Traceback (most recent call last):
  File "/home/hass/lib/python3.6/site-packages/homeassistant/helpers/entity_component.py", line 189, in _async_setup_platform
    SLOW_SETUP_MAX_WAIT, loop=self.hass.loop)
  File "/usr/lib/python3.6/asyncio/tasks.py", line 358, in wait_for
    return fut.result()
  File "/usr/lib/python3.6/asyncio/futures.py", line 245, in result
    raise self._exception
  File "/usr/lib/python3.6/asyncio/tasks.py", line 180, in _step
    result = coro.send(None)
  File "/usr/lib/python3.6/asyncio/coroutines.py", line 210, in coro
    res = func(*args, **kw)
  File "/home/hass/lib/python3.6/site-packages/homeassistant/components/vacuum/xiaomi_miio.py", line 90, in async_setup_platform
    from miio import Vacuum
  File "/home/hass/lib/python3.6/site-packages/miio/__init__.py", line 2, in <module>
    from miio.protocol import Message, Utils
  File "/home/hass/lib/python3.6/site-packages/miio/protocol.py", line 179, in <module>
    Const(0x2131, Int16ub),
  File "/home/hass/lib/python3.6/site-packages/construct/core.py", line 1927, in __init__
    super(Const, self).__init__(subcon)
  File "/home/hass/lib/python3.6/site-packages/construct/core.py", line 288, in __init__
    raise TypeError("subcon should be a Construct field")
TypeError: subcon should be a Construct field

My config setup is this:

vacuum:
  - platform: xiaomi_miio
    host: 192.168.1.221
    token: !secret vac_token

I’d like to see the maps feature too, but it needs a rooted device.

For the fellows that have updated to 0.62.1, I could fix the xiaomi component manually:

stop HA
$ source homeassistant/bin/activate
$ pip3 install python-miio==0.3.5
then just substitute the file homeassistant/lib/python3.5/site-packages/device.py with this one
https://raw.githubusercontent.com/rytilahti/python-miio/17c7a26602b4d11d6a2563ba19eade4b73c7608a/miio/device.py
(info taken from: https://github.com/rytilahti/python-miio/issues/201)

Regards

My main issue is that when I start my Roborock from within HA, it completly removes my old map. So if I have a door shut, start the cleaning, and then want to do another cleaning job later in that specific room, I have to manually navigate it to the room first since the room has disappeared from the map. If I only control it through the Mi Home app though, it keeps the room, although the door was shut.

Do you solved problem with map?

No I didn’t, It was a feature request.

Hi, it is quite easy to get the map and traces of the vacuum.
The current map is stored in /run/shm/navmap*.ppm (containing any random number). The path data is stored in /run/shm/SLAM_fprintf.log.
Dustcloud already has a nice python script that uses these two files and creates a pretty png file

Most simple way might be to periodically download these files using scp and then show the png in HA. The name of the mapfile changes from time to time.

I do not know the HA api and extensions yet - hence anybody who might know how to integrate this would be welcome.

At the moment I think there is no way to get these data without root access to the vacuum - but who doesn’t have root :wink:

Thanks for your hints.

I was able to get the map and put in on HA. It’s updated during the cleanup quite quickly (1~2s).

4 Likes

Great, can you please share your code?