Xiaomi Vacuum Map Viewer (to find coordinates for zone cleaning)

Tags: #<Tag:0x00007f616e0f0448>

To find map coordinates for your Xiaomi robot you can try the offline viewer which is included in the OH source.

I made it now also as standalone, you can get it here
http://verpaalen.com/openhab2/RoboMapviewer2.5.7.jar
2020-08-14 new version (incl calc and zone selection): http://verpaalen.com/openhab2/roboMapViewer2.5.7.zip

2020-09-22 new version (fix command format & obstacles): http://verpaalen.com/openhab2/roboMapViewer2.5.9-1.zip

you run it like this java -jar RoboMapviewer2.5.9-1.jar (assuming java is in your path, and the viewer is in the current dir, otherwise add the paths appropriately)

Clicking in the graph should give a coordinate in the text window, dragging mouse will give the zone

:exclamation:Note: The rrmap files are saved by the binding in the userdata/miio folder.
Note that the rrmap files are only saved when debug logging is enabled ( log:set debug org.openhab.binding.miio )

4 Likes

Hi,
I’m getting:

Exception in thread “AWT-EventQueue-0” java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory
Caused by: java.lang.ClassNotFoundException: org.slf4j.LoggerFactory

When I’m trying to open map

:frowning: I thought I nailed it wrt to the dependencies. It is rather unfamiliar territory for me to make standalone jars
I’ll test it as well on another PC to see if I can replicate the issue

if you unzip the jar file, I think you can also run it with below command (the missing class is packed inside the jar). This is how I tested it before packing it into the jar

java.exe -cp "./lib/slf4j-api-1.7.21.jar;./lib/slf4j-simple-1.7.21.jar;.;./*.jar;./lib/org.osgi.core-6.0.0.jar" org.openhab.binding.miio.internal.RoboMapViewer

I could replicate the issue…Do not have a good final solution yet, but got it to run with the file provided:

What did work for me is to indeed unzip a copy of the jar (make the copy, rename the file from .jar to .zip) and extract the lib folder. With the lib folder in the same folder as the jar file, I was able to execute it with the earlier command java -jar RoboMapviewer2.5.7.jar

As the libs are there, it should not give this class not found error on the logging

Great! It works fine now

I have another question how to use the coordinates
I have “draw” a zone and got this results:
Click @ point (404,0,234,0) => Coordinates: [X=314,0, Y=261,0]
Click @ point (399,0,416,0) => Coordinates: [X=315,7, Y=200,3]
Click @ point (277,0,417,0) => Coordinates: [X=356,3, Y=200,0]
Click @ point (275,0,234,0) => Coordinates: [X=357,0, Y=261,0]

Inside my rule I used to have this:
sendCommand(RoborockCommand,“app_zoned_clean[[22491,30568,23991,32668,1]]”)

How do I “convert” the information from the java program to my rule?

This is the puzzle still to solve… I was hoping these match, but seems not so based on your example.

are the clicks the same coordinates as the zone clean coordinates? (as it allmost seems factor 100)

maybe this helps:
During the conversion to coordinates in the map drawing logic, early in the processing, I divide by 50 to come from the robot provided values to the coordinates in the app.

Maybe the to get to the zone coordinates, it is the reverse.
For the Y coordinates, it is calculated as value from robo / 50 - top
for the X it is doing something like (imgWidth + left) - value from robo / 50

note these top, left width etc values can be seen in the viewer

note I found this:
https://hackernoon.com/how-i-set-up-room-cleaning-automation-with-google-home-home-assistant-and-xiaomi-vacuum-cleaner-9149e0267e6d
Have not tried it out if that works, but if that works, maybe can enhance the viewer in such a way

I used to use an app called flolevac to get the coordinates.
But after 3.5.7 firmware the app stop working.
You can see the discussion here:


I assume the flolevac app use the same method as the link you posted above to get the coordinates for the app_zoned_clean command.

I preffered to use the app_zoned_clean command instead of the app_segment_clean command.
So if you manage to implement overlaid grids to draw out the x and y-axis in your java program I’m happy to test it :slight_smile:

Maybe you can use something from here: https://github.com/PiotrMachowski/lovelace-xiaomi-vacuum-map-card

I toyed a bit with moving the vacuum (command: app_goto_target[x,y]) which gives the exact coordinate of the goto pos in the viewer, hence helps finding the formula.

Seems for me the calculation from viewer coordinate to goto coordinate: ( offset + Click Coordinate) * 50

X offset= left+width, Y offset = top

I included the calculation in the viewer for easy usage
new version (incl calc): http://verpaalen.com/openhab2/roboMapViewer2.5.7.zip

1 Like

I just tried the new version. But it seems like the offset is wrong (at least for me)

I think the app is somehow calculating the offset from the image details,

For the Y coordinates, it is calculated as (Y coord + top ) * 50
for the X it is doing something like (imgWidth + left - X coord ) * 50

If you can send an example of your map file (the rrmap) and the coordinates you used, it can help finding out the logic.

Fixed the calulation to be universal. You can find the download link in the first post.

What’s new in this version:

  • Shows coordinates according the vacuum instead of # of pixels
  • Mouse-over gives coordinates in status bar
  • Mouse wheel will zoom in/out
  • Can give filename in the command line o start with specific file
  • Clicking in the map gives goto command
  • Click & drag will draw rectange and provides the zone clean command to use
  • Images and lib are in zip for easy execution

1 Like

Great work! One suggestion for next version it would be nice to be able to copy the text inside the bottom window :grinning:

You can copy the text by selecting it with mouse and ctrl-C

Hi
Just downloaded the new version and it might be different when open the java program on OSX.
But I can’t copy the text by using Command+C or right click.

Update: Control+C seems to works fine.
But inside OSX the normal shortcut for copy&paste is:
command+C & command+V

1 Like

Thanks Marcel, I very appreciate your work on this. Your new version works for me on Mac and Windows.
However, I missed one important step - can someone let me know from where and how I can get the rrmap file that need to be opened by the viewer?

Hint…

1 Like

I can find the map and also open it. The zone is marked and the coordinates are also displayed in the app.

When I start the zone command (“app_zoned_clean[28150,28000,2970029100,1]”) the vacuum cleaner (S6) also starts immediately and reports zone cleaning. So far everything is fine!

Unfortunately the coordinates seem to be wrong. The whole ground floor is cleaned.

Where could the error be? (Openhab 2.5.8-1)

You are missing a comma.