Closed wilhelmphilipp94 closed 1 year ago
Where did you find a p2008 build ? I only know of fork https://github.com/rytilahti/python-miio/pull/683 which implements basic functionnality for mc1808 (Xiaomi 1C).
You can easily modify it by changing all IDs to the ones corresponding to the F9 using the devtools (use type urn:miot-spec-v2:device:vacuum:0000A006:dreame-p2008:1
).
I managed to control most of the vacuum using this technique, however I am still looking for a way to upload custom voice packs.
I did find a set-voice
property (siid 7, piid 4) which is write only, but I have no idea how to use it.
What setup do you use to make Wireshark captures ? I can't seem to get anything using MEmu or Bluestacks
Sorry my mistake! I used the #683 fork with the basic functionality for mc1808. I use Bluestacks and install the Xiaomi App there. (PC on the same Network as the vaccum)
Than I'm capturing with Wireshark (Filter: UDP and your Robot IP). (My Pc is connected via Lan so I choose the LAN-Adapter) After that i export the Capture as a JSON file and use Miio from (https://github.com/aholstenson/miio/blob/master/docs/protocol.md) to look at the data.
If u want i can take some pictures. Just tell me which part of the setup u want to see.
You can easily modify it by changing all IDs to the ones corresponding to the F9 using the devtools (use type urn:miot-spec-v2:device:vacuum:0000A006:dreame-p2008:1).
I'm unfamiliar with this (Devtools) could u point me in the right direction?
Weird, I can't seem to be able to communicate with the vaccuum using Bluestacks...
I was trying to see what is sent when applying a different voice pack through the app to understand how the set-voice
property works (the 1C does this through an action, not a property, so I can't just mimick the code from the fork). My final goal is to be able to send over custom voice packs and get some Mario 64 sounds going on 😎
I'd be so glad if you could get a capture of that !
I'm unfamiliar with this (Devtools) could u point me in the right direction?
No problem, you just have to navigate to the devtools folder and do the following :
urn:miot-spec-v2:device:vacuum:0000A006:dreame-p2008:1
)python3 miottemplate.py download [device type]
, this will download a .json file containing all the definition for the F9's services, actions, properties, etc. You can either format it with a Notepad++ plugin and explore it, or do the next step to generate some pseudo-Python codepython3 miottemplate.py generate [downloaded file name] >> [whatever].py
Personally, I find going through the .json file much easier to understand how the vacuum works, rather than reading the generated Python code.
Here you go: https://textuploader.com/1p09d I captured the change from German to English and reverse. But I'm unsure. It seems it has to download it first...
Tell me if it's Ok or if i should capture a second one
Oh my god yes that's perfect, I could extract the exact string that's needed to make the robot download the voice pack using set-voice
! Here it is :
"{\"id\":\"DE\",\"url\":\"https:\/\/awsde0.fds.api.xiaomi.com\/dreame-product\/dreame.vacuum.p2008\/voices\/package\/deyu.tar.gz\",\"md5\":\"96ab843008bb4d19480ac8a07d648aa7\",\"size\":1391385}"
Looks like it requires the language ID ("DE", "EN", etc), the voice pack URL (this is for the German pack), MD5 hash and size in bytes. The .tar.gz file just contains .ogg audio files with numbers as names. So in theory, anyone can just make their custom pack, host it somewhere and have the vacuum download and apply it !
Thanks for your help 😄 If that's okay, do you think you could do another capture when switching to French just so that I can get the pack URL please ?
Oh and also, I'm still trying to figure some things out with the F9 implementation but don't hesitate to ask me questions ! If I go far enough, I might make a PR to resolve this issue, but no promises
Sorry for the late reply (Work + Master thesis).
This should be it? -> 192.168.1.135 data= {"id":6691,"method":"set_properties","params":[{"did":"
Oh and also, I'm still trying to figure some things out with the F9 implementation but don't hesitate to ask me questions ! If I go far enough, I might make a PR to resolve this issue, but no promises
Oh thank you :) Will do!
Do you think it's possible to get the map data? I want to display it at my Home automation hub (Openhab2)
If I have time tonight i will try your example with the Devtools!
It's all good, thanks ! I have all the voice pack URLs thanks to the .json file posted by @rezmus.
Well, it seems to be stored on the vacuum and the app loads it from it so I guess so.
I do see a map-data
property (siid 6, piid 1), so maybe this is it ? I'll try to do some digging when I have the time !
I'm noticing something weird with the EN voice, the URL clearly indicates that it's downloading from the 1C's packs, and it doesn't sound like the English voice that comes pre-installed with the vacuum. Does anyone know the URL to the "real" F9 English voice pack ? I'm really not liking the 1C voice
...well thanks 😆 How did you find that one ?
Hey, sooo I finally got around to making a simple implementation with just enough functionnality to use in Home Assistant using this integration and this card.
I even modified the install_voice_pack
function to upload a custom file ! You just need to specify the URL, MD5 hash and size in bytes and you're good to go. You may also need to change the did
to match your robot's.
And one last thing, I couldn't find any equivalent action for the find
function (and I don't even know what it's supposed to do tbh), so for now I just play audio.
Enjoy ! dreamevacuum.zip
How can we integrate the p2008 device ?
Hey @mickabrig7 @wilhelmphilipp94 ;-) So you have now most functions of your Dreame F9 working with Home Assistant? Without changing the firmware, right? Im totally new to this, but do you still need the Xiaomi App and a Internet-Connection to controll the robot or can you "lock" the cloud access?
Hey @mickabrig7 @wilhelmphilipp94 ;-) So you have now most functions of your Dreame F9 working with Home Assistant? Without changing the firmware, right? Im totally new to this, but do you still need the Xiaomi App and a Internet-Connection to controll the robot or can you "lock" the cloud access?
Sadly, no locking-out of the Xiaomi cloud yet as the stock firmware is still running on the robot, we're just using the same protocol as Xiaomi's app to send actions through Home Assistant.
This would be possible when the device becomes rootable and Valetudo is updated to support it, but not for now...
Hey @mickabrig7 @wilhelmphilipp94 ;-) So you have now most functions of your Dreame F9 working with Home Assistant? Without changing the firmware, right? Im totally new to this, but do you still need the Xiaomi App and a Internet-Connection to controll the robot or can you "lock" the cloud access?
Sadly, no locking-out of the Xiaomi cloud yet as the stock firmware is still running on the robot, we're just using the same protocol as Xiaomi's app to send actions through Home Assistant.
This would be possible when the device becomes rootable and Valetudo is updated to support it, but not for now...
Thx for the fast answer! Really sad :-( ... and when the robot looses internet connection (i.e. blocked by router) i guess it stops working currently, right?
Hey @mickabrig7 @wilhelmphilipp94 ;-) So you have now most functions of your Dreame F9 working with Home Assistant? Without changing the firmware, right? Im totally new to this, but do you still need the Xiaomi App and a Internet-Connection to controll the robot or can you "lock" the cloud access?
Sadly, no locking-out of the Xiaomi cloud yet as the stock firmware is still running on the robot, we're just using the same protocol as Xiaomi's app to send actions through Home Assistant.
This would be possible when the device becomes rootable and Valetudo is updated to support it, but not for now...
Thx for the fast answer! Really sad :-( ... and when the robot looses internet connection (i.e. blocked by router) i guess it stops working currently, righ ?
I'm not sure, it may work actually ! I couldn't try it because my router doesn't allow me to filter Internet access of certain MAC addresses, but please keep me informed
Thx for the fast answer! Really sad :-( ... and when the robot looses internet connection (i.e. blocked by router) i guess it stops working currently, righ ?
I'm not sure, it may work actually ! I couldn't try it because my router doesn't allow me to filter Internet access of certain MAC addresses, but please keep me informed
I would love to, but I havent bought the F9 yet as I first wanted to be sure to be able to kill the cloud-connection (until valetudo is available). Maybe you can use the child-protection to test it? Or a guest-feature? If you tell me which router you have ill try to find out if it is somehow possible ;-) Edit: Or simply pull the cable/turn off internet completely for a while? If possible ...
@wilhelmphilipp94 or maybe you can try that?
thx for your work, I just modified your code in dreamevacuum.py so that "find my robot" in HASS performs an voice file upload an it worked like a charm. i had to genere .oog files in mono with 16000 Sample Rate an 56000 bitrate and vorbis encoding, so my F9 can play individual sounds.
Hi everyone. Thx for you work. I'm trying to figure out how I can move the F9 to a specific zone. But I didn't achieve to get the command work with the miottemplate.py. Did someone know what are the siid and the aiid values to perform this action?
Yeah I managed to work out that command and it works pretty well. You can see how I implemented it in my repo.
def zone_cleanup(self, coords) -> None:
"""Start zone cleaning."""
payload = [{"piid": 1, "value": 19},{"piid": 10, "value": coords}]
return self.call_action(4, 1, payload)
I already check and integrated your work in my HA. Great job by the way. And Yes the zone cleanup is working great but what I'm trying to do is to tell the robot to just move forward and stop. My charging station is under a cabinet and I want to add a button to HA to move the robot forward so I can clean it.
I tried to get the informations needed but I don't manage to retrieve the Json file like describe
- Find the type for the device you want to implement on here (for the F9, it's
urn:miot-spec-v2:device:vacuum:0000A006:dreame-p2008:1
)python3 miottemplate.py download [device type]
, this will download a .json file containing all the definition for the F9's services, actions, properties, etc. You can either format it with a Notepad++ plugin and explore it, or do the next step to generate some pseudo-Python codepython3 miottemplate.py generate [downloaded file name] >> [whatever].py
@microfrost1 in this repo https://github.com/Concentricc/xiaomi_vacuum the dev manage to add a remote function
Hi @pedro2d10, I can only see the zone cleaning service in that repo. Am I missing it?
I actually have the same use case as mine charges under the bottom step of the stairs out of view. I've planned to incoporate the forward command in the remote. From the app it triggers the vacuum to reverse about 50cm and turn around which I hope would work for you. It should be quite simple to implement when I can find the time.
In the file custom_components/xiaomi_vacuum/miio/dreamevacuum.py line 348
`# siid 21: (remote): 2 props, 3 actions
@command()
def start_remote(self) -> None:
"""aiid 1 start-remote: in: [1, 2] -> out: []"""
return self.call_action(21, 1)
# aiid 2 stop-remote: in: [] -> out: []
@command()
def stop_remote(self) -> None:
"""aiid 2 stop-remote: in: [] -> out: []"""
return self.call_action(21, 2)
# aiid 3 exit-remote: in: [] -> out: []
@command()
def exit_remote(self) -> None:
"""aiid 3 exit-remote: in: [] -> out: []"""
return self.call_action(21, 3)`
@pedro2d10 I see. I think those definitions were auto generated when using the miot spec converter. The complete calls would still need to be identified. In the case of our p2008 (https://miot-spec.org/miot-spec-v2/instance?type=urn:miot-spec-v2:device:vacuum:0000A006:dreame-p2008:1) the start-remote, stop-remote, exit-remote definitions aren't there so assuming local execution is fine, they need to be sniffed. It's something I've been meaning to spend some time on for a while.
remote for p2008 (set_properties to 4/15).
_this.sendRemoteCtrl = function (touchId) {
var v = 0;
var wv = 0;
if (touchId == 1) {
v = 300;
wv = 0;
} else if (touchId == 2) {
v = 0;
wv = 120;
} else if (touchId == 3) {
v = 0;
wv = -120;
} else if (touchId == 0) {
v = 0;
wv = 0;
} else {
return;
}
var random = Math.floor(Math.random() * 1000);
var params = {
spdv: v,
spdw: wv,
audio: _this.audio,
random: random
};
_this.audio = "false";
if (!_this.isLocalNet) {
_miot.Device.getDeviceWifi().callMethod("set_properties", [{
"did": _miot.Device.deviceID,
"siid": VacuumExtend.SIID,
"piid": VacuumExtend.PIID.remoteState,
"value": JSON.stringify(params)
}]).then(function (res) {}).catch(function (err) {});
} else {
_miot.Device.getDeviceWifi().callMethodFromLocal("set_properties", [{
"did": _miot.Device.deviceID,
"siid": VacuumExtend.SIID,
"piid": VacuumExtend.PIID.remoteState,
"value": JSON.stringify(params)
}]).then(function (res) {}).catch(function (err) {
_this.isLocalNet = false;
});
}
};
@rezmus my understanting of this is we need to set the robot to propertie 4/15 so we can write the remote-state.
Did you know how this can be implemeted in the microfrost1's custom intergration?
@pedro2d10, I have commited what I'm testing locally which appears to work well although my robot has a different idea what 90 degrees is. I'll test further when I have more time.
@rezmus thanks for the info, saved me a fair bit of time! Is that code from a public integration that we can reference?
@microfrost1 You're the best! How did you call the service? I tried this but without any luck:
service: xiaomi_vacuum.vacuum_remote_control_move_step
data:
entity_id: vacuum.thor
velocity: 100
rotation: 0
@microfrost1 code is from original f9 rn plugin from mi home ;)
@microfrost1 You're the best! How did you call the service? I tried this but without any luck:
service: xiaomi_vacuum.vacuum_remote_control_move_step data: entity_id: vacuum.thor velocity: 100 rotation: 0
My fault, I rushed the commit. Confident it should work know however I haven't tested much.
guys, with a Dreame F9 here? i have issues that he sometimes starts 45° rotated, you guys seeing it too? making the cleanup taking 20 min longers, and sometimes he then needs to recharge :
Good start = https://www.dropbox.com/s/ctyoo25jzzry7ar/xiaomi.mp4?dl=0 Bad start = https://www.dropbox.com/s/zzp60vl69w83qya/xiaomi2.mp4?dl=0
On a good start, when I start cleaning, it goes back from the charging station, then rotates like 180° todo some calibration You can clearly see on the second video, it doesn’t rotate the full 180° , more like 135° instead, so that’s why he starts cleaning wrong, like 45° shifted
guys, with a Dreame F9 here? i have issues that he sometimes starts 45° rotated, you guys seeing it too? making the cleanup taking 20 min longers, and sometimes he then needs to recharge :
Good start = https://www.dropbox.com/s/ctyoo25jzzry7ar/xiaomi.mp4?dl=0 Bad start = https://www.dropbox.com/s/zzp60vl69w83qya/xiaomi2.mp4?dl=0
On a good start, when I start cleaning, it goes back from the charging station, then rotates like 180° todo some calibration You can clearly see on the second video, it doesn’t rotate the full 180° , more like 135° instead, so that’s why he starts cleaning wrong, like 45° shifted
Hello! Actually my Dreame F9 cleanes at 45°, but I think it is because I put the base on a wall which is at 45°/135° with the other walls of my home... This doesn't seem your case. Anyway, I see that your map has the single rooms divided by colors (and letters). How did you manage to do so? The map of my whole apartment is identified as a single zone (A), with a single color and I don't know how to separate the single zones (kitchen, living room, bedroom, bathroom, ...). Thank you!
you need to turn on "map saving beta" feature, afterwards if you let it make a full clean for 3 times, it saves a map that you can edit then
you need to turn on "map saving beta" feature, afterwards if you let it make a full clean for 3 times, it saves a map that you can edit then
Thank you. Yes, I activated the Map Saving feature. But I did only one full clean. This is my current situation: Anyway, when you say
it saves a map that you can edit then
you mean that afterwards, I will be able to see some funcionalities that let me separate rooms and adjust walls that the robot hasn't recognised? Thank you!
you need to click on ths button, then you can edit the map, it will also recogniez the rooms automaticly
@pergolafabio Thank you. Actually, from that button I cannot separate rooms, but only:
i cant seperate either, the app did it for me, i think it just recognized it for me automaticly :
Maybe is a most stupid question but how to use a _install_voicepack?
I have ready file en.tar.gz and modified dreamevacuum in my coustom component directory. But I don't know how to fire install_voice_pack command ?
[edited]
Ok did it. Manually added dreamevacuum.py to init.py and use miiocli dreamevacuum --ip 192.168.22.177 --token
@microfrost1 and @pedro2d10 did you manage to move the robot from under the cabinet? I tried to call
service: xiaomi_vacuum.vacuum_remote_control_move_step
data:
entity_id: vacuum.dreame_f9
velocity: 100
rotation: 90
but the robot doesn't move from the dock at all. normal commands work. (I'm using the microfrost1 repo in HACS)
@PulsarFX Yes, it works from my side. Here the script I use
- service: xiaomi_vacuum.vacuum_remote_control_move_step data: entity_id: vacuum.thor velocity: 0 rotation: 0
Hm, that's the same I use. May it be because of this warning?
[homeassistant.helpers.service] Unable to find services.yaml for the xiaomi_vacuum integration
edit: https://github.com/microfrost1/xiaomi_vacuum/issues/11
I don't think so, I also have this error in my home assistance.
Did you tried with velocity and rotation at 0?
yes, doesn't move. What model is thor? with the services.yaml this is what I see:
with the latest firmware 3.5.8_1050 it actually does respond :)
note: for me 90° is 63.75 (64) which is 4 * 63.75 = 255 which is 1111 1111 for velocity 100 = 15cm slow (-100 reverse) 200 = 30cm fast 300 = 45cm max
Hello, I'm writing to you because my hoover (dreame vacuum p2008 v3.5.8_1050) is no longer responding (IP ok and Token ok)
I have an error message:
Would you know where the problem could be coming from? I'm not sure what the problem is. Every time I uninclude the vacuum from xiaomi home, then add it back (change token), one or two info/actions work, then error message
[This message is translated]
Before submitting a new request, use the search to see if there is an existing issue for the device.
Device information:
Use
miiocli dreamevacuum --ip <ip address> --token <token>
.dreame.vacuum.p1808 dreame.vacuum.p2008 return_home ---> Start Cleanup aiid 1 Start Charge: in: [] -> out: [] start_sweep ---> Return to Docking Station aiid 1 Start Sweep: in: [] -> out: []
Additional context I used the dreame.vacuum.p2008 build. Tested some commands and found that i can start a cleanup with the "return_home" command and return the robot to the docking station with "start_sweep"
Additionally i listend with wireshark while using the Xiaomi Home App. Here is the log: https://textuploader.com/1f3wm There should be "Start Cleanups" and Return to docking station commands