Hi, room cleaning is already out a while, but i see, no one started on the google assistant component? so you can say like, hey google, can you vacuum the kitchen?
This “zone” trait is already supported for Google Assistant, now we can only use start/stop
yes, i know its possible to run scrips/switches to clean zone
But using the offcial google trait is native and you can speak more natural, instead of those predefined commands…
i hardcoded this zone trait already a while ago in the google_assistant , and loaded it as a custom component, but since i am using nabu casa now, i cant override it anymore as a custom
below is what i did, i didnt code it myself though…
i hardcoded the rooms/zones it in the google assistant component, but if its going to be official, i think something need to change also in the xiaomi module itself, so we can define those zones in some other place… or maybe with the template vacuum component
from homeassistant.components.xiaomi_miio import vacuum as vacuum_xiaomi
def sync_attributes(self):
"""Return StartStop attributes for a sync request."""
return {'pausable':
self.state.attributes.get(ATTR_SUPPORTED_FEATURES, 0)
& vacuum.SUPPORT_PAUSE != 0,
'availableZones':['kitchen', 'living room']}
async def execute(self, command, data, params):
"""Execute a StartStop command."""
if command == COMMAND_STARTSTOP:
if params['start']:
if params.get('zone') is not None:
ZONES = {
'kitchen': [14600,17800,20450,21700],
'living room': [25480,17400,29530,22250],
}
await self.hass.services.async_call(
self.state.domain, vacuum_xiaomi.SERVICE_CLEAN_ZONE, {
ATTR_ENTITY_ID: self.state.entity_id,
'zone': [ZONES[params['zone']]],
'repeats': 1
}, 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)
elif command == COMMAND_PAUSEUNPAUSE:
if params['pause']:
await self.hass.services.async_call(
self.state.domain, vacuum.SERVICE_PAUSE, {
ATTR_ENTITY_ID: self.state.entity_id
}, 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)