Valetudo - Xiaomi Vacuum Dustcloud alternative, Live Maps

I have been trying for the past few weeks to get Dustcloud to talk to my V2 Vacuum (Roborock S50)

I have never connected her to the cloud, as soon as I bought her I rooted Rosie (Yes she is called Rosie)

I have given up on Dustcloud but I have found an alternative!

Valetudo

Valetudo is very new at under two months old, but so far I am enjoying it.
It is hosted on the Vacuum it’s self and offers a web interface where you can check stats, control the vacuum as a remote and also get your lovely real time maps.

It does need a rooted Vacuum, but rooting it is really easy esp compared to YAML!!!
How to Root

I still have Rosie configured in the normal Xiaomi way on HASS

configuration.yaml

vacuum:
  - platform: xiaomi_miio
    host: 192.168.x.x
    token: xxxx
    name: Rosie

So I can still send normal commands and zoned cleaning through HASS as I am still using the standard interface at the moment.

For live images from Valetudo there in an API and how it works at the moment is to send an API request to the Vacuum and you get a data string back.

The most simple form is:

ipaddress/api/remote/map

You will then get something like:

{“scale”:4,“border”:8,“doCropping”:true,“drawPath”:true,“mapsrc”:"/maps/2018-08-29_15-57-24.png",“drawCharger”:true,“charger”:[516,588],“drawRobot”:true,“robot”:[516,573],“robotAngle”:270}

Every time you send a request a new image is made.

So how I added this into HASS is as follow:

configuration.yaml

sensor:

  - platform: rest
    resource: http://192.168.x.x/api/remote/map
    name: RosiesMap
    value_template: '{{ value_json.mapsrc }}'

The part value_template: ‘{{ value_json.mapsrc }}’ basically filters all the other bits out and returns the image path minus the actual IP address.

I then have a generic camera setup piecing together the IP address of the Vacuum and the value of RosiesMap into a complete address to the current map image.

configuration.yaml

camera:
  - platform: generic
    name: Vacuum Map
    still_image_url: http://192.168.x.x{{states.sensor.rosiesmap.state | string }}
    content_type: image/png
    framerate: 1

Obviously the sensor name needs to match the name of the “rest sensor” you have created previously.

This is only a very basic setup so far, I need to improve on it quite a bit. There are probably more elegant ways of doing this with scripting perhaps and conditions. As at default the rest sensor polls the Vacuum every 30 seconds for a new Image even if it’s sat idle.
So going forward I will probably request a new Image upon HASS Startup in case you need to reload and then only update the image when in run mode, but more often like 2 -5 seconds so you can get a real time map of the progress.

32 Likes

Reserved for future use…

I’ve implemented using Valetudo this morning, and I have to say that I quite like it :slight_smile:
It gives the possibility of local control and maps without having to use the Mi Home app.

Next step will be integrating the map in HASS, but I’ll first have to think about ‘how do I want it to work’ some more.

I have been giving this some more thought.
At the min the rest sensor updates every 30 seconds, which is to slow for when it’s Vacuuming up.

I can use say a scan_interval: 2 or 5 etc but then I don’t want it running that quick when it’s idle. There doesn’t seem to be the option of turning of the rest sensor when “vacuum:docked” and turning on only when “vacuum:cleaning”

I was wondering if you can use an input number on the scan_interval: and then when it’s in docked state it only updates the sensor once per hour or so, but when in cleaning state it automatically changes the scan_interval to how many seconds you want.
I need to try and get my head round the input number function.

Didnt hear about Valetudo before. But it sounds great.
Can you do zone cleaning using the defined zones in Valetudo?

You can do zoned cleaning, but I have not fully mapped the house out yet though as still doing DIY so can’t get everywhere with Rosie yet.

Looking forward to getting zoned cleaning done though.

Thanks for the config. After i rooted my vacuum, it was really easy to display the map in Home Assistant.

Glad it helped someone out.

Hi,

sounds interesting, but I am not fully getting the procedure. I assume, that I have to flash the device with the modified firmware from dust cloud so that I can ssh into it and install the Valetudo binaries ?

Lars

You do need to flash a modified firmware onto the Vacuum to get root access, but you are not actually flashing / copying anything from Dustcloud in a way.

The link is in the first post (Blue coloured “How to root”)

It really is easy to do!
You then copy one binay from Valetudo over onto the vacuum and one startup script, that is all.

Which modified firmware should I use ?

Lars

I am using the V2 Vacuum / Roborock S50.

I just used the latest one from here

For V1 / Gen 1 here

Then just follow the instructions.

I know it is a kind of off-topic but it’s also possible to run aplay or espeak in the vacuum… after ssh acces there are plenty of possibilities. IT’s a modified ubuntu 14.x but you can install packages as usual…Looking forward for new exciting examples on how to modify the robo :slight_smile:

Hmm Rosie could play her fav music as she cleans up :stuck_out_tongue:

I’m agreee

