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

Add support for Dreame D9 Robot Vacuum (dreame.vacuum.p2009) #870

Closed
bigdx opened this issue Nov 25, 2020 · 116 comments · Fixed by #1581
Closed

Add support for Dreame D9 Robot Vacuum (dreame.vacuum.p2009) #870

bigdx opened this issue Nov 25, 2020 · 116 comments · Fixed by #1581

Comments

@bigdx
Copy link

bigdx commented Nov 25, 2020

The Dreame D9 Robot Vacuum is launched in Europe and has some interesting specs and feature.

Device information:

Additional context
As there is already the miot-spec out there (http://miot-spec.org/miot-spec-v2/instance?type=urn:miot-spec-v2:device:vacuum:0000A006:dreame-p2009:1) it should be possible to add support?! As I am new to this, I have no Idea where to start, but would like to contribute (when my robot arrives ^^)

@rytilahti
Copy link
Owner

I wouldn't be surprised if this shares similarities with p2008 (WIP PR #683) or some other dreame vacuums (#812).

@bigdx
Copy link
Author

bigdx commented Nov 26, 2020

I wouldn't be surprised if this shares similarities with p2008 (WIP PR #683) or some other dreame vacuums (#812).

That would be great! And if I havent missed some critical point, it seems not THAT hard to get this done. By getting the commands from miot-spec you can write py-functions to controll the bot ... and hide that behind a nice UI ;-)

Slightly off-topic, but does the bot have to be conected to the internet to receive those "locale" commands?

@rytilahti
Copy link
Owner

That would be great! And if I havent missed some critical point, it seems not THAT hard to get this done. By getting the commands from miot-spec you can write py-functions to controll the bot ... and hide that behind a nice UI ;-)

Yes, there is a script in devtools directory for that purpose. It takes a miot-spec json as input and generates a template that can be used to add support for new devices. It is still heavily work in progress, as is the whole architecture to support miot devices in a future-proofed way.

Slightly off-topic, but does the bot have to be conected to the internet to receive those "locale" commands?

No idea, sorry. It really depends on the device, but at the moment I cannot recall issues regarding to blocking the internet access, outside https://python-miio.readthedocs.io/en/latest/troubleshooting.html#intermittent-connection-issues-timeouts-xiaomi-vacuum .

@JLink-1
Copy link

JLink-1 commented Dec 23, 2020

Hi guys,

is there already something new regarding this robot? I got this model last week and would like to implement it into home assistant.

@bigdx
Copy link
Author

bigdx commented Jan 7, 2021

Hi guys,

is there already something new regarding this robot? I got this model last week and would like to implement it into home assistant.

Caused by (the pandemic- and the holiday-caused ^^) lockdown I had not much time yet. I tried to capture the commands of the App with wireshark, but had no luck. I guess a stupid little issue but my brain was just to lazy from all the eating to see it ;-) Would be nice if someone could try that too.

Yes, there is a script in devtools directory for that purpose. It takes a miot-spec json as input and generates a template that can be used to add support for new devices. It is still heavily work in progress, as is the whole architecture to support miot devices in a future-proofed way.

As soon as possible i'll try that.

No idea, sorry. It really depends on the device, but at the moment I cannot recall issues regarding to blocking the internet access, outside https://python-miio.readthedocs.io/en/latest/troubleshooting.html#intermittent-connection-issues-timeouts-xiaomi-vacuum .

Sounds promising. Strange, I searched like crazy for such informations but no luck. Thats why I like to "ask" stuff, humans are much better search-engines ;-)

@patrik-dev
Copy link

Any news at this issue? I have a d9 too and it would be very nice if I could control it with oh and Alexa :)

@GizmoLibre
Copy link

I have a Dreame D9 and it does work with Home Assistant. Just follow a post from Hyyd1e here for support for F9, apparently this works for D9 too - https://community.home-assistant.io/t/support-for-xiaomi-dream-f9-mop-vacuum/220858/14
dreame d9

@spider54
Copy link

Hello,
I managed to add my D9 vacuum cleaner in HA, but I cannot recover the card to order the vacuum cleaner by zone or by room.
have you succeeded?
thank you

@GizmoLibre
Copy link

