Home

Awesome

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

<!-- piotrmachowski_support_badges_end -->

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)

<img src="https://raw.githubusercontent.com/PiotrMachowski/Home-Assistant-custom-components-Xiaomi-Cloud-Map-Extractor/master/images/map_no_rooms.png" width=48%> <img src="https://raw.githubusercontent.com/PiotrMachowski/Home-Assistant-custom-components-Xiaomi-Cloud-Map-Extractor/master/images/map_rooms.png" width=48%>

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.
<details> <summary>I know what I'm doing and I will not recklessly copy this config to my setup</summary>
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
</details>

Available configuration parameters

KeyTypeRequiredValueDescription
platformstringtruexiaomi_cloud_map_extractorName of a platform
hoststringtrue192.168.0.123IP address of a vacuum
tokenstringtrueghjhca3ykg8o2zyyj7xb5adamhgsypelToken of a vacuum
usernamestringtruexiaomi.account@gmail.comUsername (email or user ID) used to connect to Xiaomi cloud (the account used in the Xiaomi Home app)
passwordstringtrueaVerySecretPasswordPassword used to connect to Xiaomi cloud (the account used in the Xiaomi Home app)
namestringfalseDesired name of camera entity
countrystringfalseOne of: cn, de, us, ru, tw, sg, in, i2Server used in Xiaomi cloud. Leave empty if you are not sure.
colorsmapfalseColors configuration (see below)
room_colorsmapfalseRoom colors configuration (see below)
drawlistfalseList of elements to draw on a map (see below)
textslistfalseList of texts to draw on a map (see below)
map_transformationmapfalseParameters of map transformation (see below)
sizesmapfalseSizes of map's elements (see below)
attributeslistfalseList of desired entity attributes (see below)
scan_intervalintervalfalsedefault: 5 secondsInterval between map updates (documentation)
auto_updatebooleanfalsedefault: trueActivation/deactivation of automatic map updates. (see below)
store_map_rawbooleanfalsedefault: falseEnables storing raw map data in store_map_path directory (more info). Xiaomi map can be opened with RoboMapViewer.
store_map_imagebooleanfalsedefault: falseEnables storing map image in store_map_path path with name map_image_<device_model>.png
store_map_pathstringfalsedefault: /tmpStoring map data directory
force_apistringfalseOne of: xiaomi, viomi, roidmi, dreameForces 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.

<img src="https://raw.githubusercontent.com/PiotrMachowski/Home-Assistant-custom-components-Xiaomi-Cloud-Map-Extractor/master/images/map_no_rooms_custom_colors.png" width=50%>
Color nameDescription
color_chargerCharger fill
color_charger_outlineCharger outline
color_cleaned_areaFill of area that already has been cleaned
color_goto_pathPath for goto mode
color_grey_wallObstacles (e.g. chairs, table legs)
color_ignored_obstacle_with_photoIgnored obstacle with photo mark on a map
color_ignored_obstacleIgnored obstacle mark on a map
color_map_insideMap inside (for software without rooms support)
color_map_outsideMap outside
color_map_wall_v2Walls (for software with rooms support)
color_map_wallWalls (for software without rooms support)
color_new_discovered_areaNewly discovered areas
color_no_go_zones_outlineOutline of no-go zones
color_no_go_zonesFill of no-go zones
color_no_mop_zones_outlineOutline of no-mopping zones
color_no_mop_zonesFill of no-mopping zones
color_obstacle_with_photoObstacle with photo mark on a map
color_obstacleObstacle mark on a map
color_pathPath of a vacuum
color_predicted_pathPredicted path to a point in goto mode
color_roboVacuum fill
color_robo_outlineVacuum outline
color_room_namesRoom names (if available)
color_scanAreas not assigned to any room (for software with rooms support)
color_unknownOther areas
color_virtual_wallsVirtual walls
color_zones_outlineOutline of areas selected for zoned cleaning
color_zonesFill 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:

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/"
ParameterTypeRequiredDefault valueDescription
textstringtrueText to draw on a map
xfloattrueX position of a text (in percents)
yfloattrueY position of a text (in percents)
colorlistfalseblackDesired color of a text, formatted like here
fontstringfalseName of a font to use
font_sizeintfalseSize of a font

Map transformation configuration

ParameterTypeRequiredDefault valueDescription
scalefloatfalse1Scaling factor for a map.
rotateintegerfalse0Angle of map rotation. Available values: [0, 90, 180, 270]
trimmapfalse0Map 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

ParameterTypeRequiredDefault valueDescription
charger_radiusfloatfalse6Radius of a charger circle.
vacuum_radiusfloatfalse6Radius of a vacuum semi-circle.
obstacle_radiusfloatfalse3Radius of an obstacle circle.
ignored_obstacle_radiusfloatfalse3Radius of an ignored obstacle circle circle.
obstacle_with_photo_radiusfloatfalse3Radius of an obstacle with photo circle.
ignored_obstacle_with_photo_radiusfloatfalse3Radius of an ignored obstacle with photo circle.
path_widthfloatfalse1Width of path line.

Attributes configuration

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

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:

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:

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:

<!-- piotrmachowski_support_links_start -->

Support

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

<table> <tr> <th>Platform</th> <th>Payment methods</th> <th>Link</th> <th>Comment</th> </tr> <tr> <td>Ko-fi</td> <td> <li>PayPal</li> <li>Credit card</li> </td> <td> <a href='https://ko-fi.com/piotrmachowski' target='_blank'><img height='35px' src='https://az743702.vo.msecnd.net/cdn/kofi3.png?v=0' border='0' alt='Buy Me a Coffee at ko-fi.com' /></a> </td> <td> <li>No fees</li> <li>Single or monthly payment</li> </td> </tr> <tr> <td>buycoffee.to</td> <td> <li>BLIK</li> <li>Bank transfer</li> </td> <td> <a href="https://buycoffee.to/piotrmachowski" target="_blank"><img src="https://buycoffee.to/btn/buycoffeeto-btn-primary.svg" height="35px" alt="Postaw mi kawÄ™ na buycoffee.to"></a> </td> <td></td> </tr> <tr> <td>PayPal</td> <td> <li>PayPal</li> </td> <td> <a href="https://paypal.me/PiMachowski" target="_blank"><img src="https://www.paypalobjects.com/webstatic/mktg/logo/pp_cc_mark_37x23.jpg" border="0" alt="PayPal Logo" height="35px" style="height: auto !important;width: auto !important;"></a> </td> <td> <li>No fees</li> </td> </tr> <tr> <td>Revolut</td> <td> <li>Revolut</li> <li>Credit Card</li> </td> <td> <a href="https://revolut.me/314ma" target="_blank"><img src="https://www.revolut.com/favicon/android-chrome-192x192.png" height="35px" alt="Revolut"></a> </td> <td> <li>No fees</li> </td> </tr> </table> <!-- piotrmachowski_support_links_end -->