Skip to content

Commit

Permalink
feat: Add clean area and clear duration
Browse files Browse the repository at this point in the history
  • Loading branch information
deblockt committed Jun 12, 2020
1 parent 4069f77 commit 14c9263
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
7 changes: 5 additions & 2 deletions custom_components/proscenic/vacuum.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
Expand All @@ -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 {}
return {
'clear_area': self.device.last_clear_area,
'clear_duration': (self.device.last_clear_duration // 60)
}
13 changes: 11 additions & 2 deletions custom_components/proscenic/vacuum_proscenic.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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')
Expand Down

0 comments on commit 14c9263

Please sign in to comment.