Great project, I really like it and it helps to have the map on Valetudo and also on HA. Thanks for the contribution.
There still are some things that can be added, like history cleaning, but it is already very useful.
One question related to Valetudo : is it possible to start it on another port than the default 80?
One question not related to Valetudo but related to the vacuum : after rooting the thing, do you guys do an upgrade to the Ubuntu OS (apt-get upgrade)?
I have these as upgradable but I don’t know if it is better to leave it as is or do the upgrade :
The following packages will be upgraded:
apt apt-utils base-files bash bsdutils ca-certificates coreutils cpio dnsmasq-base dosfstools dpkg e2fslibs e2fsprogs eject file gnupg gpgv ifupdown init-system-helpers initramfs-tools initramfs-tools-bin initscripts iproute2 isc-dhcp-client isc-dhcp-common klibc-utils kmod krb5-locales libapt-inst1.5 libapt-pkg4.12 libasn1-8-heimdal libblkid1 libc-bin libc6 libcgmanager0 libcurl3 libdb5.3 libdbus-1-3 libdrm2 libffi6 libgcrypt11 libgnutls-openssl27 libgnutls26 libgssapi-krb5-2 libgssapi3-heimdal libhcrypto4-heimdal libheimbase1-heimdal libheimntlm0-heimdal libhx509-5-heimdal libicu52 libidn11 libjpeg-turbo8 libk5crypto3 libklibc libkmod2 libkrb5-26-heimdal libkrb5-3 libkrb5support0 libldap-2.4-2 libmagic1 libmount1 libnl-3-200 libnl-genl-3-200 libpam-modules libpam-modules-bin libpam-runtime libpam0g libpcre3 libpcsclite1 libplymouth2 libpng12-0 libprocps3 libroken18-heimdal librtmp0 libss2 libssl1.0.0 libtasn1-6 libudev1 libuuid1 libwind0-heimdal libx11-6 libx11-data login logrotate lsb-base makedev module-init-tools mount multiarch-support ntpdate openssh-client openssh-server openssh-sftp-server openssl passwd perl perl-base perl-modules plymouth procps resolvconf rsync rsyslog sensible-utils sudo sysv-rc sysvinit-utils tar tcpdump tzdata udev util-linux wpasupplicant zlib1g
114 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Need to get 38.5 MB of archives.
After this operation, 165 kB of additional disk space will be used.

You could probably build the image from scratch to start on another port. Unless there is an option in Linux to divert the port?
I don’t know Linux to well.

Regarding updating. It’s not something I have tired, so I can’t answer that I am afraid. Might be best asking on Dustcloud or Valetudo GitHub’s

1 Like

Finally got it to work, Valetudo also works nice.

Has someone given thought to modify Valetudo to make use of MQTT ? This might make integration into HA much easier, as there is already an MQTT vacuum component.

Lars

How to issue a zone clean up from HA?

I found this thread recently and I can’t root my MiRobot v1, any help here would be appreciated.

Key points:

  • My MiRobot V1 has the latest firmware 3.3.9_003416
  • I’m following the Ubuntu steps on the guide here: https://github.com/dgiese/dustcloud/wiki/VacuumRobots-manual-update-root-Howto
  • I’m using Ubuntu 16.04 LTS using VirtualBox on a Windows 10 Machine. I tried it with Ubuntu 14.04 per the instructions but there were too many issues with Python and VENV versions being too old.
  • The newest firmware available according to the links on the instructions is v11_003254
  • All the steps work fine except for the final steps to upload the firmware

When I enter this into the terminal the result is:
python dustcloud/devices/xiaomi.vacuum/firmwarebuilder/flasher.py -f output/v11_003254.pkg

Flasher for Xiaomi Vacuum
Address is not set. Trying to discover.
Connecting to device 10.0.2.2...
Sending handshake to get token
Unable to discover a device at address 10.0.2.2
Traceback (most recent call last):
File "dustcloud/devices/xiaomi.vacuum/firmwarebuilder/flasher.py", line 206, in <module>
main()
File "dustcloud/devices/xiaomi.vacuum/firmwarebuilder/flasher.py", line 148, in main
m = vacuum.do_discover()
File "/home/sebastian/dc/.venv/lib/python3.5/site-packages/miio/device.py", line 162, in do_discover
raise DeviceException("Unable to discover the device %s" % self.ip)
miio.exceptions.DeviceException: Unable to discover the device 10.0.2.2

So I added the IP address of the MiRobot (when it’s in WIFI connecting mode) and get the below result:
python dustcloud/devices/xiaomi.vacuum/firmwarebuilder/flasher.py -f output/v11_003254.pkg -a 192.168.8.1

Flasher for Xiaomi Vacuum
Connecting to device 192.168.8.1...
Sending handshake to get token
Starting local http server...
Serving http server at 10.0.2.15:38069
Sending ota command with parameters: {"mode": "normal", "file_md5": "a37aa29d89780201fae295f4f42b6f2b", "app_url": "http://10.0.2.15:38069/output/v11_003254.pkg", "proc": "dnld install", "install": "1"}
Ota started!

Firmware downloaded successfully.
Exiting.

It gets to “firmware download successfully” very quickly. I’d expect the MiRobot to tell me it will update and do it’s thing but it does nothing at this point. To get my MiRobot working again i have to use the MiHome app and get it connected back to my wifi router.

Any advice? Do you think it’s new Xiaomi firmware blocking my downgrade?