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.18k stars 124 forks source link

Support for Dreame vacuums #126

Closed PiotrMachowski closed 2 years ago

PiotrMachowski commented 3 years ago

Vacuums confirmed to use this API:

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_raw: true
    force_api: dreame

and then follow steps provided in documentation: Retrieving map.

Existing implementation of map decoder

davideZavattero commented 2 years ago

Hi @PiotrMachowski, I own a Z10 pro. I think is the same as L10.

I check valetudo code. It needs "only" to convert that js file into python, right? I could help with this, but how can i configure a developing environment and a testing area? Is there somewhere documentation?

I never created implementation for HA, i don't know where start and what is needed for doing it, but i would help. Thank you.

PiotrMachowski commented 2 years ago

Hi @davideZavattero

Yes, that's the "only" thing that has to be done.

For development you can use get_map.py script. You have to include your implementation here (create image_handler.py and map_data_parser.py like in other platforms), the rest code should be already prepared for working with Dreame.

You can DM on HA forum with any problems

facutopa commented 2 years ago

Hi! I just got a new Xiaomi 1C, exactly the model mentioned on the first comment (dreame.vacuum.mc1808). But when I set up the .yaml like you said I got this: imagen Do I something wrong?

When I try the retrieving map with this command:

Open terminal and use the following command to copy file: docker exec homeassistant bash -c "mkdir -p /config/tmp/ && cp /tmp/map_* /config/tmp/"

I got:

cp: omitting directory '/tmp/map_*'

PiotrMachowski commented 2 years ago

@facutopa as you see this vacuum model is currently not supported by map extractor, so you won't get map image.

If you want to receive raw map data to send it to me then you don't have to, I already have map from this model

facutopa commented 2 years ago

@facutopa as you see this vacuum model is currently not supported by map extractor, so you won't get map image.

If you want to receive raw map data to send it to me then you don't have to, I already have map from this model

So If I understand, I can't use "Xiaomi Vacuum Map Card" right? Or sending to you the map is someway possible? Sorry, my english is bad and I understanded that send you the map is for help you to solve this issue, right?

PiotrMachowski commented 2 years ago

You can use it with map screenshot instead of live map, but it's much harder than using extractor.

I need maps to test implementation for Dreame vacuums in the future

davideZavattero commented 2 years ago

Hi @davideZavattero

Yes, that's the "only" thing that has to be done.

For development you can use get_map.py script. You have to include your implementation here (create image_handler.py and map_data_parser.py like in other platforms), the rest code should be already prepared for working with Dreame.

You can DM on HA forum with any problems

Ok, thank you. i'll try during holydays.

pkejval commented 2 years ago

@davideZavattero Do you have any progress? Can I help with anything? :)

rvalentinis commented 2 years ago

Sigh... Dreame Bot L10 Pro vacuum

FrancYescO commented 2 years ago

@PiotrMachowski can you share some commands helpful for a faster debugging/developing? something like:

put the file map_data_dreame.vacuum.p2041o.b64 in the dreame folder that execute python xiaomi_cloud_map_extractor/dreame/map_data_parser.py parse and you should find the generated .png in the same folder

PiotrMachowski commented 2 years ago

@FrancYescO I think I can prepare something like this, I already have similar scripts

Techfreak96 commented 2 years ago

@PiotrMachowski

Do you need an extracted map for Z10 Pro? I can share if it would help

PiotrMachowski commented 2 years ago

@Techfreak96 thanks, I already have a map from this model

PiotrMachowski commented 2 years ago

@FrancYescO @davideZavattero I have prepared a nice and easy to use script that will download a map from cloud or parse an already downloaded one: map processor

manujedi commented 2 years ago

I tried this with the dreame d9 max (dreame.vacuum.p2259). When i use the map processor script i get a ~5KB b64 file and the not supported image. When i use the store raw configuration i also get the the b64 file but the logging always says:

Retrieving map from Xiaomi cloud
Map data retrieved
Map is empty

The map extractor script:

Validating configuration file: camera.yaml
Configuration validation successful
Downloading map data...
Map data successfully saved to "camera" directory!

I have a map in the Mi Home app. Would the b64 file helpful to implement it?

PiotrMachowski commented 2 years ago

@manujedi You can send me this file as well as screenshot from Mi Home app, I probably don't have a map from this model yet

manujedi commented 2 years ago

is the b64 file the map? As the map extractor expects a *.gz file so i wasn't sure. Thanks

PiotrMachowski commented 2 years ago

@manujedi yes, different models provide different file formats: xiaomi -> gz viomi -> zlib roidmi -> gz dreame -> b64

manujedi commented 2 years ago

Perfect thanks, will send you the files

Nicooow commented 2 years ago

