PiotrMachowski / Home-Assistant-custom-components-Xiaomi-Cloud-Map-Extractor

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.
MIT License
1.13k stars 122 forks source link

Failed to retrieve map from vacuum #422

Closed kimme1024 closed 1 year ago

kimme1024 commented 1 year ago

Checklist

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

PiotrMachowski commented 1 year ago

Does the map work in Xiaomi Home?

kimme1024 commented 1 year ago

Does the map work in Xiaomi Home?

Hmm, indeed, no... Didn't check it as I assumed it would be HA-related... Any idea how that might happen? (and how to fix it)

PiotrMachowski commented 1 year ago

I have the same problem, I have no idea what happened. It might be a problem on the Xiaomi Cloud side - vacuum doesn't return map id because it can't upload it to the cloud. I hope it's not a ban...

Do your vacuums have the latest firmware versions? Has any new update become available in the last days?

kimme1024 commented 1 year ago

The S5 hasn't been updated in a while as it's the one upstairs that doesn't get used that much. The S7 should be on the latest firmware but that update has been done about a month ago. For the S7 I can't even click the 3 dots for more info so I can't check for updates...

edit The S5 is on the latest firmware

PiotrMachowski commented 1 year ago

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

kimme1024 commented 1 year ago

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

Thanks! I'll try it with the one downstairs, and tomorrow with the other one.

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

PiotrMachowski commented 1 year ago

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

You have to hold the power button for a few seconds

kimme1024 commented 1 year ago

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

You have to hold the power button for a few seconds

Great! It worked for the S7. I'll try the S5 tomorrow. I assume it'll work as well... Thanks for the support!

MathijsG commented 1 year ago

I seem to have the same problem periodically as well. It seemed to start when i customized the whole image with different colors. Don't know if these modifications are done after the retrieval from Xiaomi, or before. When it's not working i don't see an image of my room in the Xiaomi app as well.

It will try to load the map indefinitely in the Xiaomi app.

After several days or something sometimes it is working all of a sudden again. Will investigate if this still breaks occasionally without all the custom color things.

PiotrMachowski commented 1 year ago

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

MathijsG commented 1 year ago

By the way Roborock S50 / S5 Non-max edition

All the other cloud features still work, can even start it, etc, just without visuals.

kimme1024 commented 1 year ago

Weird over here. Restart fixed the s7 on Friday but when I checked again on Saturday, the s5 was available and the s7 wasn’t. Today both are unavailable again.

PiotrMachowski commented 1 year ago

I have closed this issue because it doesn't seem to be connected to the code of the integration itself. You might try to increase scan_interval and check if it helps

MechanicKitten commented 1 year ago

Also noticed this over the last few days, rebooting the vacuum hasn't helped. I did notice that the map would randomly come back and then disappear into a broken state again. Both in Home Assistant and the Xiaomi Home app. Certainly seems like something on their side

klu16 commented 1 year ago

Just here to report that I am experiencing issues since a few days too. But it looks like there could be something wrong on the Xiaomi (cloud) side. Yesterday I had "Failed to retrieve a map", on the other hand today I see "Failed to login" message on the lovelace. Also randomly I see it works fine.

sergicm commented 1 year ago

The same thing has been happening to me for about a week, I don't know if this log has anything to do with it:

2023-04-10 02:44:35.912 DEBUG (SyncWorker_5) [custom_components.xiaomi_cloud_map_extractor.camera] Retrieving map name from device 2023-04-10 02:44:36.036 DEBUG (SyncWorker_5) [custom_components.xiaomi_cloud_map_extractor.camera] Map name retry 2023-04-10 02:44:36.036 DEBUG (SyncWorker_5) [custom_components.xiaomi_cloud_map_extractor.camera] Unable to retrieve map, reasons: Logged in - True, map name - retry, device retrieved - True

MathijsG commented 1 year ago

Just here to report that I am experiencing issues since a few days too. But it looks like there could be something wrong on the Xiaomi (cloud) side. Yesterday I had "Failed to retrieve a map", on the other hand today I see "Failed to login" message on the lovelace. Also randomly I see it works fine.

Having the same, also seeing Failed to login now, instead of the earlier error.

klu16 commented 1 year ago

Having the same, also seeing Failed to login now, instead of the earlier error.

Now I also see "Two factor auth required (see logs)" message...

MathijsG commented 1 year ago

Yeah me too. I relogged in (in the logs you see the link you need to open), and now the map works again. Hope it will stay that way.

bgoncal commented 1 year ago

Rebooting the robot worked but today it happened again

MathijsG commented 1 year ago

Same here. What I find interesting is that my neighbour with the exact same S50 has zero problems, and another friend with his S7 no problems as well. So somehow I think this still is related to having this integration. Maybe we flooded the API?

PiotrMachowski commented 1 year ago

@MathijsG yeah, that's something I'm afraid of. You can try to reduce polling intensity by adding following config:

scan_interval: 30
sergicm commented 1 year ago

Today for me it's working again normally...

meepmeep commented 1 year ago

moved to : scan_interval: 60

