Xiaomi Cloud Vacuum Map Extractor

Nope, every color’s attribute is an integer from range 0-255 (as described in README)

1 Like

@3_14 can you help me with this error?

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 186, in update
    self._map_data = self._connector.get_map(map_name, self._colors, self._drawables, self._texts, self._sizes,
  File "/config/custom_components/xiaomi_cloud_map_extractor/xiaomi_cloud_connector.py", line 105, in get_map
    map_data = MapDataParser.parse(unzipped, colors, drawables, texts, sizes, image_config)
  File "/config/custom_components/xiaomi_cloud_map_extractor/map_data_parser.py", line 76, in parse
    MapDataParser.draw_elements(colors, drawables, texts, sizes, map_data)
  File "/config/custom_components/xiaomi_cloud_map_extractor/map_data_parser.py", line 237, in draw_elements
    ImageHandler.draw_texts(map_data.image, texts)
  File "/config/custom_components/xiaomi_cloud_map_extractor/image_handler.py", line 171, in draw_texts
    ImageHandler.__draw_text__(image, text_config[CONF_TEXT], x, y, text_config[CONF_COLOR],
  File "/config/custom_components/xiaomi_cloud_map_extractor/image_handler.py", line 217, in __draw_text__
    ImageHandler.__draw_on_new_layer__(image, draw_func)
  File "/config/custom_components/xiaomi_cloud_map_extractor/image_handler.py", line 231, in __draw_on_new_layer__
    draw_function(draw)
  File "/config/custom_components/xiaomi_cloud_map_extractor/image_handler.py", line 213, in draw_func
    font = ImageFont.truetype(font_file, font_size)
  File "/usr/local/lib/python3.8/site-packages/PIL/ImageFont.py", line 655, in truetype
    return freetype(font)
  File "/usr/local/lib/python3.8/site-packages/PIL/ImageFont.py", line 652, in freetype
    return FreeTypeFont(font, size, index, encoding, layout_engine)
  File "/usr/local/lib/python3.8/site-packages/PIL/ImageFont.py", line 169, in __init__
    if core.HAVE_RAQM:
  File "/usr/local/lib/python3.8/site-packages/PIL/ImageFont.py", line 43, in __getattr__
    raise ImportError("The _imagingft C module is not installed")
ImportError: The _imagingft C module is not installed

You can check out steps in this issue

Hi, sometimes I get this error:

Logger: homeassistant.helpers.entity
Source: custom_components/xiaomi_cloud_map_extractor/camera.py:190
First occurred: 9:53:56 (2 occurrences)
Last logged: 9:54:02

Update for camera.xiaomi_cloud_map_extractor fails
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/PIL/ImageFile.py", line 506, in _save
    fh = fp.fileno()
AttributeError: '_idat' object has no attribute 'fileno'

During handling of the above exception, another exception occurred:

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 190, in update
    self._map_data.image.data.save(img_byte_arr, format='PNG')
  File "/usr/local/lib/python3.8/site-packages/PIL/Image.py", line 2158, in save
    save_handler(self, fp, filename)
  File "/usr/local/lib/python3.8/site-packages/PIL/PngImagePlugin.py", line 1284, in _save
    ImageFile._save(im, _idat(fp, chunk), [("zip", (0, 0) + im.size, 0, rawmode)])
  File "/usr/local/lib/python3.8/site-packages/PIL/ImageFile.py", line 514, in _save
    e.setimage(im.im, b)
SystemError: tile cannot extend outside image

What vacuum do you have? Do you have trimming configured?

Xiaomi Mi Robot Vacuum 1st gen. No trim, colours or staff like that

Do you know when does this happen?

Hard to say. I have auto_update set to false and automation that updates entity manually while status is cleaning. I started cleaning and then paused and noticed that my image suddenly disappeared so I checked the logs and found this.

It’s possible that it happens when map data has not been yet provided from a vacuum (because 1st gen always redraws map). I will try to handle this case

1 Like

Hello,

I’ve got this error. Any idea?


Logger: homeassistant.helpers.entity
Source: custom_components/xiaomi_cloud_map_extractor/image_handler.py:213
First occurred: October 15, 2020, 9:42:10 PM (8331 occurrences)
Last logged: 8:56:10 PM
Update for camera.roborock fails

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 186, in update
    self._map_data = self._connector.get_map(map_name, self._colors, self._drawables, self._texts, self._sizes,
  File "/config/custom_components/xiaomi_cloud_map_extractor/xiaomi_cloud_connector.py", line 105, in get_map
    map_data = MapDataParser.parse(unzipped, colors, drawables, texts, sizes, image_config)
  File "/config/custom_components/xiaomi_cloud_map_extractor/map_data_parser.py", line 76, in parse
    MapDataParser.draw_elements(colors, drawables, texts, sizes, map_data)
  File "/config/custom_components/xiaomi_cloud_map_extractor/map_data_parser.py", line 237, in draw_elements
    ImageHandler.draw_texts(map_data.image, texts)
  File "/config/custom_components/xiaomi_cloud_map_extractor/image_handler.py", line 171, in draw_texts
    ImageHandler.__draw_text__(image, text_config[CONF_TEXT], x, y, text_config[CONF_COLOR],
  File "/config/custom_components/xiaomi_cloud_map_extractor/image_handler.py", line 217, in __draw_text__
    ImageHandler.__draw_on_new_layer__(image, draw_func)
  File "/config/custom_components/xiaomi_cloud_map_extractor/image_handler.py", line 231, in __draw_on_new_layer__
    draw_function(draw)
  File "/config/custom_components/xiaomi_cloud_map_extractor/image_handler.py", line 213, in draw_func
    font = ImageFont.truetype(font_file, font_size)
  File "/usr/local/lib/python3.8/site-packages/PIL/ImageFont.py", line 655, in truetype
    return freetype(font)
  File "/usr/local/lib/python3.8/site-packages/PIL/ImageFont.py", line 652, in freetype
    return FreeTypeFont(font, size, index, encoding, layout_engine)
  File "/usr/local/lib/python3.8/site-packages/PIL/ImageFont.py", line 169, in __init__
    if core.HAVE_RAQM:
  File "/usr/local/lib/python3.8/site-packages/PIL/ImageFont.py", line 43, in __getattr__
    raise ImportError("The _imagingft C module is not installed")
ImportError: The _imagingft C module is not installed

Cool, seems my vacuum is supported (roborock s5 max). Does this support multi floor mapping?

When you will switch floor on a vacuum (in Xiaomi app) a camera view will be updated, but calibration of a map card won’t (but soon it should be able to adjust itself).

Right now you can’t change a floor in my component. I will try to implement it, but right now it’s not a priorityj

1 Like

Mi robot v1.

Do you have any idea how restore backup map after cleaning?

Via ssh I try:

  • sudo su

  • chmod 777 /mnt/data/rockrobo

  • rm /mnt/data/rockrobo/last_map

  • cp /mnt/data/rockrobo/backup/last_map /mnt/data/rockrobo
    reboot

Works great, but I need to do this automatically after cleaning is complete fron HA.

You can probably save these instructions as a script and call it from automation using shell command.

But that triggers the display in HA. I need to run / send it to another device. Or am I wrong?

You can use ssh in a script to execute commands on a vacuum

I have the same model, the card cannot be received, error:
Logger: custom_components.xiaomi_cloud_map_extractor.camera
Source: custom_components/xiaomi_cloud_map_extractor/camera.py:182
Integration: xiaomi_cloud_map_extractor (documentation)
First occurred: 17:01:05 (65 occurrences)
Last logged: 17:23:08
Got exception while fetching the state: No response from the device

Were you able to solve this problem?

STYTJ02YM is not supported and it doesn’t seem to be supported soon.

It’s a pity ( is it because of the MiHome, vacuum cleaner or integration? With this integration, the vacuum cleaner is visible in the HA. Maybe need a telnet port?

1 Like