Xiaomi Vacuum as segment cleaning switch in HomeKit

Hello everyone,

I want a switch in HomeKit and Lovelace that turns on my vacuum cleaner for two specific rooms.

For this purpose I have entered the following in my configuration.yaml:

 auto_start: true
  include_entities: # Nur die Geräte in Homekit anzeigen, die hier aufgelistete sind
   - vacuum.xiaomi_vacuum_cleaner
   - ???.clean_kitchen_livingroom

  - platform: template
            entity_id: vacuum.xiaomi_vacuum_cleaner
            service: xiaomi_miio.vacuum_clean_segment
                - 16 # Wohnzimmer
                - 17 # Küchen
          service: vacuum.return_to_base
            entity_id: vacuum.xiaomi_vacuum_cleaner

How is it done right?

Many thanks to those who help.
Greeting Tristan

I am quite late to the game, but I did exactly what you described, just somewhat different:

  • Create Scripts that load specific maps (ground floor and first floor)
  • Create binary sensors that react on the last loaded map
  • Create Scripts that start cleaning for a certain area after loading the necessary map if not already loaded
  • My scripts usually wait for the vacuum changing from “cleaning” to not (“cleaning” or “paused”). This leaves the button active until the cleaning is complete (however, it does not work perfectly with chained button presses)…

I exposed all scripts over the Homekit integration (done with the config UI, no yaml) and they appear as buttons. In Homekit you also can create custom scenes that activate a given script switch and use the scene name as kind of activation word, so I now can say something like “Hey Siri, the kitchen is dirty” and this in turn activates the vacuum and sends it to the kitchen.