python-miio icon indicating copy to clipboard operation
python-miio copied to clipboard

Add support for Roborock Auto Empty Dock

Open andrey-yantsen opened this issue 3 years ago • 9 comments

Is your feature request related to a problem? Please describe. Recently, Roborock released their Auto Empty Dock for the S7 robot vacuum. It would be great if it were possible to control the dock using the library (at least — to be able to trigger the emptying cycle manually).

Describe the solution you'd like Ideally, I'd like to have a few extra methods in the vacuum-cli — empty, set_auto_empty_settings and get_auto_empty_settings. You can guess what they should do from their names :)

But to be honest, it would be just enough for me if somebody could advise how I can get the command the app uses to trigger emptying.

Device information: If the enhancement is device-specific, please include also the following information.

  • Name(s) of the device: Auto Empty Dock
  • Link: https://global.roborock.com/pages/roborock-auto-empty-dock

Use miiocli device --ip <ip address> --token <token>.

  • Model: roborock.vacuum.a15
  • Hardware version: Linux
  • Firmware version: 4.1.5_1196

Additional context

The dock itself doesn't connect to WiFi, seems like all the logic is done via the vacuum itself. I'll be happy to help with any required debugging.

P.S. I tried running tcpdump on my router, but unfortunately, I don't see any traffic on the UDP port 54321 between the vacuum and my iOS device.

andrey-yantsen avatar Aug 05 '21 12:08 andrey-yantsen

Found everything I needed in the Mi Home's plugin code.

First of all, to check whether the "auto empty dock" is available — FeatureManager.robotNewFeatures & 0x2000000. Then, to start the emptying process — app_start_collect_dust, and to abort it app_stop_collect_dust. If you just run it — it'll stop automatically in about 30 seconds.

To enable the automatic emptying call set_dust_collection_switch_status with {"status": 1}, and {"status": 0} to disable.

To change the emptying mode call set_dust_collection_mode with {"mode": ID}, and get_dust_collection_mode to get the current one.

There're 5 modes defined in the code, but only 4 available in the app:

  var DustCollectionModeSettingMap = {
    DustCollectionModeSmart: 0,
    DustCollectionModeQuick: 1,
    DustCollectionModeDaily: 2,
    DustCollectionModeStrong: 3, // <---- this one is not available in the app
    DustCollectionModeMax: 4
  };

andrey-yantsen avatar Aug 05 '21 22:08 andrey-yantsen

@andrey-yantsen glad you figured it out! Feel free to create a PR to add those commands to the vacuum class, if you wish :-)

rytilahti avatar Aug 11 '21 14:08 rytilahti

@andrey-yantsen thanks for finding all that, it was quite easy to add support

craigcabrey avatar Nov 28 '21 16:11 craigcabrey

Found everything I needed in the Mi Home's plugin code.

First of all, to check whether the "auto empty dock" is available — FeatureManager.robotNewFeatures & 0x2000000. Then, to start the emptying process — app_start_collect_dust, and to abort it app_stop_collect_dust. If you just run it — it'll stop automatically in about 30 seconds.

To enable the automatic emptying call set_dust_collection_switch_status with {"status": 1}, and {"status": 0} to disable.

To change the emptying mode call set_dust_collection_mode with {"mode": ID}, and get_dust_collection_mode to get the current one.

There're 5 modes defined in the code, but only 4 available in the app:

  var DustCollectionModeSettingMap = {
    DustCollectionModeSmart: 0,
    DustCollectionModeQuick: 1,
    DustCollectionModeDaily: 2,
    DustCollectionModeStrong: 3, // <---- this one is not available in the app
    DustCollectionModeMax: 4
  };

@andrey-yantsen Is the Mi Home app plugin code posted somewhere I can view? Thanks.

shred86 avatar Dec 12 '21 17:12 shred86

@shred86 not exactly. You can get the URL by sniffing the Mi Home traffic using mitmproxy or something similar.

andrey-yantsen avatar Dec 12 '21 17:12 andrey-yantsen

A bit more info on top of my previous comment:

  1. You need to run an HTTPS-proxy server (I'm using https://mitmproxy.org)
  2. Configure the proxy on a device with Mi Home
  3. Set the proxy's certificate to "always trust"
  4. Clear cache in the Mi Home app
  5. Open your vacuum in Mi Home app

After the last step, you'll see a request to an URL like https://cdn.alsgp0.fds.api.mi-img.com/rn-plugins/2021-09-29/signed_10059_1004367_63_IOS_bundle_38c7e26b118330452f2d68c1abe684ad.zip — that's the plugin. Inside you'll find a bunch of files, the most interesting of which is main.bundle. Just grep the hell out of it :)

andrey-yantsen avatar Dec 17 '21 20:12 andrey-yantsen

So how do you send this exactly with home assistant? Could you share the scripts / automations you use? I just received my s7 with emty dock today and i would love to automate it in home assistant.

Thanks in advance

sygys avatar Dec 28 '21 00:12 sygys

@sygys, you need to configure your vacuum using the Xiaomi Miio integration. After that, you will be able to use the vacuum.send_command service with the vacuum.

I'm using the following script:

alias: 'Vacuum: collect dust'
sequence:
  - service: vacuum.send_command
    target:
      entity_id: vacuum.roborock_vacuum_a15
    data:
      command: app_start_collect_dust
  - delay: 00:00:20
  - service: vacuum.send_command
    target:
      entity_id: vacuum.roborock_vacuum_a15
    data:
      command: app_stop_collect_dust
mode: single

(do not forget to replace vacuum.roborock_vacuum_a15 with the correct entity_id according to your setup)

andrey-yantsen avatar Dec 28 '21 10:12 andrey-yantsen

Wow didnt know that was possible too. Many thanks!! This is awsome!

sygys avatar Dec 29 '21 17:12 sygys

Thanks! This worked for my S7 Ultra as well. The ultra also has a self cleaning mop in the dock. Any idea what the command would be to tell the dock to clean the mop? Is there any way to find a list of commands?

petrusb83 avatar Jan 02 '23 14:01 petrusb83

@petrusb83, congrats on the great purchase :)

You can try following the instructions from my older comment — https://github.com/rytilahti/python-miio/issues/1107#issuecomment-997015096 and investigate the newer source code.

andrey-yantsen avatar Jan 02 '23 14:01 andrey-yantsen

Resolved with #1188

andrey-yantsen avatar Jan 15 '23 11:01 andrey-yantsen