Hi. Unfortuanely, no, i haven't. It seems kinda tricky to set up, it involves extracting the coordinates for rooms or zones, and making the scripts to incorporate them in the card. I was trying to read up on the procedure for Xiaomi Mijia 1C which is similar to Dreame D9, but i didn't have the time to actually do it. You can find the discussion here https://community.home-assistant.io/t/xiaomi-mijia-1c-sweeping-vacuum-cleaner-white-stytj01zhm/185089/95 , let me know if you succeed.

@marcelrv
Copy link

If the format is similar to the roborock models you can use this tool to extract coordinates from the map

https://community.openhab.org/t/xiaomi-vacuum-map-viewer-to-find-coordinates-for-zone-cleaning/103500

@spider54
Copy link

Thank you, I use for my Roborock S5, and it works very well.
https://github.com/PiotrMachowski/Home-Assistant-custom-components-Xiaomi-Cloud-Map-Extractor
but it does not work with my Dreame D9.
How can I use Marcel Verpaalen's software with Home Assistant?
How to get the rrmap? from Xiaomi Home?

@pergolafabio
Copy link

To extract coordinates, you need to download that customized xiaomi .apk, it will create a log file on android with the coordinates, from there you can use them in your scripts... It's discussed on the community forums

@spider54
Copy link

Thanks pergolafabio, where can I download this apk?

@pergolafabio
Copy link

There was link posted on the forums, let me know if you can't find it, I have it also local...

@spider54
Copy link

Difficult to find without knowing the exact name of the file!
If you have a link, thank you.

@Chrischi-
Copy link

Chrischi- commented Jan 31, 2021

MiHome_6.1.700_63410_vevs.apk
or google „kapiba mihome“.

The file will surely infringe some copyright and so I didn't want to post the direct link.

@spider54
Copy link

Thanks, great, I found it.

@spider54
Copy link

spider54 commented Feb 5, 2021

Hello, I installed the apk but I don't see how to recover the card !!

@pergolafabio
Copy link

It's not possible to extract map , only coordinates that are in a log file

@spider54
Copy link

spider54 commented Feb 5, 2021

And how do we get the coordinates?
Where is this log file?

@pergolafabio
Copy link

Look here, you need to manually create the folder first, then start a normal clean, it will create a file then...
Then stop the clean, and then just start with your coordinate cleaning...

https://community.home-assistant.io/t/xiaomi-mijia-1c-sweeping-vacuum-cleaner-white-stytj01zhm/185089/118?u=pergola.fabio

@spider54
Copy link

spider54 commented Feb 6, 2021

Thank you pergolafabio, I had to create the 3 directories as indicated, I got a file, but I don't really see any coordinates.

@GizmoLibre
Copy link

Same for me, i cannot find them with the log file method. Nothing in there resembles to the coordinates as for the other Xiaomi vacuums, so i guess Dreame D9 shows them in a like a different value or something. Also, even if i found and extracted them, i cannot use them anyway, since the vacuum.send_command is giving me "failed to call service". So using it with the F9 method i linked only gets you so far. Someone with the higher knowledge and D9 needs to work on this, if we want to make zone cleaning and live maps available.

@spider54
Copy link

spider54 commented Feb 7, 2021

thank you,
I came to the same conclusion.

@rezmus
Copy link

rezmus commented Feb 7, 2021

search for something like this

"siid":4,"aiid":1,"in":[{"piid":1,"value":19},{"piid":10,"value":X}]

X contains json with areas. i'm pretty sure d9 uses same cmd for room/zone clean as f9.

@spider54
Copy link

spider54 commented Feb 7, 2021

Thank you for your help. An extract of my file compared to your indication, but I do not see what to recover!
2021-02-06 13:51:53 -> {"id":4531,"method":"action","params":{"did":"382836526","siid":6,"aiid":1,"in":[{"piid":2,"value":"{"req_type":1,"frame_type":"I"}"}]}}
2021-02-06 13:52:06 -> {"id":4534,"method":"action","params":{"did":"382836526","siid":4,"aiid":1,"in":[{"piid":1,"value":18},{"piid":10,"value":"{"selects":[[5,1,0,2,1]]}"}]}}

@pergolafabio
Copy link

Are you starting a room cleaning? Or are you drawing an rectangle? Room cleaning commands are not supported yet i think

@rezmus
Copy link

rezmus commented Feb 7, 2021

1/18 is room clean which uses array of selects (rooms) in this format

var selectInfo = [];

for (var areaId in selectAreas) {
  var _item = selectAreas[areaId];

  if (_item) {
    var newData = [parseInt(_item), _this.state.selectNum, _this.state.cleaningMode, _this.state.mopMode, Number(areaId) + 1];
    selectInfo.push(newData);
  }
}

var selectData = {
  "selects": selectInfo
};

1/19 is zone/area clean.

@need2buy
Copy link

@pooyashahidi I am glad that my solution to room cleaning helps others. You could add me as a contributor if you find it appropriate. I am not so savvy at coding so I do not create my own repository publicly.

After using D9 for a few months, the main issue with this bot is no persistent map control. Map constantly get updated and overwrite the previous save map after each successful clean. Any change in the environment would cause the map to to shift from a few inches to a few feet from the original map in random direction. This could render zone cleaning to fail and its a hassle to fix each and every script built for automation. Thus room clean id service helps since map could be reset, but with static room mapping following the order created in the schedule in Mi Home app would avoid recreate the existing automation script.

Hopefully, the next firmware update could address the persistent map issue with few other minor issues. Until then, we'll see if any way to improve the usability of this bot.

Note: Do you know that we could the bot run more than 2 passes per room? I have set mine to run 4 to 6 times per room for complete deep clean :))

@pooyashahidi
Copy link
Contributor

pooyashahidi commented Jun 24, 2021

@need2buy I'm also not really a python developer myself (I learn as I go).
I just got this thing a couple of days ago and was frustrated by the amount of info, some correct some not so much, scattered around the net but not really any single working integration or even a resource to learn how to do it.

So I thought maybe I can make something relatively well documented so that others don't have to go through the same thing.
Just made the install voice pack service accessible from HA.

I have not tried it with more than two cleaning passes, will test tomorrow. I don't think that would make a huge difference. But I used the thingy only a couple of times.

okay it in fact does do more than 2 cleaning passes (yaay).

@CanoHard
Copy link

@pooyashahidi Hi I have installed the custom component from your repository and I can confirm that it also works with the dreame l10 pro. So it will be nice if you could update the docs to make other people know that it also works with this device.

@franksteiner88
Copy link

Hello, I'am new here. Can you tell me, where i have to introduce new services and include the script. THX

@jeyph
Copy link

jeyph commented Sep 9, 2021

@pooyashahidi thank you for you work! Can you share you custom lovelace card? Looks amazing!

@pooyashahidi
Copy link
Contributor

pooyashahidi commented Sep 10, 2021

@pooyashahidi thank you for you work! Can you share you custom lovelace card? Looks amazing!

unfortunately I do not have it anymore. I moved on from using that widget and made one in HA using this fantastic work as inspiration.

I rooted my D9 and currently use my repo in conjunction with Valetudo Map Card to get this result:
image

@GizmoLibre
Copy link

GizmoLibre commented Sep 10, 2021

@pooyashahidi Wow, that looks really nice. I had no idea that rooting the D9 is even doable, let alone getting jt to work with Valetudo. Mind sharing a bit more detailed (i mean the rooting part step by step) procedure how to achieve that? :) Thanks in advance, would love to implement it on my dashboard ASAP :)

@pergolafabio
Copy link

Indeed, that's new either, i have a F9 model, should work too... Are there improvements with newer firmware?

@pooyashahidi
Copy link
Contributor

pooyashahidi commented Sep 10, 2021

@pooyashahidi Wow, that looks really nice. I had no idea that rooting the D9 is even doable, let alone getting jt to work with Valetudo. Mind sharing a bit more detailed (i mean the rooting part step by step) procedure how to achieve that? :) Thanks in advance, would love to implement it on my dashboard ASAP :)

I really don't want to hijack this issue as it is mainly about adding D9 support to Python-miio. I am fine discussing my fork since it uses python miio and could have as well been done here (probably will not) but Valetudo is definitely outside of that area. So i keep it short.

You can find almost all the info required for rooting and installing valetudo in their last github release. There you will also find a link to the telegram group where stuff is discussed and some* help is given. But it is mostly from people who are starters like myself. The admins are mostly ignoring messages regarding problems that they don't want to answer. Using search in the group is probably a good thing to do.

Indeed, that's new either, i have a F9 model, should work too... Are there improvements with newer firmware?

I am using firmware 1093 which is apparently a leaked beta or something (which i found out after installing it) not really the most stable thing but it works. I would probably stick to the older stable firmwares, that being said I think (probably placebo) there are some improvements in how the bot moves. I think it hits less stuff when cleaning. But still dumb af when it comes to getting out of tight spaces.

@pergolafabio
Copy link

ok, seems we need to buy some hardware to root it :-)

https://valetudo.cloud/pages/general/rooting-instructions.html

To do this, you’ll only need a pry tool, and a 3.3V USB UART Adapter (Like CP2102 or Pl2303) as well as basic linux knowledge.

@GizmoLibre
Copy link

Indeed we do. @pooyashahidi Thanks for the write-up. I have read the messages in Telegram group, and have mixed feelings about the rooting process. On one hand, sounds simple enough if you read all the steps in the guides, but on the other hand i am not thrilled about the risk of rooting process failing. They do mention it is eventually fixable, but dunno, chance of soft bricking the robot does not sound great.

About the hardware needed, I have asked if it is doable with ESP32 boards since i have a couple laying around, but no response. I also have a CH341A mini programmer i bought ages ago on AliExpress, but i have found out it is actually 5V instead of 3.3V, and i would need to solder some wires to make it 3.3V - all that sounds like a hassle :) In any case, i would still need to order those F2M jumper wires for the connection between uart and the robot...

I surely am tempted to go with the rooting process, but it does involve some risks. Rewards are cool though, you just need to be willing to get the needed tools and crack open the robot :) If someone else decides to go through it, let us know how it went. Also, sorry for hijacking the topic with rooting stuff, but this is a convenient place to write about it.

@pergolafabio
Copy link

Yeah, do we have actually any advantages when it's rooted? Besides a live card in HA?

@pooyashahidi
Copy link
Contributor

@GizmoLibre sorry I don't know about the esp32 but the ttl programmers are really cheap like a couple euros. I had one laying around so I tried the UART method. it couldn't be any simpler really.
@pergolafabio well it has privacy advantages if you block xiaomi cloud. it also gives you shell access to the device if you like to mess with it :) and the map as it is currently not supported any other way

@Charlyiii
Copy link

hi guys, is it possible to change the voice and put a custom one like in My Vacuum or Roborock? Would it be the same process? I wanted to put the voice of darth vader :p thanks

@Handy-E
Copy link

Handy-E commented Sep 19, 2021

@GizmoLibre sorry I don't know about the esp32 but the ttl programmers are really cheap like a couple euros. I had one laying around so I tried the UART method. it couldn't be any simpler really.

@pooyashahidi Can you please tell me how you did that? Bought a new D9 this month and I am trying to root it for two weeks now with no luck. I can see the boot message when device starts (reboot) and everything I type is echoed, but cannot get a shell. Only my typed letters are displayed (so the UART-Device and connection is working), but no command line, nothing, after pressing wifi button for 3 seconds. If the D9 is docked or not also makes no difference. Thanks in advance!

@GizmoLibre
Copy link

I went ahead and rooted my D9 a couple of days ago, it was too tempting to pass. I cannot say it was an easy task, even with the guides provided (yes, there are several in the Telegram group), as you need to decipher what is the correct wiring for your chosen method, i mean between TTL and the robot - ended up using my ESP32S board that i used for temperature sensors in Home Assistant, worked just fine. I did however need to order jumper wires, as you can't do anything without them.

Also, backup procedure can be confusing, commands in the shell, etc. Not at all hard for someone that has the knowledge about this kind of stuff, but for someone that never done this kind of tinkering with your hardware, it won't be easy. But hey, you end up learning something new. Valetudo is a better local alternative to MiHome, as you can simply do more with your HA integration - i love it.

@pooyashahidi

It is such a pain trying to apply what matt8707 and you did in my existing lovelace config. I like your version of it more to be honest, and i want to recreate it. Mind sharing your lovelace config? I am stuck, from your screenshot it looks the status, control and Map is one wide card? Also the custom cleanup part is interesting to me. It will be easier if i can take a look at your config and modify it to my case. So far i am testing it in a separate dashboard.

d9ha

@pooyashahidi
Copy link
Contributor

pooyashahidi commented Sep 19, 2021

@Handy-E
I followed this guid iirc. I did not press the wifi button at all.
About the problems I can't really help as I had exactly 0 when rooting. everything worked as it was supposed to.

@GizmoLibre did you copy themes file? it looks to me like the theme is missing:-? I think it's the fact that it is not in a popup and has no background is what makes it look odd.
in order to prevent further offtopic discussions is is posted here

@majidmostafa
Copy link

Hi Guys,
Please I have an issue with my Dreame Vacuum D9 (dreame.vacuum.p2009) which is dead!! (No interaction, no light, no reaction, ...) before that I have switched my Mi Home account from Singapore to French ( because I wanted to link it with my Alexa :( )
It was fully charged and it have requested me to update the firmeware but after that I disovered that the robot is dead and I tried to reset it but no reaction. from that moment I can't do anything as it is fully Off and no signe of reactvitiy, is like the systeme has been erased or its Soft have been broken due to the firmeware update.
Can you please help me to resolve this issue?
For information, I installed the token extractor and I can see the Vaccum linked in my account Singapore and I can see also its token.
Many thanks for your help and support

@dgonneau
Copy link

Hi, Everyone,
I don't use HA and wondering how you guys manage to make the D9 work. Is there an additional stand-alone python package using miiocli that would work ?
Trying the "miiocli dreamevacuummiot" command were failing first but that was fixed by increasing the retry_count in device.py.
Now the commands reach the robot but they don't do what they should.
Start and home are reversed, well that's a start :)
Anyone knows how/where to add a proper dreame D9 support into miiocli ? (latest vers as of today : 0.5.8) ?
Thanks.

@pooyashahidi
Copy link
Contributor

That file is for Xiaomi C1, which has different commands.
Miiocli does not currently support D9 hence this issue. You can however write your own python app to control the D1 using python-miio like this.

I think instead of making many different files here, it would have been better to make a generic vacuum file and use different mappings and handle supported and unsupported features. Or have a generic file and use that for every device with minimal redundant code and so on.

@beliy1985
Copy link

Hi @need2buy, i ask for help, why it does not work:
rooms: [[ 'A', 2, 4, 3],[ 'B', 1, 2, 3]]
Repeats work,clean_mode,mop_mode does not work. Always values from the last group it is also applied to all rooms
Dream l10 pro

@spekkie3
Copy link

spekkie3 commented Oct 6, 2021

hi guys ,

move services.yaml to correct dir..

Can some one tell me were this is located ??

@dmitriypo1989
Copy link

dmitriypo1989 commented Dec 25, 2021

Hi everyone! Does anybody have D9 max (p2259)? I add him to HA, but his picture is not so good, such as state of his sensors
2021-12-26_02-16-18
.

@DirkStorck
Copy link

I have a Dreame D9 and it does work with Home Assistant. Just follow a post from Hyyd1e here for support for F9, apparently this works for D9 too - https://community.home-assistant.io/t/support-for-xiaomi-dream-f9-mop-vacuum/220858/14 dreame d9

Hi,

I have tried the Xiaomi-cloud-tokens-extractor
and I am 99% sure that my credentials are right because I tried the at MI Could

but still I get
grafik

any ideas?

Thank you!

@DirkStorck
Copy link

DirkStorck commented Apr 10, 2022

Got it working now. Installed python on my Windows PC. Now I have the token. But den vacuum can't be really controlled and shows wrong number for battery etc.

@floreo
Copy link

floreo commented Oct 20, 2022

Hello,

the supported devices list claims that the Dreame D9 is supported but it's currently not working.

Its model name is dreame.vacuum.p2009.

Could you add its support to the official python-miio for Home Assistant ?

I used this old unmaintained repository to make it work but its support could drop anytime.

Feel free to ask me more details if needed !

Thanks.

P.S: @pooyashahidi thanks a lot for you work on your xiaomi_vacuum repository ! I don't know if you could port your repo to this one to support Dreame D9

@EtienneX
Copy link

Hi,

Are there scripts for the D9 Pro ?
I would like to change and add some futures by the vacuum. Example: Adding own voice file to it not the ones that are already in the app.

tnx.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.