diff --git a/custom_components/proscenic/vacuum.py b/custom_components/proscenic/vacuum.py index dc9819c..9868cb3 100644 --- a/custom_components/proscenic/vacuum.py +++ b/custom_components/proscenic/vacuum.py @@ -175,7 +175,7 @@ def fan_speed(self): @property def fan_speed_list(self): """Get the list of available fan speed steps of the vacuum cleaner.""" - return [1, 2] + return [] async def async_turn_on(self, **kwargs): """Turn the vacuum on and start cleaning.""" @@ -195,4 +195,7 @@ async def async_stop(self, **kwargs): @property def device_state_attributes(self): """Return the device-specific state attributes of this vacuum.""" - return {} \ No newline at end of file + return { + 'clear_area': self.device.last_clear_area, + 'clear_duration': (self.device.last_clear_duration // 60) + } \ No newline at end of file diff --git a/custom_components/proscenic/vacuum_proscenic.py b/custom_components/proscenic/vacuum_proscenic.py index eef4896..436cc21 100644 --- a/custom_components/proscenic/vacuum_proscenic.py +++ b/custom_components/proscenic/vacuum_proscenic.py @@ -23,6 +23,8 @@ def __init__(self, ip, auth, loop = None, config = {}): self.battery = None self.fan_speed = 2 self.work_state = WorkState.CHARGING + self.last_clear_area = None + self.last_clear_duration = None self.listner = [] self.loop = loop self.auth = auth @@ -160,8 +162,15 @@ async def _wait_for_map_input(self): if data: _LOGGER.info('receive map {}'.format(data)) json = self._extract_json(str.encode(data)) - if 'value' in json and 'map' in json['value']: - build_map(json['value']['map'], json['value']['track'], self.map_path) + if 'value' in json: + value = json['value'] + if 'map' in value: + build_map(value['map'], value['track'], self.map_path) + if 'clearArea' in value: + self.last_clear_area = value['clearArea'] + if 'clearTime' in value: + self.last_clear_duration = value['clearTime'] + self._call_listners() await asyncio.sleep(5) else: _LOGGER.debug('do not get the map. The vacuum is not cleaning. Waiting 30 seconds')