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.14k stars 121 forks source link

Add support for dreame.vacuum.p2140o #405

Closed shurakenas closed 1 year ago

shurakenas commented 1 year ago

Checklist

The problem

Некорректная калибровка, проверьте вашу конфигурацию. Не отображается карта пылесоса.

What version of an integration has described problem?

v2.2.0

What was the last working version of an integration?

No response

What vacuum model do you have problems with?

dreame.vacuum.p2140o

What version of Home Assistant do you use?

core-2022.3.5

What type of installation are you running?

Home Assistant OS

Camera's configuration

type: custom:xiaomi-vacuum-map-card
title: Xiaomi Vacuum Map Card
preset_name: Live map
entity: vacuum.p2140o_xxxxxxxxx
camera_calibration: true
map_source:
  camera: camera.xiaomi_cloud_map_extractor
calibration_source:
  camera: true
map_modes:
  - template: vacuum_clean_zone
vacuum_platform: default

Errors shown in the HA logs (if applicable)

Logger: homeassistant.components.camera
Source: helpers/entity_platform.py:719
Integration: Камера (documentation, issues)
First occurred: 12:25:09 (244 occurrences)
Last logged: 13:15:42

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

Logger: homeassistant.helpers.entity
Source: helpers/entity.py:747
First occurred: 12:24:19 (62 occurrences)
Last logged: 13:15:12

Update of camera.xiaomi_cloud_map_extractor is taking over 10 seconds

Additional information

https://ibb.co/h9qnY0H

