homeassistant-roborock icon indicating copy to clipboard operation
homeassistant-roborock copied to clipboard

Save map in disk

Open mihatsu opened this issue 1 year ago • 3 comments

Hi,

In the original Xiaomi Cloud Map Extractor is a feature to save map in the disk. I see that it is removed from this and it is not in code anymore. This feature is useful if want to overlay Roborock elements in custom floorplan. This feature has been requested to Xiaomi Cloud Map Extractor and Xiaomi Vacuum Map Card it has not implemented. However, if the map is saved, it is possible to change non-wanted elements to transparent and overlay (using python script) this image over the floorplan and then use this new image as map source. Of course this is not ideal solution and would be better implement this in code when map is created. But this python script solution is doable without any coding skills.

Thx Mika

mihatsu avatar Jun 22 '23 12:06 mihatsu

I was able to do this with some minor modifications to camera.py and image_handler.py. It needs still some cleaning and implementation is poor because I have zero coding experience but I'll try to polish it.

IMG_96C9516E1570-1

mihatsu avatar Jun 27 '23 00:06 mihatsu

Could you explain how you got the map to look like that?

arne182 avatar Jul 27 '23 14:07 arne182

Well, I modified original python code so as far as i know this is not possible without opening the hood and do changes there. But my process was this:

  1. I Installed the homeassistant-roborock integarition and made all needed settings, including drop the map and scale it bigger.
  2. I modified /config/custom_components/roborock/common/image_handler.py file and set all elements transparent what i dont want to see in my new map. (0, 0, 0, 0) hide unneed element like backround etc. Dont hide walls yet!
  3. I opened enity camera.roborock_s7_maxv_map which is the map and save it made hard drive. This should be transparent image which has just elements you want in your custom map (plus walls), like route, device etc what you did not hide in point 3.
  4. I opened this map in Photoshop (you can use gimp as well) and then i imported my floorplan image over it and matched them using walls (this is a poor man calibration), when you are done, delete the roborock layer and save floorplan map. So, you should have your floor plan in same size than roborock map and they should match if you overlay.
  5. I modified /config/custom_components/roborock/common/image_handler.py again and removed the walls.
  6. Next you have to modify /config/custom_components/roborock/camera.py and implement there a code which overlay roborock map over your same size floorplan map. I used Image.blend command. I did this very end of the code and I think roborock map is called as map_data in the code.

unfortunately, I don't have the code what I did in point 6 because newer version of integration replaced my modified code and i have not had a time to finalize it. Second reason is that I have zero programming skills so i have probably implemented this the way which is not the way how pro would have done it. But I try this again if the original integration owner does not implement this. Pretty sure this 5min job him and for me 5 days job... :)

mihatsu avatar Jul 27 '23 23:07 mihatsu