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

reading up on this, it seems this was a firmware reset which got you back to valetudo, so you should be fine

Here is another topic on github that had the same issue as you - you might try RRCC from the previous post and install valetudo from there (save the config.json first)

no, this was a copy paste error on my side

1 Like

OK new evening new try.

what you said earlier, that you think there is still valetudo RE installed but the interface just showed me a different version induced me to reinstall valetudo again.
I copied the .deb file from here to my vacuum using filezilla, logged into the robot via ssh and installed it with dpkg -i filename.deb. Now the IP of my vacuum shows the following software information:

this used to give me troubles before, but is unrelated to the issue at hand, you can fix it by changing the line in /etc/dnsmasq.conf from bind-interfaces to bind-dynamic

I fixed this, just to be sure. Thanks for the hint.

Now, robot is running fine, my config.json on my valetudo re enabled robot looks like this:

  "mqtt": {
    "enabled": true,
    "identifier": "tachikoma",
    "topicPrefix": "valetudo",
    "autoconfPrefix": "homeassistant",
    "broker_url": "mqtt://192.168.188.45",
    "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"
}

If I listen to mqtt topic valetudo/# in home assistant I can see:

Message 8 received on valetudo/tachikoma/attributes at 8:21 PM:
{
    "cleanTime": "169.5",
    "cleanArea": "8805.5",
    "cleanCount": 501,
    "last_run_stats": {
        "startTime": 1582372097000,
        "endTime": 1582373128000,
        "duration": 968,
        "area": "15.0",
        "errorCode": 0,
        "errorDescription": "No error",
        "finishedFlag": true
    },
    "currentCleanTime": "16.1",
    "currentCleanArea": "15.0",
    "mainBrush": "130.5",
    "sideBrush": "30.5",
    "filter": "144.2",
    "sensor": "27.7",
    "state": "docked",
    "valetudo_state": {
        "id": 8,
        "name": "Charging"
    }
}

No map data shows up. Donā€™t know where to go from here?
The link you provided suggest I should reinstall valetudo again from scratch right? Donā€™t know if I am in for that honestlyā€¦

Since you are now on valetudo RE, the best choice is now to go for valetudo-mapper :slight_smile: I have never tried it, but from my understanding:

If you are running home assistant (formerly known hassio), there should be an add-on
If you are running home assistant core (formerly known home assistant) in a docker then use the dockerfile and map the config
Or simply just run it with npm start as described

My only guess at this point is (and it is really just a guess), that you had a firmware reset from valetudo RE to valetudo 0.4.0 but some files from RE were still there.

Thatā€™s why I love RRCC, once it is rooted and you have your ssh pair, you can connect to it with a nice gui and 1 click install valetudo. Saved me a ton of work when the robot had its firmware reset before.
But then again, I have never tried valetudo RE and do not know if you can simply override it. Iā€™d give the mapper a try first, does not seem too difficult

You are absolutely right. I used RRCC after I retrieved the token to install valetudo in the first place. It was almost plugā€™nā€™play, very nice.
I just managed to get valetudo-mapper running on my laptop but this was more of a test. Where did you find this add-on for HA? Searched everywhere did not find it. And when I just want to create it as a docker container I cant seem to figure out how to bind mount /data/config.json as mentioned in the instructions. Because this is a file it always tells me config.json is a directoryā€¦

I donā€™t use home assistant (formerly hassio), so I am not sure how addons are integrated, I kinda just know they are there and when doing some research I found repositories like:
this one or this one

Are you using docker-compose or docker? Can you share your commands?

You might have used a trailing ā€œ/ā€

I just tried it myself, the log looks fine for me

commandline:

Creating valetudo-mapper-master_mapper ... done
Attaching to valetudo-mapper-master_mapper
mapper  | 
mapper  | > [email protected] start /app
mapper | > node app.js
mapper  | 
mapper  | Loading configuration file: /app/config.json
mapper  | Connecting to MQTT Broker

container log (from portainer):

[email protected] start /app
node app.js
Loading configuration file: /app/config.json
Connecting to MQTT Broker

This is the docker-compose I was using:

version: '3'
services:
  mapper:
    build: .
    ports:
     - "3000:3000"
    volumes:
     - $dockerdir/valetudo-mapper-master/config.json:/app/config.json

I got it up and running, but since I do not have valetudo RE i could not test it working

1 Like

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ā€¦