Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for Roidmi vacuums #127

Closed
PiotrMachowski opened this issue Jun 7, 2021 · 10 comments · Fixed by #148
Closed

Support for Roidmi vacuums #127

PiotrMachowski opened this issue Jun 7, 2021 · 10 comments · Fixed by #148
Assignees
Labels
enhancement New feature or request

Comments

@PiotrMachowski
Copy link
Owner

PiotrMachowski commented Jun 7, 2021

Vacuums confirmed to use this API:

  • roidmi.vacuum.v60 (Roidmi EVE Plus)
  • viomi.vacuum.v18 (Viomi S9)

You can help in implementation of this feature by sending your map file and a screenshot from Xiaomi app at

piotr.machowski.dev [at] gmail [dot] com.

To get raw map file you have to use following config:

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
    store_map: true
    force_api: roidmi

and then follow steps provided in documentation: Retrieving map.

@PiotrMachowski PiotrMachowski added enhancement New feature or request maybe someday labels Jun 7, 2021
@PiotrMachowski PiotrMachowski self-assigned this Jun 7, 2021
@PiotrMachowski PiotrMachowski added the help wanted Extra attention is needed label Jun 7, 2021
@antyakushev
Copy link

I also own this vacuum, @PiotrMachowski, can you please tell how particularly you managed to extract the image from its map file?

@PiotrMachowski
Copy link
Owner Author

PiotrMachowski commented Jun 8, 2021

@antyakushev
Can you send me your map file at piotr.machowski.dev [at] gmail [dot] com?

Map decoding procedure:

  • unzip the file (it's compressed in gzip format)

  • can open it in text editor (e.g. Notepad++).

  • the file will consist of 2 sections: map image and map description in JSON

  • read image dimensions from JSON section

  • recreate image using bytes from first section, but after skipping first 16 ones.

    Code
    import gzip
    from PIL import Image
    
    dir = "map_data/roidmi.vacuum.v60"
    gzip_file = open(f"{dir}/map_data.gz", "rb")
    gzip_content = gzip_file.read()
    gzip_file.close()
    raw = gzip.decompress(gzip_content)
    gzip_output_file = open(f"{dir}/map_data.output", "wb")
    gzip_output_file.write(raw)
    gzip_output_file.close()
    width = 183
    height = 267
    sub = raw[16:width * height * 16]
    colors = {}
    rand = random.Random()
    for i in range(256):
        colors[i] = (rand.randint(0, 255), rand.randint(0, 255), rand.randint(0, 255))
    image = Image.new('RGBA', (height, width))
    pixels = image.load()
    for y in range(width):
        for x in range(height):
            v = sub[y * height + x]
            pixels[x, y] = colors[v]
    image.save(f"{dir}/map_data.png")
    

@amaciasf
Copy link

I also want to help. How can I get the map file?

@PiotrMachowski
Copy link
Owner Author

@amaciasf I have updated description in the first comment

@antyakushev
Copy link

@PiotrMachowski Thanks, I succeeded extracting the image!
I've also sent you the map file.

@poisondima
Copy link

I sent you files for help.
P.S. Link to "Retrieving Map" in the first comment is invalid, you need to fix it.

@PiotrMachowski
Copy link
Owner Author

@poisondima thank you!

Link fixed ;)

@PiotrMachowski
Copy link
Owner Author

You can now check out version from this branch

@poisondima
Copy link

It works! Thank you!
изображение

@slimpdev
Copy link

slimpdev commented Aug 1, 2021

For now need to replace "store_map: true" to "store_map_raw: true".

@PiotrMachowski PiotrMachowski removed help wanted Extra attention is needed maybe someday labels Mar 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants