Coder Social home page Coder Social logo

piotrmachowski / home-assistant-custom-components-xiaomi-cloud-map-extractor Goto Github PK

View Code? Open in Web Editor NEW
1.1K 37.0 120.0 566 KB

This custom integration provides a way to present a live view of a map for Xiaomi (Roborock/Viomi/Roidmi/Dreame) vacuums without a need for rooting.

License: MIT License

Python 100.00%
home-assistant custom-component xiaomi xiaomi-smart-home vacuum robot roborock cloud map vacuum-map

home-assistant-custom-components-xiaomi-cloud-map-extractor's Introduction

HACS Default GitHub Latest Release GitHub All Releases Community Forum Ko-Fi buycoffee.to PayPal.Me Revolut.Me

Xiaomi Cloud Map Extractor

This custom integration provides a way to present a live view of a map for Xiaomi, Roborock, Viomi, Roidmi and Dreame vacuums. (Supported devices)

Installation

Using HACS (recommended)

This integration can be installed using HACS. To do it search for Xiaomi Cloud Map Extractor in Integrations section.

Manual

To install this integration manually you have to download xiaomi_cloud_map_extractor.zip and extract its contents to config/custom_components/xiaomi_cloud_map_extractor directory:

mkdir -p custom_components/xiaomi_cloud_map_extractor
cd custom_components/xiaomi_cloud_map_extractor
wget https://github.com/PiotrMachowski/Home-Assistant-custom-components-Xiaomi-Cloud-Map-Extractor/releases/latest/download/xiaomi_cloud_map_extractor.zip
unzip xiaomi_cloud_map_extractor.zip
rm xiaomi_cloud_map_extractor.zip

Configuration

After installation of the custom component, it needs to be configured in configuration.yaml file. To do so, add a camera entry to your configuration with at least a basic or recommended configuration. Vacuum token can be extracted by following this guide (ignore "not recommended" message, as it applies only to built-in Xiaomi Miio integration). You also need to enter your Xiaomi Cloud username and password. These are the credentials used for the Xiaomi Home app (not ones from Roborock app).

After installation and a reboot of your Home Assistant instance, you should get a camera entity which shows the vacuum map. This might take a few minutes after a first restart. If you have a problem with configuration validation you have to remove camera from configuration.yaml, restart Home Assistant, add camera config and restart HA again.

After modification of camera's configuration you can reload its settings in Configuration or using xiaomi_cloud_map_extractor.reload service.

Examples

Basic

camera:
  - platform: xiaomi_cloud_map_extractor
    host: !secret xiaomi_vacuum_host
    token: !secret xiaomi_vacuum_token
    username: !secret xiaomi_cloud_username
    password: !secret xiaomi_cloud_password

Recommended

camera:
  - platform: xiaomi_cloud_map_extractor
    host: !secret xiaomi_vacuum_host
    token: !secret xiaomi_vacuum_token
    username: !secret xiaomi_cloud_username
    password: !secret xiaomi_cloud_password
    draw: ['all']
    attributes:
      - calibration_points

Full

This configuration's purpose is to show all available options, do not use it unless you know what you are doing.
I know what I'm doing and I will not recklessly copy this config to my setup
camera:
  - platform: xiaomi_cloud_map_extractor
    host: !secret xiaomi_vacuum_host
    token: !secret xiaomi_vacuum_token
    username: !secret xiaomi_cloud_username
    password: !secret xiaomi_cloud_password
    country: "de"
    name: "My Vacuum Camera"
    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_ignored_obstacle: [0, 0, 0, 127]
      color_ignored_obstacle_with_photo: [0, 0, 0, 127]
      color_obstacle: [0, 0, 0, 127]
      color_obstacle_with_photo: [0, 0, 0, 127]
      color_path: [147, 194, 238]
      color_goto_path: [0, 255, 0]
      color_predicted_path: [255, 255, 0, 0]
      color_cleaned_area: [127, 127, 127, 127]
      color_zones: [0xAD, 0xD8, 0xFF, 0x8F]
      color_zones_outline: [0xAD, 0xD8, 0xFF]
      color_virtual_walls: [255, 0, 0]
      color_new_discovered_area: [64, 64, 64]
      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_room_names: [0, 0, 0]
      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
      - cleaned_area
      - goto_path
      - ignored_obstacles
      - ignored_obstacles_with_photo
      - no_go_zones
      - no_mopping_zones
      - obstacles
      - obstacles_with_photo
      - path
      - predicted_path
      - room_names
      - vacuum_position
      - virtual_walls
      - zones
    texts:
      - text: "Room 1"
        x: 25
        y: 25
        color: [125, 20, 213]
      - text: "Room 2"
        x: 25
        y: 75
        color: [125, 20, 213, 127]
        font: "FreeSans.ttf"
        font_size: 25
    map_transformation:
      scale: 2
      rotate: 180
      trim:
        top: 10
        bottom: 20
        left: 30
        right: 40
    sizes:
      charger_radius: 4
      vacuum_radius: 6.5
      path_width: 1
      obstacle_radius: 3
      ignored_obstacle_radius: 3
      obstacle_with_photo_radius: 3
      ignored_obstacle_with_photo_radius: 3
    attributes:
      - calibration_points
      - charger
      - cleaned_rooms
      - country
      - goto
      - goto_path
      - goto_predicted_path
      - image
      - is_empty
      - map_name
      - no_go_areas
      - no_mopping_areas
      - obstacles
      - ignored_obstacles
      - obstacles_with_photo
      - ignored_obstacles_with_photo
      - path
      - room_numbers
      - rooms
      - vacuum_position
      - vacuum_room
      - vacuum_room_name
      - walls
      - zones
    scan_interval:
      seconds: 10
    auto_update: true
    store_map_raw: false
    store_map_image: true
    store_map_path: "/tmp"
    force_api: xiaomi

Available configuration parameters

Key Type Required Value Description
platform string true xiaomi_cloud_map_extractor Name of a platform
host string true 192.168.0.123 IP address of a vacuum
token string true ghjhca3ykg8o2zyyj7xb5adamhgsypel Token of a vacuum
username string true [email protected] Username (email or user ID) used to connect to Xiaomi cloud (the account used in the Xiaomi Home app)
password string true aVerySecretPassword Password used to connect to Xiaomi cloud (the account used in the Xiaomi Home app)
name string false Desired name of camera entity
country string false One of: cn, de, us, ru, tw, sg, in, i2 Server used in Xiaomi cloud. Leave empty if you are not sure.
colors map false Colors configuration (see below)
room_colors map false Room colors configuration (see below)
draw list false List of elements to draw on a map (see below)
texts list false List of texts to draw on a map (see below)
map_transformation map false Parameters of map transformation (see below)
sizes map false Sizes of map's elements (see below)
attributes list false List of desired entity attributes (see below)
scan_interval interval false default: 5 seconds Interval between map updates (documentation)
auto_update boolean false default: true Activation/deactivation of automatic map updates. (see below)
store_map_raw boolean false default: false Enables storing raw map data in store_map_path directory (more info). Xiaomi map can be opened with RoboMapViewer.
store_map_image boolean false default: false Enables storing map image in store_map_path path with name map_image_<device_model>.png
store_map_path string false default: /tmp Storing map data directory
force_api string false One of: xiaomi, viomi, roidmi, dreame Forces usage of specific API.

