Home-Assistant-custom-components-Xiaomi-Cloud-Map-Extractor: Failed to retrieve map from vacuum

Checklist

  • I have updated the integration to the latest version available
  • I have checked if the problem is already reported

The problem

First of all thanks for this great integration! I’ve been using it for more than a year now without any issues. However for the last couple of days I don’t receive any maps anymore. I only see “Failed to retrieve map from vacuum” for both my vacuums (S5 &S7). I’ve checked the logs but nothing’s showing. I only have the custom integration error about that it’s not tested by Home Assistant. But after that, nothing at all. Always difficult when something breaks when you didn’t change anything…

Any idea’s?

What version of an integration has described problem?

v2.2.0

What was the last working version of an integration?

v2.2.0

What vacuum model do you have problems with?

S5 and S7

What version of Home Assistant do you use?

2023.3.6

What type of installation are you running?

Home Assistant Core

Camera’s configuration

camera:
  - platform: xiaomi_cloud_map_extractor
    name: Roborock S5
    host: 192.168.1.30
    token: xxx
    username: xxx
    password: xxx
    draw: ['all']
    attributes:
      - calibration_points
      - room_numbers
      - rooms
    colors:
      color_map_inside: [21, 21, 21]
      color_map_outside: [28, 28, 28]
      color_map_wall: [142, 142, 142]
      color_map_wall_v2: [142, 142, 142]
      color_grey_wall: [142, 142, 142]
      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: [255, 255, 255]
      color_goto_path: [0, 255, 0]
      color_predicted_path: [255, 255, 0, 0]
      color_cleaned_area: [127, 127, 127, 127]
      color_zones: [0, 0, 0, 0]
      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: [21, 21, 21]
      2: [21, 21, 21]
      3: [21, 21, 21]
      4: [21, 21, 21]
      6: [21, 21, 21]
      7: [21, 21, 21]
      5: [21, 21, 21]
    map_transformation:
      rotate: 270
      scale: 3
      trim:
        top: 0
        bottom: 0
        left: 0
        right: 0
  - platform: xiaomi_cloud_map_extractor
    name: Roborock S7
    host: 192.168.1.181
    token: xxx
    username: xxx
    password: xxx
    draw: ['all']
    attributes:
      - calibration_points
      - room_numbers
      - rooms
    colors:
      color_map_inside: [21, 21, 21]
      color_map_outside: [28, 28, 28]
      color_map_wall: [142, 142, 142]
      color_map_wall_v2: [142, 142, 142]
      color_grey_wall: [142, 142, 142]
      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: [255, 255, 255]
      color_goto_path: [0, 255, 0]
      color_predicted_path: [255, 255, 0, 0]
      color_cleaned_area: [127, 127, 127, 127]
      color_zones: [0, 0, 0, 0]
      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: [21, 21, 21]
      16: [21, 21, 21]
      20: [21, 21, 21]
      17: [21, 21, 21]
      18: [21, 21, 21]
      19: [21, 21, 21]
      21: [21, 21, 21]
    map_transformation:
      rotate: 270
      scale: 3
      trim:
        top: 0
        bottom: 0
        left: 0
        right: 0

Errors shown in the HA logs (if applicable)