Reboot worked yesterday, but map is once again unavaible this morning. New reboot and still nothing :(

MathijsG commented 1 year ago

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.

totow93 commented 1 year ago

ok i will test if scan_interval: 30 helps

MathijsG commented 1 year ago

Well, 60 of course would be better as it is even less often relying on the API.

meepmeep commented 1 year ago

I changed to 120 this morning, and remove the integration to maybe get some cool down on the api.

MathijsG commented 1 year ago

The official app seems to refresh every 5 seconds, if I counted correctly.

totow93 commented 1 year ago

@MathijsG yes but only when the app is open. the standard of this integration is refresh every 5 seconds 24/7, which are a few more api calls than the app does.

MathijsG commented 1 year ago

We can't know when the users actually looks at the card right? Would be nice to only update when needed.

PiotrMachowski commented 1 year ago

@MathijsG I'm not sure if it is easily doable...

totow93 commented 1 year ago

@PiotrMachowski Is it not possible to insert a query? If the robot is docked, update every 5 minutes, if not update every 5 seconds.

PiotrMachowski commented 1 year ago

@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

MathijsG commented 1 year ago

Mine broke again with 30 second interval. It seems they really tightened their rate limiting. Will try the conditional one.

Would also be nice if we could somehow have a fall back image, instead of fully broken. Maybe use the lastest working one if the next api call doesn't provide an image but an error instead?

YoMan12 commented 1 year ago

what is the proper syntax?

scan_interval:
   seconds: 30

or

scan_interval: 30

or both?

PiotrMachowski commented 1 year ago

@YoMan12 both of them are correct

cosmos1978 commented 1 year ago

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

meepmeep commented 1 year ago

I wrote yesterday to Xiaomi support, asking why lyymap wasn't loading on Xiaomi app.

Is your robot connected to any home assist integration to control the robot? like google assist or Alexa. If yes, what is the name of it? Could you shoot a video to show how you connect the robot to that integration? We are doubting the problem is related to that.

I tell them about home assistant and Google home. Still waiting for their answer.

bgoncal commented 1 year ago

Is this the way the scan_interval should be added?

Screenshot 2023-04-13 at 23 47 27
PiotrMachowski commented 1 year ago

@meepmeep have you told them about this integration?


@cpvbruno yes

YoMan12 commented 1 year ago

@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)

meepmeep commented 1 year ago

@PiotrMachowski I wasn't too specific. I just named "homeassistant".

Their answer (which isn't really one ;))

Thanks for your reply.

We suggest you disconnect robot from home assist or disable its map feature have a try, which should solve the issue. You can also try to connect the robot to Roborock APP to control the robot.

BTW,
Could you tell us your device's SN?
Open the cover of the device and take out the dustbin. There's a barcode on the device (not on dustbin). The SN is under the barcode like R0201S82418800.

Best regards.

Not sure I want to give them my SN ...

@YoMan12 can you share your blueprint ?

YoMan12 commented 1 year ago

@meepmeep sure but .... I'm neewbee due to I'm not sure how to make a downloadable link I will paste it just here (the original lines are commented) I hope it will be not against "github law" or common ;) (if yes then forgive me @PiotrMachowski and let me be instructed)


blueprint:
  name: Disable vacuum camera update when docked
  description: Disable the automatic update of the vacuum camera when the robot is
    docked.
  domain: automation
  source_url: https://github.com/PiotrMachowski/Home-Assistant-custom-components-Xiaomi-Cloud-Map-Extractor/blob/master/blueprints/automation/disable_vacuum_camera_update_when_docked.yaml
  input:
    vacuum:
      name: Vacuum device
      selector:
        entity:
          domain:
          - vacuum
          multiple: false
    camera:
      name: Vacuum camera
      selector:
        entity:
          domain:
          - camera
          multiple: false
mode: restart
trigger:
- platform: state
  entity_id: !input vacuum
condition:
- condition: template
  value_template: '{{ trigger.to_state.state != trigger.from_state.state }}'
action:
- condition: trigger
  id: 0
# - service: "{% if trigger.to_state.state in [\"unavailable\", \"unknown\", \"docked\"]
#     %}\n  camera.turn_off\n{% else %}\n  camera.turn_on\n{% endif %}\n"
#   entity_id: !input camera
- service: "{% if trigger.to_state.state in [\"unavailable\", \"unknown\", \"docked\"]
    %}\n  scan_interval: 600\n{% else %}\n  scan_interval: 5\n{% endif %}\n"
  entity_id: !input camera
PiotrMachowski commented 1 year ago

@YoMan12 thanks for your investigation, I'll add this feature to my blueprint as well 👍

PiotrMachowski commented 1 year ago

@YoMan12 Are you sure this part works correctly? I have never seen such approach to setting scan interval

- service: "{% if trigger.to_state.state in [\"unavailable\", \"unknown\", \"docked\"]
    %}\n  scan_interval: 600\n{% else %}\n  scan_interval: 5\n{% endif %}\n"
  entity_id: !input camera
YoMan12 commented 1 year ago

@PiotrMachowski nope, I'm not sure (as I wrote earlier I'm total newbie in this). I'm trying always to make slightly changes using logic and very basic knowledge of programming. But I'm basing on effect and the effect is as I described. Maybe it is just a coincidence (I wrote that it is working for 30h). Finally: "when sth is stupid but it works ... then it isn't stupid" :) To be serious: R U able to investigate if it really works?

PiotrMachowski commented 1 year ago

@YoMan12 You can check it out by starting the vacuum and checking HA logs. I think it will complain about this service call

YoMan12 commented 1 year ago

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

AseKarlsson commented 1 year ago

Hi, One more with the same problem.