Colors configuration

Each color is represented by a list of 3 or 4 parameters: [red, green, blue] or [red, green, blue, alpha]. Each parameter is a number from a range 0-255 and can be also provided as a HEX value: [0x12, 0xAF, 0xC5] matches #12AFC5.

Color name Description
color_charger Charger fill
color_charger_outline Charger outline
color_cleaned_area Fill of area that already has been cleaned
color_goto_path Path for goto mode
color_grey_wall Obstacles (e.g. chairs, table legs)
color_ignored_obstacle_with_photo Ignored obstacle with photo mark on a map
color_ignored_obstacle Ignored obstacle mark on a map
color_map_inside Map inside (for software without rooms support)
color_map_outside Map outside
color_map_wall_v2 Walls (for software with rooms support)
color_map_wall Walls (for software without rooms support)
color_new_discovered_area Newly discovered areas
color_no_go_zones_outline Outline of no-go zones
color_no_go_zones Fill of no-go zones
color_no_mop_zones_outline Outline of no-mopping zones
color_no_mop_zones Fill of no-mopping zones
color_obstacle_with_photo Obstacle with photo mark on a map
color_obstacle Obstacle mark on a map
color_path Path of a vacuum
color_predicted_path Predicted path to a point in goto mode
color_robo Vacuum fill
color_robo_outline Vacuum outline
color_room_names Room names (if available)
color_scan Areas not assigned to any room (for software with rooms support)
color_unknown Other areas
color_virtual_walls Virtual walls
color_zones_outline Outline of areas selected for zoned cleaning
color_zones Fill of areas selected for zoned cleaning

Room colors configuration

This section contains mapping between room numbers and colors. Each color is represented by a list of 3 or 4 parameters: [red, green, blue] or [red, green, blue, alpha]. Each parameter is a number from a range 0-255 and can be also provided as a HEX value: [0x12, 0xAF, 0xC5] matches #12AFC5.

Draw configuration

A list of features to be drawn on a map. If all features should be drawn it can be replaced with:

  draw: ["all"]

Available values:

  • charger
  • cleaned_area
  • goto_path
  • ignored_obstacles_with_photo
  • ignored_obstacles
  • no_go_zones
  • no_mopping_zones
  • obstacles_with_photo
  • obstacles
  • path
  • predicted_path
  • room_names
  • vacuum_position
  • virtual_walls
  • zones

Texts configuration

Each list entry must obey a following schema. You can get a list of available fonts by executing this command:

fc-list | grep ttf | sed "s/.*\///"| sed "s/ttf.*/ttf/"
Parameter Type Required Default value Description
text string true Text to draw on a map
x float true X position of a text (in percents)
y float true Y position of a text (in percents)
color list false black Desired color of a text, formatted like here
font string false Name of a font to use
font_size int false Size of a font

Map transformation configuration

Parameter Type Required Default value Description
scale float false 1 Scaling factor for a map.
rotate integer false 0 Angle of map rotation. Available values: [0, 90, 180, 270]
trim map false 0 Map trimming configuration. Each trimming direction is in percents: value 25 means trimming of quarter of image size in a given dimension. Available keys: [left, right, top, bottom]

Sizes configuration

Parameter Type Required Default value Description
charger_radius float false 6 Radius of a charger circle.
vacuum_radius float false 6 Radius of a vacuum semi-circle.
obstacle_radius float false 3 Radius of an obstacle circle.
ignored_obstacle_radius float false 3 Radius of an ignored obstacle circle circle.
obstacle_with_photo_radius float false 3 Radius of an obstacle with photo circle.
ignored_obstacle_with_photo_radius float false 3 Radius of an ignored obstacle with photo circle.
path_width float false 1 Width of path line.

Attributes configuration

A list of attributes that an entity should have. Available values:

  • calibration_points - Calculated calibration points for Lovelace Xiaomi Vacuum Map card.
  • charger
  • cleaned_rooms
  • country
  • goto_path
  • goto_predicted_path
  • goto
  • ignored_obstacles_with_photo
  • ignored_obstacles
  • image
  • is_empty
  • map_name
  • no_go_areas
  • no_mopping_areas
  • obstacles_with_photo
  • obstacles
  • path
  • room_numbers
  • rooms
  • vacuum_position
  • vacuum_room_name
  • vacuum_room
  • walls
  • zones

Updates

Camera image is updated every 5s by default. It can be disabled in config using auto_update property.

You can also disable and enable automatic updates using services camera.turn_off, camera.turn_on.

If automatic updates are disabled you can manually trigger update using homeassistant.update_entity service.

You can change interval of automatic updates using scan_interval setting (documentation)

If you want to disable map updates when a vacuum is not running you can use this blueprint.

Open your Home Assistant instance and show the blueprint import dialog with a specific blueprint pre-filled.

Supported devices

This integration was tested on following vacuums:

  • Xiaomi map format:
    • rockrobo.vacuum.v1 (Xiaomi Vacuum Gen 1, Mi Robot Vacuum, SDJQR01RR, SDJQR02RR)
    • roborock.vacuum.m1s (Xiaomi Mi Robot 1S)
    • roborock.vacuum.s4 (Roborock S4)
    • roborock.vacuum.s5 (Roborock S5)
    • roborock.vacuum.s5e (Roborock S5 Max)
    • rockrobo.vacuum.s6 (Roborock S6)
    • roborock.vacuum.a08 (Roborock S6 Pure)
    • roborock.vacuum.a10 (Roborock S6 MaxV)
    • roborock.vacuum.a15 (Roborock S7)
    • roborock.vacuum.a19 (Roborocka S4 Max)
    • roborock.vacuum.a27 (Roborock S7 MaxV)
  • Viomi map format:
    • viomi.vacuum.v6 (Viomi Vacuum V2 Pro, Xiaomi Mijia STYJ02YM, Mi Robot Vacuum Mop Pro)
    • viomi.vacuum.v7 (Mi Robot Vacuum-Mop Pro)
    • viomi.vacuum.v8 (Mi Robot Vacuum-Mop Pro)
    • viomi.vacuum.v13 (Viomi V3)
  • Roidmi map format:
    • roidmi.vacuum.v60 (Roidmi EVE Plus)
    • viomi.vacuum.v18 (Viomi S9)
    • zhimi.vacuum.xa1 (Lydsto R1)
  • Dreame map format:
    • dreame.vacuum.mc1808 (Xiaomi Mi Mop/Xiaomi Mijia 1C)
    • dreame.vacuum.p2008 (Dreame F9)
    • dreame.vacuum.p2009 (Dreame D9)
    • dreame.vacuum.p2028 (Dreame Z10 Pro)
    • dreame.vacuum.p2029 (Dreame L10 Pro)
    • dreame.vacuum.p2036 (Trouver LDS Cleaner)
    • dreame.vacuum.p2041o (Xiaomi Mop 2 Pro+)
    • dreame.vacuum.p2140 (Mijia Robot Vacuum-Mop 2C)
    • dreame.vacuum.p2157 (MOVA L600)
    • dreame.vacuum.p2259 (Dreame D9 Max)

