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

Rockrobo v1 random map rotation #303

Open Crickus opened 2 years ago

Crickus commented 2 years ago

Description

Is there any solution for random map 180 rotation at rockrobo v1 at every cleaning start? I know what it's MiHome problem, not extractor.

Solution

Maybe it's possible to analyse image during extraction to auto rotate it? Some kind of test check "vacuum should start cleaning from the base situated in upper left corner" or something like this? Or maybe someone already tried to do script/automatisation patch for this issue?

Alternatives

No response

Context

No response

PiotrMachowski commented 2 years ago

Can you provide some examples of maps in different rotations? Is it the same as just rotating the whole image or does items on the map move as well?

Crickus commented 2 years ago

I almost sure what I saw topic about this issue at your v1 map repo, but with no solution. This is the map image from your v1 project. It's cleared, but it present normal room direction. Vacuum station is in the upper left room. map_новый размер

Sometimes vacuum at cleaning start rotates map at 90 degrees. Today it rotated map at 180. Capture+_2022-06-09-22-22-44_новый размер

What's why I stopped using previous version. Map has changed randomly and coordinates have moved vacuum into wrong position.

As I understand it's some kind of Xiaomi defence algorithm to excludes more expensive models features from the cheapest one))

PiotrMachowski commented 2 years ago

Yes, there's no solution at this moment.

Can you provide raw images from Map Extractor instead? Ideally from config without map trimming

t0bse commented 2 years ago

got the same problem, the most times the roborock scans, the rotation is wrong.

Crickus commented 2 years ago

I pulled two images with different orientation today. It took three attempts (first and second was with the same orientation). map_image_rockrobo vacuum v1 map_image_rockrobo vacuum v1_reversed

PiotrMachowski commented 2 years ago

Can you change config of map extractor to following:

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
      - image

and check out if this template correctly recognizes location of docking station?

{% set docking = state_attr('camera.xiaomi_cloud_map_extractor', 'calibration_points')[0].map %}
{% set image = state_attr('camera.xiaomi_cloud_map_extractor', 'image').dimensions %}
{% set center = {'x': image.width * image.scale / 2, 'y': image.height * image.scale / 2, } %}
{{ ('upper' if docking.y <= center.y else 'lower') + '_' + ('left' if docking.x <= center.x else 'right') }}
Crickus commented 2 years ago

Yep. Your template recognized corner perfectly. If I understand your idea we need to wait until map changes it orientation and check it once again, right? map template

PiotrMachowski commented 2 years ago

If I understand your idea we need to wait until map changes it orientation and check it once again, right?

Exactly. Also please check if CPU/RAM usage stayed at the same level

Crickus commented 2 years ago

The reversed map also recognized perfectly. CPU/RAM show more or less stable consumption (I have old Rasp3 HA server) . mem1 proc1 template_reverse One more detail. I'm not sure does vacuum rotate only the map or whole coordinates field. Even if we rotate the map in HA to normal direction, coordinates we transmit to API will be reversed, am I right?

t0bse commented 2 years ago

@PiotrMachowski the code works for me, too. any news on this?

LexaBukreev commented 1 year ago

Could you please give an advice, how to enable room cleaning? I mapped rooms, but when i press start button (play button near x1 in a right side) - vacuum do nothing. Rooms a selectable, but after pressing start - it becomes unchecked and no response from vacuum. Xiaomi ver.1 P.S. I am ttrying to add an screenshot here, but "something went wrong"

PiotrMachowski commented 1 year ago

@LexaBukreev v1 vacuum doesn't support room cleaning