Help with zone cleaning parameters - Xiaomi vacuum

Hello guys! How are you today?

I was wondering if any of you could help me out with scripting a zone cleaning of Xiaomi Vacuum.

As you know, the last number, after the last comma, is the number of passes the vacuum should do on this coordinates:

[[23746,23540,25096,25240,1]]

So, I tough it would be nice to set this myself, before sending the parameter to the vacuum. The solution was supposed to be very simple: create an input_number from 1 to 3 and set the last digit of the parameter with the state of it, like this:

input_number:

  aspirador_passadas:
    name: Passadas
    initial: 1
    min: 1
    max: 3
    step: 1

script:

  aspirador_zona_sala_inteira:
    sequence:
    - service: vacuum.send_command
      data_template:
        entity_id: vacuum.aspirador
        command: app_zoned_clean
        params: [[22674,21998,26074,31348,{{ states.input_number.aspirador_passadas.state }}]]

That did not work. I get this error when checking config:

Error loading /config/configuration.yaml: invalid key: "OrderedDict([('states.input_number.aspirador_passadas.state', None)])"
  in "/config/includes/packages/xiaomi_vacuum.yaml", line 224, column 0

Any ideas how to fix this?

Thanks a lot!

A little progress has been made but still does not work:

  aspirador_zona_sala_inteira:
    sequence:
    - service: vacuum.send_command
      data_template:
        entity_id: vacuum.aspirador
        command: app_zoned_clean
        params: '[[22674,21998,26074,31348,{{ states("input_number.aspirador_passadas") }}]]'

Not sure why, by using the template like this shows no error on log.

The vacuum starts, gets out of the dock, turn around and says that the cleaning is done, then return do home. Maybe HA is passing the quotes to the vacuum, not sure…

Thanks!

probably it enters a 1.0 as the value. Try this:

params: '[[22674,21998,26074,31348,{{ states(“input_number.aspirador_passadas”) | int }}]]

1 Like

Great idea! Will try it. Thanks mate!

Sorry @AlmostSerious, it did not work.

Template editor shows that the coordinates are formatted correctly, like this:

'[[23746,23540,25096,25240,1]]'

I think there is problem with the quotes or the component itself, not sure…

My zone cleaning script does not have any quote at all:

  • service: vacuum.send_command
    data:
    entity_id: vacuum.mijia
    command: app_zoned_clean
    params: [[23000, 21800, 31600, 27600, 1]]

Yep! I had to use quotes because there are templating involved or else the config check shows error. Already tried without it. This passes template would be very useful!

image

Sorry, texts are in portuguese…

1 Like

Well… alternatively you could always just make extra scripts hardcoded with 1, 2 or 3 passes and simply select the correct one based on the input number.
Do you plan an letting it vacuum more than 1 pass regularly? I only use this feature for the mopping mode.

Yeah, I think that would be the easiest and reliable way of doing it. I’ve just tested again at home and the vacuum did not went to the zone.

May I ask you: are your zones coordinates consistent? Mine just rotated the map and lost everything… Is there a method or good practices for this problem? Just bought one, arrived 4 days ago, still learning.

Thanks!

@AlmostSerious: quick tip, discover this yesterday… If you want to set the vacuum to mop mode, just like the app, here is a script for that:

   aspirador_set_mop:
    sequence:
      service: vacuum.set_fan_speed
      data:
        entity_id: vacuum.aspirador
        fan_speed: 105

Fan speed 105… Very odd. You will se in the app that mop mode is selected.

Very cool!

2 Likes

Yes that will happen if the vacuum starts a new fresh cleaning job. Then it will relearn the map from scratch. It can happen that the map turns. Has something to do with the orientation of the base i believe. If you only do zoned cleanups this will not happen.
105 is correct and works fine for mopping. I actually have my vacuum under the couch and for mopping ill first let it come out to a coordinate. Then let it pause to add the mop and the continue the zoned mopping. A lot of nice stuff is possible with this little thing :slight_smile:

1 Like

Amazing machine indeed… Incredible how much technology they came up with in such a small package. So many sensors and AI.

About the map reset issue: have you tried to set just a huge box around your house so if you need a full cleanup just use this zone to reach all? Maybe this will avoid the start full cleanup command the map might not reset itself, since it is a zone.

Yes that works well.
Alternatively, you can do a zone for each room and let it clean all of them in one command.
I actually have both, one big zone for daily cleanup, and several room zones if i decide to let it clean one specific room or area only.

1 Like

Nice! Thanks for your tips…

Using only zones cleanups, are your zones coordinates and commands stable? No map resets?

If this map “module” works, we can finally ditch the app and go completely offline and use only HA. Very cool stuff!

Thanks!

Yes it works very well… just be sure that the base approximately keeps the same position and nobody presses the “Full Cleanup” on either HA or the Bot itself. Then its very stable!

Little tip for getting the coordinates:
Use the app Flolevac https://xiaomi.flole.de/
Simply paint your Zone or your Coordinate as you would within the MiHome App and then long press on start. It will copy the whole Code you need :slight_smile:

3 Likes

Very nice! Will do that.

I use this app too for copying the coordinates, very easy to use.

Thanks for your help!

How would be such a command to clean all zones in one ?

you could do it like this:

alias: "XYZ"
sequence:
  - service: vacuum.send_command
    data:
      entity_id: vacuum.xiaomi_vacuum_cleaner
      command: app_zoned_clean
      params: [[16708,20845,29958,32195,1],[22939,31583,24789,33983,1]]
1 Like

Just putting a comma in between will work? Nice shot! Will try this …or create a zone capturing all single zones

Do I have any idea how to template the amounts of cleaning an area? All tries failed and vacuum will return to station directly after starting cleaning