MIIO Binding - Execute RPC Command for Dreame D9

Hi All,

I bought a Dreame D9 robot vacuum cleaner, I assumed that it could be controlled exactly like a Roborock (because I think it has same software running on the device). Via the channel Execute RPC Command I start my Roborock and clean only selected rooms. Unfortunately, the channel shows on my Dreame D9 no reaction. Does anyone know if the Dreame D9 supports this channel, or what I can do to make this work? Otherwise, I would have to sell the robot again.

Many greetings,
Christian

I got some help from Marcel and was able to send commands. I can start the cleaning, but can not set properties, maybe a syntax error. Can someone please help me to check my command:

action {“did”:“start-room-sweep”,“siid”:2,“aiid”:3,“in”:[{“piid”:4,“value”:10}]}

SIID:2 = vacuum
AIID:3 = start-room-sweep
PIID:4 = room-id
VALUE:10 = Room ID

At a first glance it looks right.
If you are really stuck, you could use one of the hacked mihome apps that does logging of the commands (e.g. the vevs version) and check what command/parameters are exactly send to the vacuum by the regular app…

1 Like

I have no Android device, so I can‘t use these apps. I will sell my new D9 and switch to a roborock.

I have oerganized an android phone and installed Mi Home 5.9.19 (vevs & rezmus), but I did not find any option to do logging.

If I remember well, in the very old versions you needed to make (manually) a folder vevs on the sd

In the recent/current versions is no longer needed. The latest version did not work for me https://nl.kapiba.ru/mihome/files/old/MiHome_7.1.703_65404_vevs.apk (cannot logon) but
https://nl.kapiba.ru/mihome/files/old/MiHome_6.9.700_64604_vevs.apk did work

In these versions you go to ‘experimental options’ in the profile menu and enable ‘write custom log files’

1 Like

Thanks, I was able to get the logfile. To learn how to the read the file and get some understanding of the syntax I switched to the four modes (Silent, Basic, Strong and Full Speed) and found this in the logfile:

2022-02-13 00:02:58 -> {"id":7908,"method":"set_properties","params":[{"did":"447269189","siid":4,"piid":4,"value":0}]}
2022-02-13 00:02:58 <- {"code":0,"message":"ok","result":[{"siid":4,"did":"447269189","piid":4,"code":0}],"id":7908}
2022-02-13 00:03:00 -> {"id":7909,"method":"set_properties","params":[{"did":"447269189","siid":4,"piid":4,"value":1}]}
2022-02-13 00:03:00 <- {"code":0,"message":"ok","result":[{"siid":4,"did":"447269189","piid":4,"code":0}],"id":7909}
2022-02-13 00:03:04 -> {"id":7910,"method":"set_properties","params":[{"did":"447269189","siid":4,"piid":4,"value":2}]}
2022-02-13 00:03:04 <- {"code":0,"message":"ok","result":[{"siid":4,"did":"447269189","piid":4,"code":0}],"id":7910}
2022-02-13 00:03:05 -> {"id":7911,"method":"set_properties","params":[{"did":"447269189","siid":4,"piid":4,"value":3}]}
2022-02-13 00:03:05 <- {"code":0,"message":"ok","result":[{"siid":4,"did":"447269189","piid":4,"code":0}],"id":7911}

Than I tried to set the mode by openhab with this command:
set_properties {“did”:“447269189”,“siid”:4,“aiid”:4,“value”:0}
But nothing happens. Is my code wrong, or my understanding about how it works?

And that is maybe the part when I send the robot to clean a specific room:

{"id":5746,"method":"action","params":{"did":"447269189","siid":4,"aiid":1,"in":[{"piid":1,"value":18},{"piid":10,"value":"{\"selects\":[[6,1,0,1,1]]}"}]}}

ok, first step done, to set the mode, this command works:

set_properties[{"did":"SetMode","siid":4,"piid":4,"value":3}]

And here the command to clean one of my rooms:

action{"did":"CleanRoom","siid":4,"aiid":1,"in":[{"piid":1,"value":18},{"piid":10,"value":"{\"selects\":[[6,1,0,1,1]]}"}]}

I’m very happy now that it is working. Thank you very much @marcel_verpaalen for your help. Also I would like to help others who are in the same situation, so here are my learnings:

  • you need an Android device
  • you need an SD-Card in this device (it’s not working with the internal storage)
  • you need to setup the SD-Card in the Android settings with path “SD Card”, not internal
  • you need to install the modificated Mi Home App by Vevs (7.1.703.4475)
  • in the App, you need to enable logging Profile → Experimental Features → write custom log files

Because I have security concerns about the modificated App, I will reset the Android Device and my Mi Home password when the work is done. Here are some of the commands:

Set mode (silent, basic, strong, full speed):

set_properties[{"did":"SetMode","siid":4,"piid":4,"value":0}]
set_properties[{"did":"SetMode","siid":4,"piid":4,"value":1}]
set_properties[{"did":"SetMode","siid":4,"piid":4,"value":2}]
set_properties[{"did":"SetMode","siid":4,"piid":4,"value":3}]

Clean a single room:

action{"did":"CleanRoom","siid":4,"aiid":1,"in":[{"piid":1,"value":18},{"piid":10,"value":"{\"selects\":[[6,1,0,1,1]]}"}]}

In the above command, this part is where the room is selected: [[6,1,0,1,1]]. This first number, in this example the 6, is the room. In the Mi Home App, the rooms in the Dreame map has no numbers, they are designated with letters. Room A is 1, room B is 2, room C is 3, and so on.

Clean multiple rooms:

action{"did":"CleanRoom","siid":4,"aiid":1,"in":[{"piid":1,"value":18},{"piid":10,"value":"{\"selects\":[[6,1,0,1,1],[6,1,0,1,2],[3,1,0,1,3]]}"}]} 

Hope that will help others with a dreame.

2 Likes

Hey, thanks for your work. Unfortunately I’m a bit confused since my Dreame D9 does not show any reaction (while my Roborock works well).

Are you sending the command like this?

val text = "action {\“did\”:\“start-room-sweep\”,\“siid\”:2,\“aiid\”:3,\“in\”:[{\“piid\”:4,\“value\”:10}]}"
C_Vacuum_rpcCommand.sendCommand(text)

My itenm definition is

String         C_Vacuum_rpcCommand {channel="miio:generic:(ID):actions#rpc"}

Cheers,
Snueffel88

I found an issue - obviously the first command uses a different ", this is why it was not parsed correctly.

However, I changed the command accordingly to:

val text = "action{\"did\":\"CleanRoom\",\"siid\":4,\"aiid\":1,\"in\":[{\"piid\":1,\"value\":18},{\"piid\":10,\"value\":\"{\"selects\":[[6,1,0,1,1]]}\"}]}"

Unfortunately my log now says:

[ERROR] [nal.common.AbstractInvocationHandler] - An error occurred while calling method 'ThingHandler.handleCommand()' on 'org.openhab.binding.miio.internal.handler.MiIoBasicHandler@119d9a2': com.google.gson.stream.MalformedJsonException: Unterminated object at line 1 column 89 path $.in[1].value

Any Idea whats the problem here?

this is my blocky rule, hope it can help you:

if (itemRegistry.getItem('SwitchVacuumDoneToday').getState() == 'OFF') {
  events.sendCommand('Paul_ExecuteRPCcloudCommand', 'app_start');
  events.sendCommand('Paul_ExecuteRPCcloudCommand', 'set_custom_mode[103]');
  events.sendCommand('Paul_ExecuteRPCcloudCommand', 'set_water_box_custom_mode[200]');
  events.sendCommand('Oskar_ExecuteRPCcloudCommand', 'action{"did":"CleanRoom","siid":4,"aiid":1,"in":[{"piid":1,"value":18},{"piid":10,"value":"{\\"selects\\":[[5,1,0,1,1],[6,1,0,1,2],[3,1,0,1,3]]}"}]}');
  events.sendCommand('Oskar_ExecuteRPCcloudCommand', 'set_properties[{"did":"SetMode","siid":4,"piid":4,"value":3}]');
  events.sendCommand('SwitchVacuumDoneToday', 'ON');
} else {
  events.sendCommand('Paul_ExecuteRPCcloudCommand', 'app_segment_clean[17]');
  events.sendCommand('Paul_ExecuteRPCcloudCommand', 'set_custom_mode[103]');
  events.sendCommand('Paul_ExecuteRPCcloudCommand', 'set_water_box_custom_mode[200]');
  events.sendCommand('Oskar_ExecuteRPCcloudCommand', 'set_custom_mode[103]');

glancing your json looks like you are having a " too much (the one 4 positions from the end)