hello, Is the support going well? I really want to use this integration, is there any way to help? (because I'm a developer, maybe I can help)

Thanks

PiotrMachowski commented 2 years ago

Hi @Nicooow,

Personally I don't do it, maybe @FrancYescO and @davideZavattero have done something. There is a link to a working implementation written in JavaScript in the first comment, it needs to be rewritten in Python

Techfreak96 commented 2 years ago

Hi @Nicooow,

Personally I don't do it, maybe @FrancYescO and @davideZavattero have done something. There is a link to a working implementation written in JavaScript in the first comment, it needs to be rewritten in Python

unfortunately i can only do small basics in python and co. has anyone already written something to fall back on?

Nicooow commented 2 years ago

ok I'll look at next week to do this, there shouldn't be any problem

kisjeth commented 2 years ago

Nothing about Dreame D9? DÃŪs you receive my map, @PiotrMachowski ?

PiotrMachowski commented 2 years ago

@kisjeth I think I did. I have a lot of maps for many different vacuums, I will test all of them before release.

kisjeth commented 2 years ago

@kisjeth I think I did. I have a lot of maps for many different vacuums, I will test all of them before release.

Ok tnks! Anyway great job!

Nicooow commented 2 years ago

@PiotrMachowski could you just quickly explain to me what image_handler.py is for?

PiotrMachowski commented 2 years ago

@Nicooow map_data_parser.py - parses whole raw binary map file image_handler.py - parses map image data

You can DM on HA forum with any problems

MegoVaTx commented 2 years ago

image Just sent an email with a screenshot and raw map for MOVA L600 or Dreame F9/D9 (similar) (Dreame p2157). Thank you so much. Can't wait to use it =)

Pxvvxp commented 2 years ago

Hi @PiotrMachowski you are doing really grate job! I am also seeing no support alert for one of my robots - dreame.vacuum.mb1808 . What exactly should I send to you right now? image

PiotrMachowski commented 2 years ago

@Pxvvxp you can send me map_data_dreame.vacuum.mb1808.b64 file + screenshot from Xiaomi Home.

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_raw: true
    force_api: dreame
    store_map_path: "/config"
Pxvvxp commented 2 years ago

Hello @PiotrMachowski, I just wanted to make sure you received my email with screenshot + file for mb1808 and if I did everything fine. Thanks in advance.

PiotrMachowski commented 2 years ago

@Pxvvxp yup, everything is ok

Neonox31 commented 2 years ago

Hello 👋

I've got a dreame.vacuum.p2008 model and I'm currently working on transcribing Valetudo's javascript code for map parsing of Dreame models.

I'm quite comfortable with Javascript, but I'm just discovering Python so it's taking me a little while. Here is the actual map I can generate with my model : 2022-01-27_15-44 You can see floor, walls, charger and vaccum position as well as no go areas. I also implemented path parsing, but the dreame map contains several paths and the MapData can only contain one if I understand correctly. I tried to flatten the list but it causes unwanted interconnections between paths : 2022-01-27_16-59

I have a lot of work to do and I will submit a P.R if you're intesrested @PiotrMachowski

PiotrMachowski commented 2 years ago

Nice 👍 I think I can add support for multiple paths without any problems. You can create a PR, I will check it out and adjust if needed 😉

auanasgheps commented 2 years ago

😍 It's wonderful to see progress on this!

PulsarFX commented 2 years ago

Is this intended to pull data from the cloud or directly from the robot? I've blocked internet access in the router and control it via xiaomi_vacuum.

PiotrMachowski commented 2 years ago

@PulsarFX well, the name contains the word "cloud"... 😉

PulsarFX commented 2 years ago

nevermind :nerd_face: :exploding_head: This would be a valetudo only feature, then?

PiotrMachowski commented 2 years ago

Yup, if you want to remain cloud-free

Bloodpilot commented 2 years ago

Did someone already start (or has ben successfull) to add support for the Dreame D9 Pro (dreame.vacuum.p2187) if not, does anyone plan to do that so we could join forces?

PiotrMachowski commented 2 years ago

@Bloodpilot https://github.com/PiotrMachowski/Home-Assistant-custom-components-Xiaomi-Cloud-Map-Extractor/pull/230

RaJeronimo commented 2 years ago

I probably go for a Dreame bot w10. Is there any chance this robot will be included in this feature in the future or is it impossible?

PiotrMachowski commented 2 years ago

@RaJeronimo I think it will

BernieV1977 commented 2 years ago

I have send the raw map file and a screenshot to support dreame.vacuum.p2041o. Tia!

mirkin-pixel commented 2 years ago

Will the Dreame Z10 Pro (dreame.vacuum.p2028) also added?

PiotrMachowski commented 2 years ago

@mirkin1993 I think so

aviadlevy commented 2 years ago

A noob question - is the support for "Dreame" vacuums includes also the vacuum functionality like "goto" on the xiaomi-vacuum-map-card?

PiotrMachowski commented 2 years ago

@aviadlevy this is a completely different thing. Map card has to support integration used to control vacuum.

Wyfy0107 commented 2 years ago

Is there any update on this. I would love to have mc1808 supported