Xiaomi Vacuum with Valetudo RE: How to MAP, Zoned Cleaning and Notifications with Home Assistant?

Again, many thanks for your reply.

I got it working!!! :star_struck:

A little sum up for everyone who has similar difficulties getting a live map into HA:

  1. Install Valetudo on your vacuum following official instructions. My advice: Install old xiaomi app to get the token, use dustbuilder to create your firmware and install that created firmware using RRCC. Its the shortest and most fail-save way I guess.
  2. Once done you can easily install valetudo RE from this point on. Just download the .deb file from valetudo re releases, place it onto the vacuum and install it using dpkg -i filename.deb. Other installation methods can be found here but again, I guess this is the easiest one.
  3. Now you should have a fully working vacuum running valetudo re. On itā€™s IP adress you should see a working live map. Next is on how to get that into home assistant.
  4. If you havenā€™t, install mosquitto broker addon for home assistant following the official guide. Keep in mind to create a dedicated home assistant user for later use with mosquitto. Once installed you should add
mqtt:
  broker: IP_of_machine_mosquitto_is_running_on

to your config.yaml. For me this was the very same my whole Home Assistant is running on.

  1. Now comes the part with valetudo-mapper:
    From what I understood valetudo re is only broadcasting raw data via mqtt to save resources on the vacuum itself. valetudo-mapper is a little helper program that converts this raw data into an image and passes it along to whatever mqtt service you want.
    For that to work you first have to setup your config.json on the vacuum itself to actually broadcast the data. Here is my example config. You find that on your vacuum at mnt/data/valetudo/config.json
 "mqtt": {
    "enabled": true,
    "identifier": "tachikoma",
    "topicPrefix": "valetudo",
    "autoconfPrefix": "homeassistant",
    "broker_url": "mqtt://HA-username:password@MosquittobrookerIPAdress",
    "provideMapData": true,
    "mapSettings": {
      "drawPath": true,
      "drawCharger": true,
      "drawRobot": true,
      "border": 2,
      "scale": 4
    },
    "caPath": ""
  },
  "dummycloud": {
    "spoofedIP": "203.0.113.1",
    "bindIP": "127.0.0.1"
  },
  "webInterface": {
    "localization": "en",
    "hideMapReload": true,
    "style": ""
  },
  "httpAuth": {
    "enabled": false,
    "username": "valetudo",
    "password": "valetudo"
  },
  "telegramBot": {
    "enabled": false,
    "token": "",
    "password": "",
    "host": "",
    "proxy": "",
    "clients": [],
    "sendConsumables": true,
    "sendConsumablesEvery": false
  },
  "allowSSHKeyUpload": true,
  "map_upload_host": "http://127.0.0.1"
}
  1. With that done your vacuum should broadcast all the necessary data via mqtt.
    I went to install valetudo-mapper via docker. It gets a little catchy as the official instruction say one shoud map the /app/config.json for the mapper. I did that but docker told me ā€œconfig.jsonā€ was a directory not a file. It was my mistake: you first have to create the config.json yourself and place it where docker can find it, else docker would map everything as a directory. Second one should build the container. I used this command:
docker run -d -v /path/to/your/config.json:/app/config.json roflcoopter/valetudo-mapper

This is my config.json:

{
        "mqtt" : {
            "identifier": "tachikoma",
            "topicPrefix": "valetudo",
            "autoconfPrefix": "homeassistant",
            "broker_url": "mqtt://HA-username:password@MosquittobrookerIPAdress:1884",
            "caPath": "",
            "mapSettings": {
                "drawPath": true,
                "drawCharger": true,
                "drawRobot": true,
                "drawForbiddenZones": true,
                "drawVirtualWalls": true,
                "border": 2,
                "scale": 4,
                "gradientBackground": true,
                "crop_x1": 30,
                "crop_y1": 70,
                "crop_x2": 440,
                "crop_y2": 440
            },
            "mapDataTopic": "valetudo/tachikoma/map_data",
            "minMillisecondsBetweenMapUpdates": 10000,
            "publishMapImage": true,
            "publishMapData": true
        },
        "webserver": {
            "enabled": true,
            "port": 3000
        }
}

Note that you should use the same identifier, ā€œTachikomaā€ or the name of your vacuum so that valetudo-mapper knows where to catch the data from. The broker url should be your mosquitto service in home assistant as the mapper will send the created image to this destination.
Edit: Running a docker container separately from HA proved to be unstable for me. It crashed several times. So I followed @komadori1 's advice and added this repository and installed valetudo-mapper as add-on in home assistant. Now everything runs smooth as butter :slight_smile:

  1. Almost done:
    Head over to your configuration.yaml and add the map sensor:
sensor:
  - platform: mqtt
    state_topic: "valetudo/tachikoma/state"
    json_attributes_topic: "valetudo/tachikoma/map_data_parsed"
    name: tachikoma_map
    value_template: 'OK'
    scan_interval: 5

recorder:
  exclude:
    entities:
      - sensor.tachikoma_map

Restart home assistant and add the valetudo-map-card for lovelace from HACS to any home screen with this code

type: 'custom:valetudo-map-card'
entity: sensor.tachikoma_map
crop:
  bottom: 0
  left: 0
  right: 0
  top: 0
icon_scale: 1
map_scale: 1
min_height: 0
rotate: 0
show_dock: true
show_path: true
show_vacuum: true

Hopefully you see the same result as me:
image

14 Likes

the problem is solved

Glad this all worked out in the end now :slight_smile:

Maybe you could change the title to focus on valetudo RE and mapper and mark the summary of yours as a solution for others to find it more easily

1 Like

I will do that. I will add my configuration for zoned cleanup and notifications later on. Maybe someone can use that. Googleing around I found many different configuations, some are heavily outdated and I had to use some trial and error to get that working.

I have a second vacuum, its the Xiaomi vacuum 1s, do you know how to get live map from there? From my research I found neither dustcloud nor valetudo is available for this device.

Thank you so much, I have been using the hassio supervisor for a long time with this, but I recently started to migrate everything to docker on Unraid and this one I couldnā€™t figure out. Your tutorial on this made it work for me again! Thank you so much!

1 Like

@EdwardEnglish your post above got this working for me beautifully. THANK YOU!

Now I want to have a 2nd vac and mapā€¦ Not sure yet if that will require a 2nd container running a second instance of valetudo-mapper.

@jimz011 Did you ever figure out getting this container to work in unRaid?

1 Like

Glad this could help.
I have a second vacuum but itā€™s an s1 and valetudo does not support it.
Maybe you should ask the guys from valetudo-mapper how it would work with two devices or find something to start the mapper again.
If you donā€™t come up with anything I did manage to run valetudo-mapper in plain docker apart from Home Assistant. Your second valetudo-map-card would then interpret that external data. Could be one solution.

yes, I did. Thank @EdwardEnglish for his tutorial. it is just a few posts up.

Im using custom:vacuum-card with valetudo RE. All working fine except for zone cleaning script. I was able to get coordinates from Valetudo RE custom zones I made, but when I call app_zoned_clean it goes to another placeā€¦

How are you using zone cleaning from HA?

Just made it

clean_all:
  alias: Vacuum Home
  sequence:
    - service: vacuum.send_command
      data:
        entity_id: vacuum.rockrobo
        command: 'zoned_cleanup'
        params:
          'zone_ids':
            - home
4 Likes

Did this fix it? I have the same issue and have not been using it in zoned mode for a while now.
Zoned cleaning from valetudo web interface works but using the same coordinates in home assistant does not. It goes somewhere else or canā€™t reach the zone at all

Yes, it is working!

That example starts cleaning a zone that is called ā€œhomeā€ on valetudo RE web interface! I defined all of my zones in valetudo RE interface an then created a script like this one for everyone of them.

1 Like

My valetudo-map-card shows the paths, and the icons for charge and vacuum. But no map. I tripple checked all settings with the adjusted settings for RE, and valetudo mapper also seems to work fine. Anyone has an Idea why it does not work?

Using vacuum-card, the map shows (but that does not use the valetudo-mapper, but Iā€™m not sure?), but there I canā€™t rotate.

And about changing colors, how can this be accomplished? The UI from Valetudo RE with dark theme shows a nice Black/Gray map. Vacuum-card shows the blue map. Valetudo-mapper (running as hassio addon) is configured with my own colors, but it still shows the blue map. And valetudo-map-card does not show any map yet :slight_smile:

With the latest update you had to reset the config of mapper or map card I guess. Did you do that?

Zoned cleaning is working,
Anyone who fixed room cleaning?

I cant create zones because not all my rooms are a squaresā€¦

- service: vacuum.send_command
  data:
    entity_id: vacuum.rockrobo
    command: 'segmented_cleanup'
    params:
      'segment_ids':
        - home
1 Like

what would be the ā€œgo toā€ command with this style? like send it to a place and stay there

edit: I found this and it works:

move_vacuum_to_bin_emptying_location:
     alias: "Move Vacuum to bin emptying location"
     sequence:
       - service: vacuum.send_command
         data:
           entity_id: 'vacuum.rockrobo'
           command: 'go_to'
           params:
             'spot_id': 'KitchenBin'

1 Like

So Iā€™ve been messing with this for a few days now, and I think I am close, but having issues. Iā€™m still new to HA and it seems to be a pretty steep and frustrating learning curve, but Iā€™m getting there.

So far I have Valetudo RE installed and working on the vacuum. I can control everything and see the map from the vacuum IP, and I have edited the config.json on the vacuum. Valetudo map card and valetudo-mapper are installed, along with mosquitto. I donā€™t know how to tell if the vacuum is communicating with HA using mqtt. I can control the vacuum from HA using a separate card I installed and xiaomi controls. The sensor and recorder exclusion have been added to my configuration.yaml and I manually created a lovelace card.

My issue is that the card only shows ā€œEntity not available: sensor.rockrobo1_mapā€. Viewing configuration>entities, rockrobo1_map is there with an entity ID of camera.rockrobo1_map. Viewing Developer tools>states, camera.rockrobo1_map is there with an idle state.

I feel like iā€™m missing something simple, but I canā€™t seem to figure it out. Any suggestions?

Check your valetudo-mapper config and make sure your broker_url has username, password, and ip for home assistant (Iā€™ve got a user just for mqtt). Thatā€™s what was tripping me up at first.

@bittles I also have a user just for mqtt. Do you know the proper format for the broker_url? I currently have ā€œmqtt://username:password@IP:portā€