PiotrMachowski commented 1 year ago
Logger: homeassistant.helpers.entity
Source: custom_components/xiaomi_cloud_map_extractor/dreame/map_data_parser.py:51
Integration: xiaomi_cloud_map_extractor ([documentation](https://github.com/PiotrMachowski/Home-Assistant-custom-components-Xiaomi-Cloud-Map-Extractor), [issues](https://github.com/PiotrMachowski/Home-Assistant-custom-components-Xiaomi-Cloud-Map-Extractor/issues))
First occurred: 11:57:29 (2 occurrences)
Last logged: 12:07:28

Update for camera.xiaomi_cloud_map_extractor fails
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 535, in async_update_ha_state
    await self.async_device_update()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 744, in async_device_update
    raise exc
  File "/usr/local/lib/python3.9/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/xiaomi_cloud_map_extractor/camera.py", line 278, in update
    self._handle_map_data(map_name)
  File "/config/custom_components/xiaomi_cloud_map_extractor/camera.py", line 335, in _handle_map_data
    map_data, map_stored = self._device.get_map(map_name, self._colors, self._drawables, self._texts,
  File "/config/custom_components/xiaomi_cloud_map_extractor/common/vacuum.py", line 36, in get_map
    map_data = self.decode_map(response, colors, drawables, texts, sizes, image_config)
  File "/config/custom_components/xiaomi_cloud_map_extractor/dreame/vacuum.py", line 24, in decode_map
    return MapDataParserDreame.decode_map(raw_map_string, colors, drawables, texts, sizes, image_config)
  File "/config/custom_components/xiaomi_cloud_map_extractor/dreame/map_data_parser.py", line 51, in decode_map
    unzipped = zlib.decompress(base64.decodebytes(raw_map_string.encode("utf8")))
zlib.error: Error -3 while decompressing data: incorrect header check
PiotrMachowski commented 1 year ago

You have to send me raw map file as well

shurakenas commented 1 year ago

Where to get the raw map file?

PiotrMachowski commented 1 year ago

Add following lines to config of map extractor:

store_map_raw: true
store_map_path: /config

Map file will be stored alongside configuration.yaml

shurakenas commented 1 year ago

I added these parameters and restarted HA, the map file did not appear. What name and extension should the map file have?

PiotrMachowski commented 1 year ago

Can you show your config?

shurakenas commented 1 year ago
camera:
  - platform: xiaomi_cloud_map_extractor
    host: 192.168.xxx.xxx
    token: mytoken
    username: myusername
    password: mypass
    force_api: xiaomi
    store_map_raw: true
    store_map_path: /config
    draw: ['all']
    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
    auto_update: true
    scan_interval:
      seconds: 10 #10seconds
PiotrMachowski commented 1 year ago

Use this one instead:

camera:
  - platform: xiaomi_cloud_map_extractor
    host: 192.168.xxx.xxx
    token: mytoken
    username: myusername
    password: mypass
    store_map_raw: true
    store_map_path: /config
    draw: ['all']
    attributes:
      - calibration_points
      - rooms
shurakenas commented 1 year ago

The file has appeared, how best to send it to you?

PiotrMachowski commented 1 year ago

piotr.machowski.dev [at] gmail.com

shurakenas commented 1 year ago

Sent

shurakenas commented 1 year ago

Did you get my file?

PiotrMachowski commented 1 year ago

Yes, I got it

lfdominguez commented 1 year ago

Ohhh great, if you need more info i can help too, i have one of this kind of vacuum

shurakenas commented 1 year ago

Is there any news?

JudeCrew commented 1 year ago

I have the same problem with p2140p model... Looking forward to some news.

lfdominguez commented 1 year ago

Hi @PiotrMachowski how can I help with this (I'm a developer), I have this same vacuum device and i want get that map.

PiotrMachowski commented 1 year ago

@lfdominguez check out this issue

lfdominguez commented 1 year ago

@lfdominguez check out this issue

Thanks

shurakenas commented 1 year ago

I didn't understand what needs to be done to make it work dreame.vacuum.p2140o

lfdominguez commented 1 year ago

I didn't understand what needs to be done to make it work dreame.vacuum.p2140o

The thing is (I will test it based on that other issue) the map is encrypted on our model with a static key, and need to add that middle task of decrypting the map raw data first.

shurakenas commented 1 year ago

I didn't understand what needs to be done to make it work dreame.vacuum.p2140o

The thing is (I will test it based on that other issue) the map is encrypted on our model with a static key, and need to add that middle task of decrypting the map raw data first.

thank you, I will be waiting for news

lfdominguez commented 1 year ago

@PiotrMachowski that patch from the other issue is working GREAT!!!!!!

image

shurakenas commented 1 year ago

@PiotrMachowski that patch from the other issue is working GREAT!!!!!!

image

what should I do to make it work?

lfdominguez commented 1 year ago

@PiotrMachowski that patch from the other issue is working GREAT!!!!!! image

what should I do to make it work?

You must use this https://github.com/PiotrMachowski/Home-Assistant-custom-components-Xiaomi-Cloud-Map-Extractor/files/11109954/xiaomi_cloud_map_extractor.zip and merge with your actual plugin code, modify where say p2140p by p2140o.

shurakenas commented 1 year ago

@PiotrMachowski that patch from the other issue is working GREAT!!!!!! image

what should I do to make it work?

You must use this https://github.com/PiotrMachowski/Home-Assistant-custom-components-Xiaomi-Cloud-Map-Extractor/files/11109954/xiaomi_cloud_map_extractor.zip and merge with your actual plugin code, modify where say p2140p by p2140o.

thank you, it works

Balooski commented 1 year ago

@PiotrMachowski that patch from the other issue is working GREAT!!!!!! image

what should I do to make it work?

You must use this https://github.com/PiotrMachowski/Home-Assistant-custom-components-Xiaomi-Cloud-Map-Extractor/files/11109954/xiaomi_cloud_map_extractor.zip and merge with your actual plugin code, modify where say p2140p by p2140o.

thank you, it works

How did you get it to work? I changed every instance of p2140p to p2140o and replaced the files in HA with the ones from the patch. Restarted HA, still get the error. Rebooted the system, still the same. Am I missing something? I'm running OS on a RPi 4, using the miot platform.

shurakenas commented 1 year ago

@PiotrMachowski that patch from the other issue is working GREAT!!!!!! image

what should I do to make it work?

You must use this https://github.com/PiotrMachowski/Home-Assistant-custom-components-Xiaomi-Cloud-Map-Extractor/files/11109954/xiaomi_cloud_map_extractor.zip and merge with your actual plugin code, modify where say p2140p by p2140o.

thank you, it works

How did you get it to work? I changed every instance of p2140p to p2140o and replaced the files in HA with the ones from the patch. Restarted HA, still get the error. Rebooted the system, still the same. Am I missing something? I'm running OS on a RPi 4, using the miot platform.

have you changed the country in the "get_otherinfo" function?

Balooski commented 1 year ago

@PiotrMachowski that patch from the other issue is working GREAT!!!!!! image

what should I do to make it work?

You must use this https://github.com/PiotrMachowski/Home-Assistant-custom-components-Xiaomi-Cloud-Map-Extractor/files/11109954/xiaomi_cloud_map_extractor.zip and merge with your actual plugin code, modify where say p2140p by p2140o.

thank you, it works

How did you get it to work? I changed every instance of p2140p to p2140o and replaced the files in HA with the ones from the patch. Restarted HA, still get the error. Rebooted the system, still the same. Am I missing something? I'm running OS on a RPi 4, using the miot platform.

have you changed the country in the "get_otherinfo" function?

I saw that 30s after my reply. Changed it to us and now it works. I'll get to testing the functionality now.

PiotrMachowski commented 1 year ago

Moving the discussion to an issue for all affected vacuums: #459