sadly, none :(

Additional information

No response

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Reactions: 3
  • Comments: 386 (92 by maintainers)

Most upvoted comments

I have created a new blueprint that should handle all possible cases. It is not mentioned in a documentation at this moment, I will add it there later.

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

You just have to copy and paste the link Open your Home Assistant instance and show the blueprint import dialog with a specific blueprint pre-filled.

Seems my automations I uploaded here were removed ?

So I will place them again as I think this is a better solution than the blueprint to disable the camera completely. One automation will enable or disable the second automation if the roborock is either docker or not. The second automation will update the camera service every 15 seconds.

You will need to set the scan_interval in the configuration.yaml to a high value like 14400 ( 4 hours )


alias: start/stop xiaomi fast scan interval
description: ""
trigger:
  - platform: state
    entity_id:
      - vacuum.roborock_s6
condition: []
action:
  - if:
      - condition: state
        entity_id: vacuum.roborock_s6
        state: docked
    then:
      - service: automation.turn_off
        data: {}
        target:
          entity_id: automation.update_xiaomi_map_extractor
    else:
      - service: automation.turn_on
        data: {}
        target:
          entity_id: automation.update_xiaomi_map_extractor
mode: single


alias: update xiaomi map extractor
description: ""
trigger:
  - platform: time_pattern
    seconds: "15"
condition: []
action:
  - service: homeassistant.update_entity
    data: {}
    target:
      entity_id: camera.xiaomi_cloud_map_extractor
initial_state: "off"
mode: restart

Also small note @PiotrMachowski , I see that You are selecting @rospogrigio instead of me 😉 when replying to my stuff. Ik names somewhat similar haha.

Whooops… Sorry! Your replies were right beside each other and I got them mixed up one time. I have updated my comment 😄

No need to apologize @PiotrMachowski!! Actually it was a stroke of luck for me, since I discovered this entire thread only because you erroneously mentioned me instead of him, at some point!!! I would have never imagined that the HA integration could be responsible for the disappearance of the map, since it was happening also on the xiaomi app so I was convinced it was a problem on the app, I was about to deep reset the robot… LOL I find this so hilarious… sometimes mistakes help!! 🤣🤣

@MathijsG neat idea, I think I’ll add it to the blueprint as well

I have just added it to the update_map_extractor blueprint as well.

I finally got “unbanned” from the servers and I can see the map. I applied Piotr’s blueprint to never update when docked and update 10s when working. I also made a sensor for the status like this:

- platform: template
  sensors:
    vacuum_cleaner_status_sensor:
    friendly_name: "VacuumStatus"
    value_template: "{{ states.vacuum.f_robo.attributes.status }}"

then I made a sepparate automation to do a final update after arriving at dock (until Piotr has time to update the BP), something like:

alias: BP Piotr Helper after docking
description: >-
  Blabla
trigger:
  - platform: state
    entity_id:
      - sensor.vacuum_cleaner_status_sensor
    from: Returning home
    to: Charging
    for:
      hours: 0
      minutes: 0
      seconds: 5
action:
  - service: xiaomi_cloud_map_extractor.reload
    data: {}
mode: single

so now it refreshes the map one last time after arriving at the dock (5 secs delay after docking) in order to get the “docked” robot on map. Seems to work fine, let’s see how it works in time.

@cosmos1978 one suggestion regarding your automation: at this moment it refreshes the camera every minute, to make it work every 15s you have to use seconds: "/15"

You have to use this config

camera:
  - platform: xiaomi_cloud_map_extractor
    host: XXXXX
    token: XXXXX
    username: XXXXX
    password: XXXX
    draw: ["all"]
    attributes:
      - calibration_points
    auto_update: false

Do not modify blueprint, just create an automation using it. https://www.home-assistant.io/docs/automation/using_blueprints/

And it’s back 😦

Since 2 days, the map doesn’t load on the xiaomi app. A restart saturday did the trick, but I lost it again sunday evening, and even a reboot doesn’t bring the map back on xiaomi’s app.

(I used an intermediate system with 2 automations from @PiotrMachowski :

  • start/stop xiaomi fast scan interval -> start the second automation if status is “not docked”
  • update xiaomi map extractor -> only retrieve map is vacuum is running)

Does anyone has the same issue on xiaomi side ?

Hahaha sorry too funny, don’t need to update the replies, You updated it wrong anyway ,is np, just leave it like that.

@ravensergio you can completely disable updating (using auto_update: false) and use this blueprint to update the map instead.

I did not asked that question. Also, Your replies that should’ve been to me are :

@rospogrigio yes, I plan to add it to the blueprint, but I didn’t have time recently @rospogrigio you were first, but I was halfway through writing it, so I have posted it anyway 😉

As I said, is np, is just funny. I’ll stop now thanks for everything ( and also making me laugh) . I updated the BP to the latest, now I also have the last refresh Toggle (after 10seconds), this is awesome.

image

My mistake, sorry, did not understand that I had to make an automation, just loaded the new Blueprint into HA and thought that was it.

Well, this is a quite essential functionality of blueprints 😄

@PiotrMachowski OK. I will do it but in the late evening.

Having the same issue. Now my official Xiaomi home app on my Android phone won’t even load the map anymore.

@MathijsG it must’ve been a coincidence. Map coloring is done completely on the integration side.

any idea on how to reboot it without doing a factory reset?

You have to hold the power button for a few seconds

Ok, I have rebooted my vacuum and it started to work. Maybe it will work with your vacuums as well.

Not only integration crashes, map won’t load anymore when using this Home Assistant extension on your vacuum.

Xiaomi app just shows “Map Loading” after using this extension, and you must unpair and change device to different region and back to restore map functionality.

Thanks for the tip, in the meantime I think I’ve found a workaround 😄

  1. For xiaomi_cloud_map_extractor increase the scan_interval in configuration.yaml: scan_interval: 14400
  2. Switch from Xiaomi Miio to https://github.com/al-one/hass-xiaomi-miot
  3. For the Vacvuum set this as it is told in https://github.com/al-one/hass-xiaomi-miot/issues/1027:
interval_seconds: '60'
auto_cloud: true
  1. Set following automation to only update the map when the robot is running: https://community.home-assistant.io/t/roborock-map-camera-is-not-shown-every-24h/573404/9 mine is here:
alias: Start/Stop Xiaomi Fast Scan Interval
description: ""
trigger:
  - platform: state
    entity_id:
      - vacuum.rockrobo_v1_a259_robot_cleaner
    attribute: vacuum.status
    to: null
condition: []
action:
  - if:
      - condition: or
        conditions:
          - condition: state
            entity_id: vacuum.rockrobo_v1_a259_robot_cleaner
            state: Charging
            attribute: vacuum.status_desc
          - condition: state
            entity_id: vacuum.rockrobo_v1_a259_robot_cleaner
            state: Idle
            attribute: vacuum.status_desc
    then:
      - delay:
          hours: 0
          minutes: 0
          seconds: 10
          milliseconds: 0
      - service: automation.turn_off
        data: {}
        target:
          entity_id: automation.update_xiaomi_map_extractor
    else:
      - service: automation.turn_on
        data: {}
        target:
          entity_id: automation.update_xiaomi_map_extractor
mode: single

and

alias: Update Xiaomi Map Extractor
description: ""
trigger:
  - platform: time_pattern
    seconds: "10"
condition: []
action:
  - service: homeassistant.update_entity
    data: {}
    target:
      entity_id: camera.xiaomi_cloud_map_extractor
initial_state: "off"
mode: single

This is all cool and all, but i’d rather have something integrated into the solution itself that does not require us to create unmanaged processes that might or might not keep working into the future.

Soon 😉 (potentially)

That would be brilliant!

@Merwenus I have started working on rewriting this integration, but I’m not 100% certain it will work, Xiaomi seems to be quite restrictive

@witooski If you remove debug node and inject node you can condense it even further 😃

@Loeana thx a lot for the invitation and the node red automation! Yesterday, I experimented with it and developed my version, which I have uploaded to your GitHub project. Please have a look if you are interested 😃 In a nutshell, both our approaches are very similar, but yours is much more condensed, which, for me, is a plus.

@witooski Sure, I sent you an invitation to github project. BTW. it worked, after about 24h my ban was lifted and now I can see the map, finally!

@PiotrMachowski would you be so kind and double check if the ‘Turn off when docked’ option really turns of map refreshing? I’ve been using this option within the blueprint automation and every couple of days (can’t say exactly how many) I get the error 'Failed to retrive map from vacuum".

For example, I have set up the automation today again with that exact option selected. Map was working perfectly fine until now, when it became unavailable again 😦

My setup: Home Assistant 2023.7 running in docker container Xiaomi Cloud Map Extractor - v2.2.0 Xiaomi Vacuum Map card - v2.2.2 Update Map Extractor camera Blueprint - the latest available with 5 modes

Please let me know if you need any further information.

Well maybe little longer story than required.

I visited Xiaomi Store in Czechia, to replace protection glass on my phone for free and buy new side brush for my roborock.

I was told that roborock has separated from xiomi and support on official app and also their HomeAssistant integration is not guaranteed.

While i was trying to repair map not showing in xiaomi app, I tried to reset the whole vacuum multiple times (both just wifi reset and factory reset). After few tries it started working again flawlessly in the official xiaomi and also roborock app. But not on HA map. After some serearch in configs i figured out camera token also changed. So i was forced to update the token using python script included on github.

Now its working fine (little bit questionable with too much zoom but thats fine).

I have created a new blueprint that should handle all possible cases. It is not mentioned in a documentation at this moment, I will add it there later.

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

Thank you very much the Blueprint, I have configured it, and the map is working good, i don’t get “map error” message two days already. I have configured the blueprint with “Two intervals - automation controls camera updates both when vacuum is cleaning or docked. To use with auto_update: false in camera’s configuration.”

@MrBlank111 Ok, for some reason template trigger wasn’t working. I have rewritten the logic and updated the blueprint again. It should work this time.

@loadamasta try using the blueprint in browser mod mode

Using blueprint with “turn off when docked”, some hours after show map, “failed to retrieve map …” again 😕

I tried several approaches, the only one that works is to deactivate home assistant integration. Then the map will not disappear in xiaomi home app.

I have s5 and have no other option to integrate it in home assistant, so I just use xiaomi app.

If you have newer versions, I would use the roborock integration, need to delete it then from xiaomi app before adding it to roborock.

Using blueprint with “turn off when docked”, some hours after show map, “failed to retrieve map …” again 😕

Let me know if it fixes, I would hate to remove the integration, but would still be better than having no maps most of the time that I want to use the robot

Okay… After overnight sleep, I see my map in mihome app. Polling xiaomi server was the issue I think.

Nope - it was pretty much stock from when I initially installed Cloud-Map-Extractor:

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

@Flightkick I understood what you meant. Think of the Blueprint adding additional features. I didn’t have to change any of my previous Map Extractor config.

If I understand the blueprint correctly, it toggles on/off, so will it will maybe work if I run the blueprint on/off every day in automation?

You can achieve it using “two intervals” mode, but you have to add auto_update: false in camera’s config.

The issue still exists for me even on a roborock s5 (not max) with latest automation rules on 30s update when cleaning and 3600s when docked. I have enabled debug and i get this :


I am out of ideas, this used to work but now even with the automations in place... it works like 15% of the time :(

How can i help in debuging this more ?

Thanks

I don’t have any issues, BUT i disabled the updates when docked , so my settings are like this:

image

Notice I also toggled ON the “Update once after docking”. I don’t really think that we need map updates AFTER we are docked, so I leave it off. I had no issues since i did this setting. Make sure You also have the latest blueprint from here( delete your old BP/automation if You dont have the latest and reinstall), and made a new automation based on that. I did these steps in 4 May, and I just checked, my map is still working np in MI App etc. Try maybe like this and see how it goes for You.

Hello, so i did what you sugested, i can confirm this looks like it did it, no more issues.

All i had to do after i added automation from blueprint was to turn of the vacuum and turn on, no server change and it looks like it’s working ever since.

Thanks

change

OK but does it change the language as well?

Nope

@rospogrigio (I hope I have tagged a correct person this time 😄) you can use browser mod to check current URL for every browser/app. If any of them matches a view that contains the map card -> refresh the map every 5s

So I need to make an automation for this? But how do I make it work for “any” browser? Do I need to edit the automation every time a new browser is registered? It looks a bit clunky, also because you need to check the URL and the visibility sensor combined, I think I’ll start by using your blueprint for now…

@rospogrigio here’s a template for you (you can use it in a template binary sensor):

{{ states.sensor | selectattr('attributes.pathSegments', 'defined') | selectattr('attributes.type', '==', 'browser_mod') | selectattr('state', '==', '/lovelace/test') | list | count > 0 }}

You have to enable “Auto-register” in settings of browser mod make it work automatically with all browsers.

Just a tip.

If anybody have problems getting the maps in phone or pad after disabeling in ha, a server switch could hjelp. Mine has been gone for over a week in apps, no reboot or anything helped. I changed the region from Norway to Singapore, and suddenly the maps came back.

@ravensergio you were first, but I was halfway through writing it, so I have posted it anyway 😉

You have to remove the blueprint and install it again (feature request to make blueprints upgradable).

The reason to update camera after the vacuum is docked is to make sure Map Extractor has downloaded the map with completed cleaning.

It would be nice to just change the refresh frequency when the robot is docked instead of stopping the acquisition completely.

Doesn’t the Blueprint Piotr posted here do just that? You have 4 variations for refreshing the vacuum as I saw:

image

I just tried this map integration that uses the API of the newer roborock app. This one seems to use another backend then the xiaomi one. https://github.com/humbertogontijo/homeassistant-roborock Work perfect for me with the map card from piotr. Only thing missing is the map customization like rotation and colors.

Ideally you want to have a last update after having docked, otherwise the map could give the image that the vacuum is still undocked. I might add something manually later.

Unfortunately, my map broke at 3am this morning with 20s / 1800s settings. ☹️

Broken here as well

Unfortunatelly I haven’t time to make more investigation during the weekend (unexpected 😉 ) and I can see that some solutions are made 😃 Just to enlarge the knowledge I can say that basing on my logs I found out that in my case “reset” is made at 3:20 and block is coming at ca. 18:00 (17:56, 18:01, 18:02 - checked on three following days). I set up scan_interaval to 30s so it makes about 1700-1800 API questions for a day but as it was written here some of You have made bigger intervals and the problem appeared as well so maybe it is kind of more complicated algorithm. I will check new blueprint as well. BTW: similar problem seems to be with Xiaomi cameras. Somebody has found out the solution?

Did that, no luck. I guess I’ll have to be more patient.

@AseKarlsson @witooski you are correct, I have adjusted it (this is what you get when you code at 4AM…)


@oksakoor you have to disable camera’s automatic updates first with auto_update: false in its config. Also it might take some time to recover on Xiaomi Cloud.

Next release preferable without need of external solutions and can your own BluePrint be included in the code as well?

I think I would prefer to keep variable intervals as a blueprint to keep it easy to modify without changing the code.

About other changes, I’d try to merge all pull requests, fix some issues, improve stability, extract map parsing to a dedicated packages. Maybe someday I’ll make a config flow. That is my general plan, but nothing is guaranteed 😉

@AseKarlsson wait until next day.

@cosmos1978 solution seems to do the job. Thank you !

@cosmos1978 they were not removed, you just posted them in a completely different thread.

I will adjust the blueprint to support different scan intervals later today/tomorrow

What is the best way to get map working again after a failure. First time I just restarted the vaccuum, but now I cannot get it working again (not even on phone)?

Wait until the limit is reset (https://blog.axway.com/learning-center/apis/basics/api-rate-limits) it doesn’t have anything to do with the vacuum cleaner locally, everything is related to the Roborock API now enforcing rate limits on their cloud services.

@totow93 I’ve modified slightly the blueprint of @PiotrMachowski to make scan interval of 5s during work and 10m when docked (&others). It seems to work OK. The map is now always visible (earlier with camera_off the map was missing) and during the work the progress is visible as well in real time. No problems for last 30h. Earlier the problem was occurring just in 2-3h. (vacuum time in my device is about 1:40)

@totow93 refreshing only when vacuum is running is already possible (more info here), the harder thing is to update only when the card is visible

I think a reboot is not really useful, as it’s the cloud api connection that rejects us, not something wrong in the vacuum itself.

I moved to 30 with that setting. It seems to work for now, lets see how long it will continue to work.