Retrieving map

When store_map_raw: true is added to your config this integration will store a raw map file in /tmp directory. If you don't use Core installation (installation types) you can retrieve this file in the following way:

  • In SSH & Terminal add-on enable protected access
  • Open terminal and use the following command to copy file:
    docker exec homeassistant bash -c "mkdir -p /config/tmp/ && cp /tmp/map_* /config/tmp/"
    
  • Map file will appear in tmp folder in your config folder

Enabling debug logging

To enable debug logging add following section to your configuration.yaml

logger:
  default: info
  logs:
    custom_components.xiaomi_cloud_map_extractor: debug

Special thanks

This integration wouldn't exist without following projects:

Support

If you want to support my work with a donation you can use one of the following platforms:

Platform Payment methods Link Comment
Ko-fi
  • PayPal
  • Credit card
  • Buy Me a Coffee at ko-fi.com
  • No fees
  • Single or monthly payment
  • buycoffee.to
  • BLIK
  • Bank transfer
  • Postaw mi kawฤ™ na buycoffee.to
    PayPal
  • PayPal
  • PayPal Logo
  • No fees
  • Revolut
  • Revolut
  • Credit Card
  • Revolut
  • No fees
  • home-assistant-custom-components-xiaomi-cloud-map-extractor's People

    Contributors

    brushknight avatar cclauss avatar desout avatar drblokmeister avatar halfbakery avatar horse315 avatar jd1 avatar krystiancharubin avatar neonox31 avatar nukusinji avatar piotrmachowski avatar rospogrigio avatar seitan avatar yuvalabou avatar

    Stargazers

     avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

    Watchers

     avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

    home-assistant-custom-components-xiaomi-cloud-map-extractor's Issues

    Warning: The websocket command 'camera_thumbnail' has been deprecated

    I'm not 100% sure if this belongs to this project or to the map card, but I'm guessing from the error message that it belongs here.

    Whenever I open the lovelace tab with a map card with a vacuum camera as image source, my home-assistant.log gets logs a warning every 5 seconds (my scan_interval is set to 10sec in the camera configuration):

    2020-11-11 19:23:56 WARNING (MainThread) [homeassistant.components.camera] The websocket command 'camera_thumbnail' has been deprecated
    2020-11-11 19:24:01 WARNING (MainThread) [homeassistant.components.camera] The websocket command 'camera_thumbnail' has been deprecated
    2020-11-11 19:24:06 WARNING (MainThread) [homeassistant.components.camera] The websocket command 'camera_thumbnail' has been deprecated
    2020-11-11 19:24:11 WARNING (MainThread) [homeassistant.components.camera] The websocket command 'camera_thumbnail' has been deprecated
    2020-11-11 19:24:16 WARNING (MainThread) [homeassistant.components.camera] The websocket command 'camera_thumbnail' has been deprecated
    2020-11-11 19:24:21 WARNING (MainThread) [homeassistant.components.camera] The websocket command 'camera_thumbnail' has been deprecated
    2020-11-11 19:24:26 WARNING (MainThread) [homeassistant.components.camera] The websocket command 'camera_thumbnail' has been deprecated
    2020-11-11 19:24:31 WARNING (MainThread) [homeassistant.components.camera] The websocket command 'camera_thumbnail' has been deprecated
    2020-11-11 19:24:36 WARNING (MainThread) [homeassistant.components.camera] The websocket command 'camera_thumbnail' has been deprecated
    

    Transparency

    colors:
          color_map_outside: [0, 0, 0, 0]
    

    Transparent color gets rendered as black by the camera entity.
    Also using this in a custom card with camera_thumbnail websocket call returns a jpeg.
    Possible that HA is treating everything as jpeg behind the scenes thus breaking transparency.

    download

    Rooms looks "greyed out" compared to the app

    I do not know why, but the color of my rooms look greyed out compared to the app. Is this some setting? It looks like my whole map is covered by the "grey" color that is shown in this figure. (This image is taken from you in this repository)
    image

    [Feature Request] Negative Trim Values

    I'm a robot vacuum fanatic, and I have a home with 7 separate areas that are separated by stairs. So I currently have 5 vacuums and plan on getting more so I don't have to move any around. It would be very convenient if I could set a negative trim value in order to change the aspect ratio of the map. It would be even better if I could set a height and have the map centered in whatever height I set so that I can get my maps to match dimensions more easily on my dashboard.

    Camera Entity Attributes

    First I have to say: Amazing work so far! Exactly what I and I assume many others always wanted.

    Now, one question wrt to the entity state attributes that are created within HomeAssistant.
    Is it possible to hide things like the path from the attributes, while still being able to see the path on the picture?

    I guess this is not possible, since the camera image is actually calculated from the values, correct?

    Why I am asking: When going to my developer tools / state, I have to scroll a long time down, until this entity is passed.
    However, this is simply a thing Id like to understand and isn't really an issue per se.

    Again, Great work! Looking forward to the further developments of this addon :)

    Warning: Unable to open font (...)

    I cannot add label in Cyrillic, such as "ะšัƒั…ะฝั":

    Traceback (most recent call last):
      File "E:\HassWP\python-3.7.7\lib\site-packages\homeassistant\helpers\entity.py", line 279, in async_update_ha_state
        await self.async_device_update()
      File "E:\HassWP\python-3.7.7\lib\site-packages\homeassistant\helpers\entity.py", line 472, in async_device_update
        await self.hass.async_add_executor_job(self.update)
      File "E:\HassWP\python-3.7.7\lib\concurrent\futures\thread.py", line 57, in run
        result = self.fn(*self.args, **self.kwargs)
      File "E:\HassWP\config\custom_components\xiaomi_cloud_map_extractor\camera.py", line 186, in update
        self._image_config)
      File "E:\HassWP\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 "E:\HassWP\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 "E:\HassWP\config\custom_components\xiaomi_cloud_map_extractor\map_data_parser.py", line 237, in draw_elements
        ImageHandler.draw_texts(map_data.image, texts)
      File "E:\HassWP\config\custom_components\xiaomi_cloud_map_extractor\image_handler.py", line 171, in draw_texts
        text_config[CONF_FONT], text_config[CONF_FONT_SIZE])
      File "E:\HassWP\config\custom_components\xiaomi_cloud_map_extractor\image_handler.py", line 206, in __draw_text__
        w, h = draw.textsize(text, font)
      File "E:\HassWP\config\deps\Python37\site-packages\PIL\ImageDraw.py", line 430, in textsize
        return font.getsize(text, direction, features, language, stroke_width)
      File "E:\HassWP\config\deps\Python37\site-packages\PIL\ImageFont.py", line 128, in getsize
        return self.font.getsize(text)
    UnicodeEncodeError: 'latin-1' codec can't encode characters in position 0-6: ordinal not in range(256)
    

    Configuration failed

    Hi, I have the following error in my log.

    2020-10-26 10:15:16 ERROR (MainThread) [homeassistant.helpers.entity] Update for camera.my_robocop 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 187, in update
        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 81, in parse
        ImageHandler.draw_texts(map_data.image, texts)
      File "/config/custom_components/xiaomi_cloud_map_extractor/image_handler.py", line 189, 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 235, in __draw_text__
        ImageHandler.__draw_on_new_layer__(image, draw_func)
      File "/config/custom_components/xiaomi_cloud_map_extractor/image_handler.py", line 249, in __draw_on_new_layer__
        draw_function(draw)
      File "/config/custom_components/xiaomi_cloud_map_extractor/image_handler.py", line 231, 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
    

    I took 'de' country, because 'fr' is not available.

    Here is my configuration :

      - platform: xiaomi_cloud_map_extractor
        host: 192.168.x.x
        token: 4xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
        username: [email protected]
        password: xxxxxxxxxxxxx
        country: de
        name: My Robocop
        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
        texts:
          - text: "Room 1"
            x: 25
            y: 25
            color: [125, 20, 213]
          - text: "Room 2"
            x: 25
            y: 75
            color: [125, 20, 213, 127]
            font: "FreeSans.ttf"
            font_size: 25
        map_transformation:
          scale: 2
          rotate: 180
          trim:
            top: 10
            bottom: 20
            left: 30
            right: 40
        sizes:
          charger_radius: 4
          vacuum_radius: 6.5
        attributes:
          - calibration_points
          - charger
          - goto
          - goto_path
          - goto_predicted_path
          - image
          - is_empty
          - map_name
          - no_go_areas
          - no_mopping_areas
          - obstacles
          - path
          - room_numbers
          - rooms
          - vacuum_position
          - vacuum_room
          - walls
          - zones
        scan_interval:
          seconds: 10
        auto_update: true
    

    warning: The websocket command 'camera_thumbnail' has been deprecated

    I stuck with roborock s6 vacuum custom card (custom:xiaomi-vacuum-map-card). This card have no map.

    There is many warnings in home assistant log:

    2020-12-10 18:16:12 WARNING (MainThread) [homeassistant.components.camera] The websocket command 'camera_thumbnail' has been deprecated
    2020-12-10 18:16:13 WARNING (MainThread) [homeassistant.components.camera] The websocket command 'camera_thumbnail' has been deprecated
    
    

    I have seen problem like this here: https://community.home-assistant.io/t/xiaomi-vacuum-interactive-map-card/123901/523
    It seems like the HA update is ruining the camera.xiaomi_cloud_map_extractor.

    System Health
    Home Assistant Core Integration
    version: 0.118.4
    installation_type: Home Assistant Core
    dev: false
    hassio: false
    docker: false
    virtualenv: true
    python_version: 3.8.5
    os_name: Linux
    os_version: 5.4.0-54-generic
    arch: x86_64
    timezone: Europe/Moscow
    
    Home Assistant Cloud
    logged_in: false
    can_reach_cert_server: ok
    can_reach_cloud_auth: ok
    can_reach_cloud: ok
    
    Lovelace
    dashboards: 1
    mode: storage
    views: 5
    resources: 6
    

    Cannot see the component in Integrations

    Hi, first of all - awesome work here.
    I have HA 116.4 - I have added in HACS the repository as per readme - I then installed it and rebooted HA. After loading, when I go to Integrations, I cannot find the Xiaomi Cloud Map Extractor component.
    What I tried was to add the configuration directly in configuration.yaml - and then in HA Frontend I added the camera (camera.r2d2_camera) but it does not show anything.

    Any idea what I am doing wrong?

    camera
    homeassistant - custom components
    configuration yaml

    Thank you very much

    Map display too large

    Yesterday, the display of the map of the Roborock S6's course worked wonderfully. This morning there was a new version of the integration ... the map is still displayed, but only a small part of it. See pictures as follows.
    This is the map on my iPhone:
    IMG_6046

    and this is the map in HA:
    2020-10-01_13-56-54

    install to HassOS 4.16

    When im tryin to add repo i got this error
    20-11-13 13:33:00 ERROR (MainThread) [supervisor.utils.json] Can't read json from /data/addons/git/7fee8d21/repository.json: [Errno 2] No such file or directory: '/data/addons/git/7fee8d21/repository.json' 20-11-13 13:33:00 ERROR (MainThread) [supervisor.store] https://github.com/PiotrMachowski/Home-Assistant-custom-components-Xiaomi-Cloud-Map-Extractor is not a valid add-on repository.

    Country

    Hello. In Mi Home I use Cyprus as my country and in FloleVac I need to choose Europe in order to connect.

    From the documantation only the following counries are available: One of: ru, us, tw, sg, cn, de.

    I tried EU and CY but HA is not valitating the YAML.

    Any help?

    Error

    The card seems to be working but I keep getting the errors below. The other problem I have is that the vacuum doesnโ€™t respond to the commands like zone, go to,etc

    Logger: homeassistant.helpers.entity
    Source: custom_components/xiaomi_cloud_map_extractor/map_data_parser.py:94
    First occurred: 12:30:25 PM (1 occurrences) 
    Last logged: 12:30:25 PM
    
    Update for camera.roborock_camera 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 474, in async_device_update
        raise exc
      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
        map_data = self._connector.get_map(self._country, map_name, self._colors, self._drawables, self._texts,
      File "/config/custom_components/xiaomi_cloud_map_extractor/xiaomi_cloud_connector.py", line 117, 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 79, in parse
        map_data.vacuum_room = MapDataParser.get_current_vacuum_room(img_start, raw, map_data.vacuum_position)
      File "/config/custom_components/xiaomi_cloud_map_extractor/map_data_parser.py", line 94, in get_current_vacuum_room
        x = round(vacuum_position.x / MapDataParser.MM - image_left)
    AttributeError: 'NoneType' object has no attribute 'x'
    

    The websocket command 'camera_thumbnail' has been deprecated

    I'm getting a ton of these in my logs. I believe it's coming from the cloud map extractor.

    Logger: homeassistant.components.camera
    Source: components/camera/init.py:555
    Integration: Camera (documentation, issues)
    First occurred: 10:01:22 PM (503 occurrences)
    Last logged: 10:57:19 PM

    The websocket command 'camera_thumbnail' has been deprecated

    Question about calibrate point..

    I have integrate a camera.
    with this trim:

    map_transformation:
      scale: 1
      trim:
        top: 10
        bottom: 10
        left: 20
        right: 20
    

    But my question is, if i use xiaomi-vacuum-map-card with cam , for calibrate point ? ( i have use your flole.xlsx, but don't work)
    Becouse map is trasform with trim in home assisitant and i don't have a real point for calibration_point.
    Many thanks.
    Your work is superlative ;)

    constant spikes in CPU load

    Thank you for your component, it is very useful.
    I noticed constant spikes in CPU usage.
    After prolonged use, my orangepi pc-2 freezes and stops responding.
    I think this will be easy to fix.
    maybe you don't need to load the map all the time only on request

    without component:

    orangepi@orangepipc2:~$ top | grep python
     PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND 
     7107 root      20   0  428684 196260  31156 S   4.2 19.3   0:59.28 python3                            
     7107 root      20   0  428684 197104  31156 S   6.6 19.4   0:59.48 python3                            
     7107 root      20   0  428716 197252  31156 S   8.9 19.4   0:59.75 python3                            
     7107 root      20   0  428684 197376  31156 S   9.5 19.4   1:00.04 python3                            
     7107 root      20   0  428684 197576  31156 S   7.6 19.4   1:00.27 python3                            
     7107 root      20   0  428684 197684  31156 S   5.9 19.4   1:00.45 python3                            
     3256 root      20   0  162884  35312   7720 S   1.3  3.5   0:13.71 python3                            
     7107 root      20   0  428684 197692  31156 S   3.3 19.4   1:00.55 python3                            
     7107 root      20   0  428684 197696  31156 S   3.3 19.4   1:00.65 python3                            
     7107 root      20   0  428684 197708  31156 S   4.6 19.4   1:00.79 python3                            
     7107 root      20   0  428684 197724  31156 S   8.6 19.4   1:01.05 python3                            
     3256 root      20   0  162884  35312   7720 S   0.7  3.5   0:13.73 python3                            
     7107 root      20   0  428684 197764  31156 S   5.6 19.4   1:01.22 python3                            
     3256 root      20   0  162884  35312   7720 S   1.0  3.5   0:13.76 python3                            
     7107 root      20   0  431244 198004  31156 S   3.9 19.5   1:01.34 python3                            
     7107 root      20   0  431244 198008  31156 S   6.5 19.5   1:01.54 python3                            
     7107 root      20   0  431244 198048  31156 S   6.8 19.5   1:01.75 python3                            
     7107 root      20   0  431244 198112  31156 S   4.6 19.5   1:01.89 python3                            
     3256 root      20   0  162884  35312   7720 S   1.3  3.5   0:13.80 python3                            
     7107 root      20   0  431244 198112  31156 S   5.3 19.5   1:02.05 python3                            
     7107 root      20   0  431244 198120  31156 S   2.3 19.5   1:02.12 python3   
    
    

    with component:
    โ€”โ€”

     PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND 
    orangepi@orangepipc2:~$ top | grep python
     7672 root      20   0  493516 239732  30864 S  32.2 23.6   1:13.31 python3                            
     3256 root      20   0  162884  33576   7472 S   3.9  3.3   0:16.21 python3                            
     7672 root      20   0  500172 243620  30864 S  16.2 23.9   1:13.80 python3                            
     3256 root      20   0  162884  33576   7472 S   0.3  3.3   0:16.22 python3                            
     7672 root      20   0  500172 243756  30864 S  45.7 24.0   1:15.19 python3                            
     7672 root      20   0  500204 244216  30864 S  15.5 24.0   1:15.66 python3                            
     7672 root      20   0  504268 246416  30864 S  41.4 24.2   1:16.92 python3                            
     7672 root      20   0  510924 250896  30864 S  44.7 24.7   1:18.28 python3                            
     3256 root      20   0  162884  33500   7472 S   1.3  3.3   0:16.26 python3                            
     7672 root      20   0  510924 251896  30864 S  10.2 24.8   1:18.59 python3                            
     7672 root      20   0  515020 254080  30864 S  47.4 25.0   1:20.03 python3                            
     7672 root      20   0  515020 254136  30864 S  14.5 25.0   1:20.47 python3                            
     7672 root      20   0  515020 254284  30864 S  38.0 25.0   1:21.62 python3                            
     7672 root      20   0  524236 259328  30864 S  46.4 25.5   1:23.03 python3                            
     3256 root      20   0  162884  33220   7408 S   2.6  3.3   0:16.34 python3                            
     7672 root      20   0  524236 259348  30864 S   5.3 25.5   1:23.19 python3                            
     7672 root      20   0  528332 261308  30864 S  41.7 25.7   1:24.47 python3                            
     7672 root      20   0  528364 261864  30896 S  27.7 25.7   1:25.31 python3                            
     7672 root      20   0  531916 265392  30864 S  25.7 26.1   1:26.09 python3                            
     7672 root      20   0  531948 265656  30864 S  42.3 26.1   1:27.39 python3                            
     3256 root      20   0  162884  33208   7408 S   1.3  3.3   0:16.38 python3

    Support for vacuums that use new API

    Hello,
    Any chance of getting support for STYJ02YM vacuum? (Xiaomi Vaccum Mop Pro/some Viomi models)

    I currently use this custom integration to integrate the vacuum in HA and it works getting the state, starting etc, but would love to have the map in HA and also to use the map card so I ca do room cleaning:
    https://github.com/nqkdev/home-assistant-vacuum-styj02ym

    From what I have read, Python Miio already supports commands to this vacuum but the HA guys don't want to have two different implementations for Xiaomi Vacuums in core. Not sure how the map comes from the cloud for this tho...

    I tried using this with the same settings as the custom integration but I just get:
    Got exception while fetching the state: No response from the device.
    Got error when receiving: timed out

    Support Xiaomi Vacuum S1

    Hello,

    I know that device is currently unsuported, but
    I tried to add my Xiaomi Vacuum S1, unfortunately it does not work.

    Would be great if that would work!

    My config:

      - platform: xiaomi_cloud_map_extractor
        host:  192.168.50.253
        token: 3167425273704c475575xxxxxxxx
        username: '[email protected]'
        password: 'xxxxxxx'
        country: "cn"
    
    

    Errors from debug log:

    Update for camera.xiaomi_cloud_map_extractor fails
    Traceback (most recent call last):
      File "/srv/homeassistant/lib/python3.7/site-packages/miio/miioprotocol.py", line 192, in send
        data, addr = s.recvfrom(1024)
    socket.timeout: timed out
    
    During handling of the above exception, another exception occurred:
    
    Traceback (most recent call last):
      File "/srv/homeassistant/lib/python3.7/site-packages/miio/miioprotocol.py", line 192, in send
        data, addr = s.recvfrom(1024)
    socket.timeout: timed out
    
    During handling of the above exception, another exception occurred:
    
    Traceback (most recent call last):
      File "/srv/homeassistant/lib/python3.7/site-packages/miio/miioprotocol.py", line 192, in send
        data, addr = s.recvfrom(1024)
    socket.timeout: timed out
    
    During handling of the above exception, another exception occurred:
    
    Traceback (most recent call last):
      File "/srv/homeassistant/lib/python3.7/site-packages/miio/miioprotocol.py", line 192, in send
        data, addr = s.recvfrom(1024)
    socket.timeout: timed out
    
    The above exception was the direct cause of the following exception:
    
    Traceback (most recent call last):
      File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/helpers/entity.py", line 278, in async_update_ha_state
        await self.async_device_update()
      File "/srv/homeassistant/lib/python3.7/site-packages/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.7/concurrent/futures/thread.py", line 57, in run
        result = self.fn(*self.args, **self.kwargs)
      File "/home/homeassistant/.homeassistant/custom_components/xiaomi_cloud_map_extractor/camera.py", line 144, in update
        map_name = self._vacuum.map()[0]
      File "/srv/homeassistant/lib/python3.7/site-packages/miio/vacuum.py", line 240, in map
        return self.send("get_map_v1")
      File "/srv/homeassistant/lib/python3.7/site-packages/miio/device.py", line 147, in send
        command, parameters, retry_count, extra_parameters=extra_parameters
      File "/srv/homeassistant/lib/python3.7/site-packages/miio/miioprotocol.py", line 236, in send
        extra_parameters=extra_parameters,
      File "/srv/homeassistant/lib/python3.7/site-packages/miio/miioprotocol.py", line 236, in send
        extra_parameters=extra_parameters,
      File "/srv/homeassistant/lib/python3.7/site-packages/miio/miioprotocol.py", line 236, in send
        extra_parameters=extra_parameters,
      File "/srv/homeassistant/lib/python3.7/site-packages/miio/miioprotocol.py", line 240, in send
        raise DeviceException("No response from the device") from ex
    miio.exceptions.DeviceException: No response from the device
    

    Map not updating after a while

    I can see lot of:

    Updating xiaomi_cloud_map_extractor camera took longer than the scheduled update interval 0:00:05

    (it's not problem with 5 seconds intervals - same happens when I set 30 seconds)

    After HA restart, when vacuum is cleaning, then map is updating properly (even with 5 seconds intervals). But when cleaning ends and vacuum gets back to the dock, Updating xiaomi_cloud_map_extractor camera took longer than the scheduled update interval 0:00:05 will be back. Next when I start new cleaning, map will be not updated - never. After next HA restart - it will work till next cleaning end...

    Configuration Issue with Xiaomi Vacuum 1S

    Hi!

    I'm trying to use the custom integration with a Xiaomi Vacuum 1S. I've installed it with HACS and my configuration in config.yaml is as follows:

    camera:
       - platform: xiaomi_cloud_map_extractor
         host: !secret xiaomi_vacuum_host
         token: !secret xiaomi_vacuum_token
         username: !secret xiaomi_cloud_username
         password: !secret xiaomi_cloud_password
         country: "cn"
    

    And the information in secrets is as:

    xiaomi_vacuum_host: 192.168.1.41
    xiaomi_vacuum_token: "xxxxxxxxxxxxxxxxx"
    xiaomi_cloud_username: "[email protected]"
    xiaomi_cloud_password: "xxx"
    

    However, the integration is not correctly loaded and the error in Home Assistant Log is not very clarifying. I assume that it is a problem with my configuration but I can not find the error...

    I used your script to obtain the token and the vacuum is correctly integrated into Home Assistant with the xiaomi_miio Official integration so I assume those values are correct.

    Any help would be appreciated.

    Thanks!

    [Feature] Background image

    Hi!
    Thanks for your component, love it!
    I have a small feature request.
    Would it be possible to add an background image to the map?
    Reason for this is i have drawn my house layout instead of the map, and would love to see the position of the vacuum real time.

    Flooding the core logs

    I have tons of these in my HA_Core with the latest update

    {1: (100, 104, 226, 206), 2: (192, 105, 252, 217), 3: (255, 107, 322, 164), 4: (253, 166, 322, 204)}
    {1: (100, 104, 226, 206), 2: (192, 105, 252, 217), 3: (255, 107, 322, 164), 4: (253, 166, 322, 204)}
    {1: (100, 104, 226, 206), 2: (192, 105, 252, 217), 3: (255, 107, 322, 164), 4: (253, 166, 322, 204)}
    {1: (100, 104, 226, 206), 2: (192, 105, 252, 217), 3: (255, 107, 322, 164), 4: (253, 166, 322, 204)}
    {1: (100, 104, 226, 206), 2: (192, 105, 252, 217), 3: (255, 107, 322, 164), 4: (253, 166, 322, 204)}
    {1: (100, 104, 226, 206), 2: (192, 105, 252, 217), 3: (255, 107, 322, 164), 4: (253, 166, 322, 204)}
    {1: (100, 104, 226, 206), 2: (192, 105, 252, 217), 3: (255, 107, 322, 164), 4: (253, 166, 322, 204)}
    {1: (100, 104, 226, 206), 2: (192, 105, 252, 217), 3: (255, 107, 322, 164), 4: (253, 166, 322, 204)}
    {1: (100, 104, 226, 206), 2: (192, 105, 252, 217), 3: (255, 107, 322, 164), 4: (253, 166, 322, 204)}
    {1: (100, 104, 226, 206), 2: (192, 105, 252, 217), 3: (255, 107, 322, 164), 4: (253, 166, 322, 204)}
    {1: (100, 104, 226, 206), 2: (192, 105, 252, 217), 3: (255, 107, 322, 164), 4: (253, 166, 322, 204)}
    {1: (100, 104, 226, 206), 2: (192, 105, 252, 217), 3: (255, 107, 322, 164), 4: (253, 166, 322, 204)}
    {1: (100, 104, 226, 206), 2: (192, 105, 252, 217), 3: (255, 107, 322, 164), 4: (253, 166, 322, 204)}
    {1: (100, 104, 226, 206), 2: (192, 105, 252, 217), 3: (255, 107, 322, 164), 4: (253, 166, 322, 204)}
    {1: (100, 104, 226, 206), 2: (192, 105, 252, 217), 3: (255, 107, 322, 164), 4: (253, 166, 322, 204)}
    {1: (100, 104, 226, 206), 2: (192, 105, 252, 217), 3: (255, 107, 322, 164), 4: (253, 166, 322, 204)}
    {1: (100, 104, 226, 206), 2: (192, 105, 252, 217), 3: (255, 107, 322, 164), 4: (253, 166, 322, 204)}
    {1: (100, 104, 226, 206), 2: (192, 105, 252, 217), 3: (255, 107, 322, 164), 4: (253, 166, 322, 204)}```
    

    Help with integration

    Hey!
    I'm cant get the cloud map extractor with the live map to work. As i'm using custom cards and all that the first time - it is really hard for newbies to know what to do and what to configure where.

    What i've did is to install both the cloud map extractor and the Lovelace Xiaomi Vacuum Map card using HACS. Now how do i configure this step by step? I've managed to extract my roborock s5 max's token and ip from the iOS backup.

    I've added this to my configuration.yaml:

    vacuum:
      - platform: xiaomi_miio
        host: !secret 10.0.0.105 
        token: !secret my_token
    
    camera:
      - platform: xiaomi_cloud_map_extractor
        host: !secret 10.0.0.105
        token: !secret my_token
        username: !secret my_mi_username
        password: !secret my_mi_password
        draw: ['all']
        attributes:
          - calibration_points    
    

    and i created a ui-lovelace.yaml and added this:

    resources:
      - url: /local/custom_lovelace/xiaomi_vacuum_map_card/xiaomi-vacuum-map-card.js
        type: module
    

    How do i get a working card now? What do i need to add to make it function?
    Thank you so much! <3

    Zones are misplaced on trimming the map

    camera:
      - platform: xiaomi_cloud_map_extractor
        host: 192.168.1.#$
        token: @#$#$!#$
        username: !@#$!@#$@!
        password: #!@$!@#$!
        country: "us"
        name: "Roborock S5 Max Camera"
        draw: ['all']
        attributes:
          - calibration_points
        map_transformation:
          trim:
            top: 15
            bottom: 15
            left: 15
            right: 15
        colors:
          color_robo: [255, 255, 255]
          color_charger: [214, 186, 122]
          color_map_outside: [255, 255, 255]
          color_path: [255, 255, 255]
          color_goto_path: [250, 241, 117]
        room_colors:
          16: [245, 176, 65]
          17: [88, 214, 141]
          18: [217, 136, 128]
          19: [214, 178, 209]
          20: [72, 201, 176]
          21: [52, 152, 219]
          22: [133, 193, 233]
          24: [240, 178, 122]
          25: [205, 97, 85]
    

    i just realized this isn't really a xiaomi-cloud-map-extractor issue but rather a lovelace-xiaomi-vacuum-map-card issue but its kind of related to both working together so creating the issue here since the fix can actually be done in this integration - i got the zones from the room definitions reported by this integration as an attribute. maybe it could offset the zones by the trimming percentages and report them, so one could copy paste that into the lovelace-xiaomi-vacuum-map-card definition.

    when the map is trimmed in xiaomi-cloud-map-extractor (like above) then the room coordinates reported do not honor the trims. so in case you copy them over to a frontend integration like lovelace-xiaomi-vacuum-map-card as your defined zones, they will appear misplaced like this:

    04694648-7BC9-48BB-9848-778CCE01B09C

    Error: Unable to log in, check credentials

    I keep having the error: keyError: 'ssecurity'

    What did I try to fix

    • use my account id instead of e-mailadres. Select cn or de server.
    • Create a new account factory reset my vacuum and add it to the new account. Mainland setting china so for the config country cn and try the new mailadres and account id.

    Keep having this error, on my iPhone I can loggin with email I also have a dev android phone also possible to login with mail or id.

    Someone suggestions?

    ImportError: The _imagingft C module is not installed

    Hi,

    I get this in the log when i added more than the "basic" config.
    Running HA in docker. Any tips?

    `2020-10-25 14:12:22 ERROR (MainThread) [homeassistant.helpers.entity] Update for camera.s5max 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 187, in update 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 81, in parse ImageHandler.draw_texts(map_data.image, texts)
    File "/config/custom_components/xiaomi_cloud_map_extractor/image_handler.py", line 189, 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 235, in __draw_text__ ImageHandler.__draw_on_new_layer__(image, draw_func)
    File "/config/custom_components/xiaomi_cloud_map_extractor/image_handler.py", line 249, in __draw_on_new_layer__ draw_function(draw)
    File "/config/custom_components/xiaomi_cloud_map_extractor/image_handler.py", line 231, 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`
    

    KeyError: 'ssecurity'`

    help please

    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 149, in update self._logged = self._connector.login() File "/config/custom_components/xiaomi_cloud_map_extractor/xiaomi_cloud_connector.py", line 88, in login return self.login_step_1() and self.login_step_2() and self.login_step_3() File "/config/custom_components/xiaomi_cloud_map_extractor/xiaomi_cloud_connector.py", line 65, in login_step_2 self._ssecurity = json_resp["ssecurity"] KeyError: 'ssecurity'

    Update for camera fails

    I have also issues with updating the map. Log file says:

    Logger: homeassistant.helpers.entity
    Source: custom_components/xiaomi_cloud_map_extractor/xiaomi_cloud_connector.py:110
    First occurred: 8:23:19 (3 occurrences)
    Last logged: 8:23:29
    
    Update for camera.herbies_karte 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 474, in async_device_update
        raise exc
      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
        map_data = self._connector.get_map(self._country, map_name, self._colors, self._drawables, self._texts,
      File "/config/custom_components/xiaomi_cloud_map_extractor/xiaomi_cloud_connector.py", line 113, in get_map
        response = self.get_raw_map_data(country, map_name)
      File "/config/custom_components/xiaomi_cloud_map_extractor/xiaomi_cloud_connector.py", line 124, in get_raw_map_data
        map_url = self.get_map_url(country, map_name)
      File "/config/custom_components/xiaomi_cloud_map_extractor/xiaomi_cloud_connector.py", line 110, in get_map_url
        return api_response["result"]["url"]
    TypeError: 'NoneType' object is not subscriptable
    

    No idea what to do or if this is a real problem.

    Exceptions in log when Vacuum is in an error state

    My vacuum (Roborock S5) was running and I picked it up off the ground. This resulted in the following errors in the Home Assistant log until I put it down again and resumed the cleaning.

    2020-12-05 08:24:35 ERROR (MainThread) [homeassistant.helpers.entity] Update for camera.sofie 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 474, in async_device_update
        raise exc
      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
        map_data = self._connector.get_map(self._country, map_name, self._colors, self._drawables, self._texts,
      File "/config/custom_components/xiaomi_cloud_map_extractor/xiaomi_cloud_connector.py", line 113, in get_map
        response = self.get_raw_map_data(country, map_name)
      File "/config/custom_components/xiaomi_cloud_map_extractor/xiaomi_cloud_connector.py", line 124, in get_raw_map_data
        map_url = self.get_map_url(country, map_name)
      File "/config/custom_components/xiaomi_cloud_map_extractor/xiaomi_cloud_connector.py", line 110, in get_map_url
        return api_response["result"]["url"]
    TypeError: 'NoneType' object is not subscriptable
    

    Help with installation

    Hi everybody

    I've just tried to install the "xiaomi vacumm card" (manually and through HACS) with the integration with the "cloud map extractor".

    From the card i can start and stop my vacuum.
    The issue is about the rendering. The card shows only half of my flat
    image

    I've tried to change "the scale" in the "cloud map extractor configs" configs, i've rebooted the system, cleared the cache, removed and reinstall the component.. but i can't fix this issue.
    i changed the rotation and it works, so i think is only a "size problem"

    Can anyone help me?

    here the card config:

    type: 'custom:xiaomi-vacuum-map-card'
    entity: vacuum.xiaomi_vacuum_cleaner
    camera_calibration: true
    map_camera: camera.xiaomi_cloud_map_extractor
    debug: false

    and here the config file

    vacuum:
      - platform: xiaomi_miio
        host: !secret vacuum_ip 
        token: !secret vacuum_token
        
    camera:
      - platform: xiaomi_cloud_map_extractor
        host: !secret vacuum_ip
        token: !secret vacuum_token
        username: !secret vacuum_cloud_username
        password: !secret vacuum_cloud_password
        country: "cn"
        name: "xiaomi_cloud_map_extractor"
        draw:
          - charger
          - path
          - goto_path
          - predicted_path
          - no_go_zones
          - no_mopping_zones
          - vacuum_position
          - virtual_walls
          - zones
        map_transformation:
          scale: 1
          rotate: 180
          trim:
            top: 10
            bottom: 20
            left: 30
            right: 40
        sizes:
          charger_radius: 4
          vacuum_radius: 6.5
        attributes:
          - calibration_points
          - charger
          - goto
          - goto_path
          - goto_predicted_path
          - image
          - is_empty
          - map_name
          - no_go_areas
          - no_mopping_areas
          - obstacles
          - path
          - room_numbers
          - rooms
          - vacuum_position
          - vacuum_room
          - walls
          - zones
        scan_interval:
          seconds: 10
        auto_update: true

    Thanks

    s6 maxv

    i don't know if this is the righe place

    you can add "s6 maxv" to your compatibility list.

    i'm using it and works fine.

    Please add ability to place random text on the map

    It would be nice to allow render random text on the map to place some labels for the rooms. Something like:

    labels:
      - name: Kitchen
        x: 120
        y: 50
        size: 10
      - name: Living room
        x: 240
        y: 110
        size: 10
    

    Or probably it's possible to get room names from Mi Cloud and render them as it does in Mi Home.

    Add "fr" country

    "Tout est dans le titre", as we say in France.

    If it is possible to add this country, this component would be fantastic.

    Thanks in advance.

    Error

    Platform error camera.xiaomi_cloud_map_extractor - Requirements for xiaomi_cloud_map_extractor not found: ['python-secrets'].

    Calibration points and rooms

    Hey, I'm just testing a new add-on. Generally it works very well although I am not sure about the accuracy of the calibration. Below are a few screens:

    Addon attributes:
    Screenshot 2020-10-24 at 16 00 24
    My settings:
    Screenshot 2020-10-24 at 15 59 45
    Screenshot 2020-10-24 at 15 59 53
    View:
    Screenshot 2020-10-24 at 16 03 38

    Looks like the rooms have been moved outside the center of the map. Is it because of scaling and triming the map?

    Platform not found

    Hi,

    Thanks a lot for your development, I'm already using the map card with cleared zone so thank you.
    I would like to add the live map in the previous card without rooting the vacuum, so I'm trying to use this map extractor.

    I have added in my configuration.yaml the configuration:

    camera:
      - platform: xiaomi_cloud_map_extractor
        host: 192.168.1.83
        token: 643162304c785a4b65585a30684b4c4c
        username: mymihome@email
        password: mypasswordmihome
        country: "de"
    

    I have tried to copy past the Github folder "xiaomi_cloud_map_extractor" everywhere but it is not found.
    Have tried these differents path:

    /home/homeassistant/.homeassistant/custom_components/xiaomi_cloud_map_extractor
    /home/homeassistant/.homeassistant/www/custom_components/xiaomi_cloud_map_extractor

    in the folder I have copied these files:

    camera.py
    const.py
    image_handler.py
    manifest.json
    map_data_parser.py
    xiaomi_cloud_connector.py

    All files and directory are with homeassistant owner.

    What am I missing please ?
    Thanks for your help

    Configuration Validator "check configuration" never finishes

    I've added this custom integration via HACS and can see it is installed as an integration in the HACS interface. I then added the config to my configuration.yaml file under an existing camera entry I already had.

    -   platform: xiaomi_cloud_map_extractor
        host: !secret xiaomi_robot_host
        token: !secret xiaomi_cloud_robot_token
        username: !secret xiaomi_cloud_username
        password: !secret xiaomi_cloud_password
        country: cn
        draw: ['all']
        attributes:
          - calibration_points
          - vacuum_position
          - charger

    When I go to the Configuration Validator section in HA and click the "check configuration" button, I see the spinning icon but it never finishes (just spins forever). If I comment out the changes above, the checker returns "check configuration". If I change one of the entries for my secrets file, I get the expected Configuration invalid response (e.g. Secret xiaomi_cloud_passwordX not defined). I'm also not able to trigger a restart, as a similar thing happens - restart never gets triggered.

    I've confirmed my login details and token using the Xiaomi-cloud-tokens-extractor tool. Which is why I added the country attribute above, as I noticed my robot vacuum listed for multiple country servers, so went with cn attributes.

    Can't see anything in my HA logs about this integration or about failed config test.

    'camera_thumbnail' has been deprecated

    Hello

    All the time, since installed getting warning in Log :

    2020-12-03 11:20:30 WARNING (MainThread) [homeassistant.components.camera] The websocket command 'camera_thumbnail' has been deprecated
    2020-12-03 11:20:35 WARNING (MainThread) [homeassistant.components.camera] The websocket command 'camera_thumbnail' has been deprecated
    2020-12-03 11:20:40 WARNING (MainThread) [homeassistant.components.camera] The websocket command 'camera_thumbnail' has been deprecated
    2020-12-03 11:20:45 WARNING (MainThread) [homeassistant.components.camera] The websocket command 'camera_thumbnail' has been deprecated
    2020-12-03 11:20:50 WARNING (MainThread) [homeassistant.components.camera] The websocket command 'camera_thumbnail' has been deprecated

    Can you advice please ?

    Recommend Projects

    • React photo React

      A declarative, efficient, and flexible JavaScript library for building user interfaces.

    • Vue.js photo Vue.js

      ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

    • Typescript photo Typescript

      TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

    • TensorFlow photo TensorFlow

      An Open Source Machine Learning Framework for Everyone

    • Django photo Django

      The Web framework for perfectionists with deadlines.

    • D3 photo D3

      Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

    Recommend Topics

    • javascript

      JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

    • web

      Some thing interesting about web. New door for the world.

    • server

      A server is a program made to process requests and deliver data to clients.

    • Machine learning

      Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

    • Game

      Some thing interesting about game, make everyone happy.

    Recommend Org

    • Facebook photo Facebook

      We are working to build community through open source technology. NB: members must have two-factor auth.

    • Microsoft photo Microsoft

      Open source projects and samples from Microsoft.

    • Google photo Google

      Google โค๏ธ Open Source for everyone.

    • D3 photo D3

      Data-Driven Documents codes.