Vacuum Entity To Support Zones

May I propse that the vacuum entity support Zones?

With this in mind, I would suggest that a const SUPPORT_ZONES should be added with the zone names as a list in ATTR_ZONES for the entity. Next step would be to implement a vacuum.clean_zones service that would work like xiaomi_miio.vacuum_clean_zone or xiaomi_miio.vacuum_clean_segement with the zones being an optional list for those inegrations that can support multiple zones in one command.

With this feature in place, then it will give vacuum integrations a bit more flexibility when it comes to zone/segment cleaning. Further more, when this is implemented as a standard, then integrations like google_assistant can make use of this feature and allow our google assistants to do room cleaning on the startstop trait.

currently for this to work in my setup, I had to override google_assistant/

    def sync_attributes(self):
        """Return StartStop attributes for a sync request."""
        domain = self.state.domain
        if domain == vacuum.DOMAIN:
            return {
                "pausable": self.state.attributes.get(ATTR_SUPPORTED_FEATURES, 0) & vacuum.SUPPORT_PAUSE != 0,
                "availableZones": list(VACUUM_ROOMS.keys())
        if domain == cover.DOMAIN:
            return {}

NOTE: where VACUUM_ROOMS.keys() is, is where it should check ATTR_ZONES instead.

    async def _execute_vacuum(self, command, data, params, challenge):
        """Execute a StartStop command."""
        if command == COMMAND_STARTSTOP:
            if params["start"]:
                if "zone" in params or "multipleZones" in params:
                    zones = []
                    if "multipleZones" in params:
                        for zone in params["multipleZones"]:
                            zones.append( VACUUM_ROOMS.get(zone) )
                        zones.append( VACUUM_ROOMS.get(params["zone"]) )

                            ATTR_ENTITY_ID: self.state.entity_id,
                            'segments': zones
                        {ATTR_ENTITY_ID: self.state.entity_id},
                    {ATTR_ENTITY_ID: self.state.entity_id},

Where I call the service xiaomi_miio.vacuum_clean_segment should be vacuum.clean_zones

hi, i was interested in this too
are you aware of an official integration?

meanwhile i have found this :

My custom code has worked since I made it so I haven’t hunted for anything else, Just prefer that home assistant did it built in

1 Like

Just looked at the link you shared and I can’t say I’m a fan of the implementation. Seems very hacky

You can view my YouTube video in how I acheived it.

ok, ill have a look

why tou are not creating a PR for this?

btw, how are you retrieving the zone/coordinates anyway? I mean, how does google know the zones?

i now have template switches for each zone defined, so i expose the switches to GA

Simply because it relies on modifying the attributes which isn’t a home assistant standard.

The Roborock 6 has rooms within the FW which the home assistant has a service for clean by room which you pass the room id

yeah, i’m already using the service to clean rooms or coordinates
But what i dont understand, how do you publish those zones to GA so it can be used with the start/stop trait? you also need to specifiy a “name” right? so you can say like, hi google clean the kitchen

my roborock doesnt support names it seems :frowning: , my dreame vacuum does

The trait that I’ve implemented as also shown in the YouTube video takes care of that. The trait code is the middle man between vacuum and google. Doesn’t matter what the vacuum supports by itself, it home assistant who’s controlling and talking to both google and vacuum cleaner. So the trait is sending the names… when a room is called from Google then the code interperates the room then calls the service for the vacuum using the id for that room (or zones if your cleaner doesn’t support rooms)

ok, will watch the video first when i have some time, thnx for posting :slight_smile: