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/trait.py:
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) )
else:
zones.append( VACUUM_ROOMS.get(params["zone"]) )
await self.hass.services.async_call(
'xiaomi_miio',
'vacuum_clean_segment',
{
ATTR_ENTITY_ID: self.state.entity_id,
'segments': zones
},
blocking=True,
context=data.context,
)
else:
await self.hass.services.async_call(
self.state.domain,
vacuum.SERVICE_START,
{ATTR_ENTITY_ID: self.state.entity_id},
blocking=True,
context=data.context,
)
else:
await self.hass.services.async_call(
self.state.domain,
vacuum.SERVICE_STOP,
{ATTR_ENTITY_ID: self.state.entity_id},
blocking=True,
context=data.context,
)
...
Where I call the service xiaomi_miio.vacuum_clean_segment should be vacuum.clean_zones