Xiaomi Cloud Vacuum Map Extractor

Very good project that i hope will solve the problem of the coordinates for my s5max.
I try it with the map card and everythings goes well apart a “little” detail: the home-assistant_v2.db rises rapidly from 400 mb to 2 tb. I have the vacuum in the recorder because i need to know when the vacuum start (because of an automation).
I am pretty sure that the growth of the DB is due to the integration. I deleted the DB twice and every time it rises again over 2 tb, once i eliminated this integration and deleted again the DB it stops to grown.

You just have to use calibration_points and correct calibration will appear in attributes (documentation)

You can limit attributes to only the ones you need. It should solve your problem (documentation)

Thanks heaps for this…Massive thumbs up for you sir

1 Like

Thanks again, I really like this custom component. A coffee is on the way :wink:
I wanted to ask once if there is an easy way to get the room numbers? So that I can set them correctly under “room_colors”.

I want to set the same colors as in the Xiaomi app.

App:

Lovelace:

Many thanks again

1 Like

I have seen that it usually starts at 16, you can check with this service:

      - data:
          entity_id: vacuum.roborock_s5_max
          command: app_segment_clean
          params:
            - 16
        service: vacuum.send_command

you can use the service to send the vacuum cleaner to a room. If while you see the app my home you can see how the corresponding room is marked. If no room is marked, the number not correspond to any, and with a bit of try and failure you will get all numbers.

1 Like

Great integration.
I test it with my STYJ02YM but it doesn’t work, maybe you can have a look at the error:

Update for camera.xiaomi_cloud_map_extractor fails
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/miio/miioprotocol.py", line 177, in send
    "send (timeout %s): %s",
socket.timeout: timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/miio/miioprotocol.py", line 177, in send
    "send (timeout %s): %s",
socket.timeout: timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/miio/miioprotocol.py", line 177, in send
    "send (timeout %s): %s",
socket.timeout: timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/miio/miioprotocol.py", line 177, in send
    "send (timeout %s): %s",
socket.timeout: timed out

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 278, in async_update_ha_state
    await self.async_device_update()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 471, in async_device_update
    await self.hass.async_add_executor_job(self.update)  # type: ignore
  File "/usr/local/lib/python3.8/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/xiaomi_cloud_map_extractor/camera.py", line 144, in update
    map_name = self._vacuum.map()[0]
  File "/usr/local/lib/python3.8/site-packages/miio/vacuum.py", line 222, in map
    def log_upload_status(self):
  File "/usr/local/lib/python3.8/site-packages/miio/device.py", line 124, in send
    def send(
  File "/usr/local/lib/python3.8/site-packages/miio/miioprotocol.py", line 215, in send
    try:
  File "/usr/local/lib/python3.8/site-packages/miio/miioprotocol.py", line 215, in send
    try:
  File "/usr/local/lib/python3.8/site-packages/miio/miioprotocol.py", line 215, in send
    try:
  File "/usr/local/lib/python3.8/site-packages/miio/miioprotocol.py", line 218, in send
    return payload
miio.exceptions.DeviceException: No response from the device

Thank you!

I will try to add support for your vacuum, but I will need some help, as I don’t have it :wink:

1 Like

Yes no problem, feel free to ask :slight_smile:

hmm, updated to 116.0 , is it possible that the lovelace card is broken? i cant draw zones anymore ?

edit: wrong topic i will post in the lovelace topic :slight_smile:

But it’s annoying to check all the room in that way. Doesn’t it? You can use the ‘miio’ library to check the room’s IDs

1 Like

Hello @sermayoral. Exactly! I also find it cumbersome to find out the room number this way.
What exactly do you mean by ‘miio’ Libary and how do I have to use it to get the room numbers?
Thanks in advance

I think I will be able to add a list of room numbers as a attribute…

2 Likes

That would be awesome!

You can get the room ID by using:
miio protocol call <roboip> get_room_mapping

I added calibration_points command but i can’t find the coordinates

Can you show your config?

#mappa robot
camera:
  - platform: xiaomi_cloud_map_extractor
    host: !secret walle_ip
    token: !secret walle_token
    username: !secret mi_user
    password: !secret mi_pwd
    country: "de"
    name: "Mappa Wall-E"
    colors:
      color_map_inside: [32, 115, 185]
      color_map_outside: [19, 87, 148]
      color_map_wall: [100, 196, 254]
      color_map_wall_v2: [93, 109, 126]
      color_grey_wall: [93, 109, 126]
      color_path: [147, 194, 238]
      color_goto_path: [0, 255, 0]
      color_predicted_path: [255, 255, 0, 0]
      color_zones: [0xAD, 0xD8, 0xFF, 0x8F]
      color_zones_outline: [0xAD, 0xD8, 0xFF]
      color_virtual_walls: [255, 0, 0]
      color_no_go_zones: [255, 33, 55, 127]
      color_no_go_zones_outline: [255, 0, 0]
      color_no_mop_zones: [163, 130, 211, 127]
      color_no_mop_zones_outline: [163, 130, 211]
      color_charger: [0x66, 0xfe, 0xda, 0x7f]
      color_robo: [75, 235, 149]
      color_unknown: [0, 0, 0]
      color_scan: [0xDF, 0xDF, 0xDF]
    room_colors:
      1: [240, 178, 122]
      2: [133, 193, 233]
      3: [217, 136, 128]
      4: [52, 152, 219]
      5: [205, 97, 85]
      6: [243, 156, 18]
      7: [88, 214, 141]
      8: [245, 176, 65]
      9: [252, 212, 81]
      10: [72, 201, 176]
      11: [84, 153, 199]
      12: [133, 193, 233]
      13: [245, 176, 65]
      14: [82, 190, 128]
      15: [72, 201, 176]
      16: [165, 105, 18]
    draw:
      - charger
      - path
      - goto_path
      - predicted_path
      - no_go_zones
      - no_mopping_zones
      - vacuum_position
      - virtual_walls
      - zones
    attributes:
      - charger
      - goto
      - goto_path
      - goto_predicted_path
      - image
      - no_go_areas
      - no_mopping_areas
      - obstacles
      - path
      - vacuum_position
      - walls
      - zones 
      - calibration_points

Config seems to be correct, calibration points should be available in camera’s attributes.

New feature:

I have added returning room numbers in a dedicated attribute: room_numbers