Xiaomi Vacuum Robot not moving

So I’ve connected the Xiaomi robot to HA and it’s working fine through the front-end and as a scheduled cleaning using automation. Now I want to write a custom script that turns the robot on and moves it straight forward for 10 seconds. I’ve tried two approaches but none of them worked.

Alternative 1:

vacuum_service_mode:
  alias: "Kör fram Gunhild för service"   
  sequence:
      - service: vacuum.xiaomi_remote_control_move_step
        entity_id: vacuum.gunhild
        data:
          velocity: 0.2 
          rotation: 0
          duration: 10

This will start the vacuum and make it run for 10 seconds but it will not MOVE.

Alternative 2:

vacuum_service_mode:
  alias: "Kör fram Gunhild för service"   
  sequence:
      - service: vacuum.xiaomi_remote_control_start
        entity_id: vacuum.gunhild
      - service: vacuum.xiaomi_remote_control_move
        entity_id: vacuum.gunhild
        data:
          velocity: 0.2 
          rotation: 0
          duration: 10
      - service: vacuum.xiaomi_remote_control_stop
        entity_id: vacuum.gunhild

This will start the vacuum but immediately stop it, so it seems it skips the MOVE step all in all.

Can anyone please tell me what I’m doing wrong here? There is nothing in the homeassistant.log file, are there any other logs to check?

The second variant send the command after each other, so it send the move command, and send the stop command right away.

You can try adding a delay in your sequence after the move command:

vacuum_service_mode:
  alias: "Kör fram Gunhild för service"   
  sequence:
      - service: vacuum.xiaomi_remote_control_start
        entity_id: vacuum.gunhild
      - service: vacuum.xiaomi_remote_control_move
        entity_id: vacuum.gunhild
        data:
          velocity: 0.2 
          rotation: 0
          duration: 10
      - delay:
        seconds: 10
      - service: vacuum.xiaomi_remote_control_stop
        entity_id: vacuum.gunhild

@touliloup Thanks for the suggestion! Unfortunately it didn’t help. Now it acts like alternative 1, meaning it stays on for 10 seconds before it turns off, but without actually moving anywhere.

I got a hunch that I need to update python-miio to 0.3.3 (I have 0.3.2). But I’m uncertain on how to do so.

This is what I use to move the vacuum straight out about three feet (I’m using AppDaemon though):

self.call_service("vacuum/xiaomi_remote_control_move_step",velocity=".2", duration="2300",rotation="0")

Tom

I guess the documentation is wrong and the duration is not in second but in millisecond, explaining why your robot just move for 10mS and stop.

Try with duration: 10000.

If you look at the source code, default value is 1500 for duration, which wouldn’t make sense if the value is in seconds (since every move would last 25 minutes ^^). This also appear in eBoon example with a duration of 2300.

@touliloup alright, that at least made a small difference. Using the alternative 1 above it now moves but there seems to be a limit of the duration around 10000 (or 9999) as it will not move than that, and it appears I need a couple more seconds…
Using alternative 2, running it as a sequence, it still skips the move step.

Interestingly enough, using the Home Assistant front-end, messing with the Services page I can get it to work by doing this manually:

  1. Calling vacuum.xiaomi_remote_control_start

  2. Calling vacuum.xiaomi_remote_control_move with the data:
    {
    “entity_id”: “vacuum.gunhild”,
    “duration”: 15000,
    “velocity”: 0.29,
    “rotation”: 0
    }

  3. Calling vacuum.xiaomi_remote_control_stop

Not sure how this differs from the script sequence above, more than the data being in JSON.

Did you try to increase the delay?
The delay need to be superior to the duration (+ 1/2 seconds for processing) to allow the command to finish before sending xiaomi_remote_control_stop

@touliloup This is what I have right now, not working:

vacuum_service_mode2:
  alias: "Kör fram Gunhild för service 2"   
  sequence:
      - service: vacuum.xiaomi_remote_control_start
        entity_id: vacuum.gunhild
      - delay:
          seconds: 5
      - service: vacuum.xiaomi_remote_control_move
        entity_id: vacuum.gunhild
        data:
          duration: 15000
          velocity: 0.2 
          rotation: 0
      - delay:
          seconds: 20
      - service: vacuum.xiaomi_remote_control_stop

Can you try this?:

vacuum_service_mode2:
  alias: "Kör fram Gunhild för service 2"   
  sequence:
      - service: vacuum.xiaomi_remote_control_move_step
        entity_id: vacuum.gunhild
        data:
          duration: 10000
          velocity: 0.2 
          rotation: 0

If you only have one vacuum, you may not even need the entity_id - I don’t use it for mine.

Tom

@eboon yes, I’ve tried that and got it working BUT there seems to be a limit of the duration parameter. No matter how high I set it, it max out at 10000 (or 9999 perhaps). I get the same result running it on the Service page in the front-end.

I finally got it working so I thought I’d answer my own thread for anyone else that might be interested.
There where two issues with my initial script. First, as @touliloup mentioned, the duration should be set in milliseconds even if the documentation says seconds. Secondly, you need to add different delays to allow the vacuum to be ready for the different steps in the sequence.

I never got xiaomi_remote_control_move_step to work as it seems to have a duration limit of 10 seconds (with or without delays set). However I got the xiaomi_remote_control_move method to work. This is my script now:

vacuum_service_mode:
  alias: "Kör fram Gunhild för service"
  sequence:
      - service: vacuum.xiaomi_remote_control_start
        entity_id: vacuum.gunhild
      - delay: '00:00:10' 
      - service: vacuum.xiaomi_remote_control_move
        entity_id: vacuum.gunhild
        data:
          duration: 12000
          velocity: 0.2
          rotation: 0
      - delay: '00:00:13'
      - service: vacuum.xiaomi_remote_control_stop

As you can see I had to set a 10 sec delay for the start command to finish. I also had to set a delay after the move command of one second more (just to be safe) before triggering stop.

Thanks @touliloup and @eBoon for you support!

5 Likes

Hi, I’m about to get one if these, I was wondering though why you would need to tell it to move out 3 feet, isn’t there just a simple trigger to tell it to start so it does everything automatically?

Thanks!

Well you see, I have it placed somewhat hidden and hard to reach and once a week I need to bring it out to empty the dust bin and remove hair from the brush. So this script allows me to bring it out just for that, ultimately with a voice command to the Google home mini (not there yet though :grin:)

1 Like

Exactly my same situation - it comes out from it’s hiding place!

Guys,

Is there way to monitor bin cleaning ?
I mean what attribute we can get when the bin need cleaning ?

Hmm, no, as far as I know there’s only attributes for the brushes, not the bin. Don’t even think that’s possible from the Xiamo app?

Alternativly, just send it the GoTo Coordinates like this:

sequence:
  - service: vacuum.send_command
    data:
      entity_id: vacuum.xiaomi_vacuum_cleaner
      command: app_goto_target
      params: [25250,23800]

Has anyone able to get the vacuum to respond to Google home voice commands. my roborock vacuum is working fine from the HA fron end by clicking on the Start cleaning link. However, I would like to have the control via google home. I am using ha cloud and have google home working for my other devices. the vacuum appears in google home device - home control list but it doesn’t respond to the commands.
Is the best way to set up an automation to run the HA service and then use google home to call that automation?

Or make a switch that calls a script when turned on, and sends the vacuum back to the dock when turned off. Then you can also cancel the current cleaning with Google Home :slight_smile: