Skip to content

Commit

Permalink
Add last clean times to xiaomi vacuum (#19043)
Browse files Browse the repository at this point in the history
  • Loading branch information
rytilahti authored and syssi committed Dec 5, 2018
1 parent da0542e commit bc69309
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions homeassistant/components/vacuum/xiaomi_miio.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@
'Turbo': 77,
'Max': 90}

ATTR_CLEAN_START = 'clean_start'
ATTR_CLEAN_STOP = 'clean_stop'
ATTR_CLEANING_TIME = 'cleaning_time'
ATTR_DO_NOT_DISTURB = 'do_not_disturb'
ATTR_DO_NOT_DISTURB_START = 'do_not_disturb_start'
Expand Down Expand Up @@ -169,6 +171,7 @@ def __init__(self, name, vacuum):
self.consumable_state = None
self.clean_history = None
self.dnd_state = None
self.last_clean = None

@property
def name(self):
Expand Down Expand Up @@ -248,6 +251,10 @@ def device_state_attributes(self):
ATTR_STATUS: str(self.vacuum_state.state)
})

if self.last_clean:
attrs[ATTR_CLEAN_START] = self.last_clean.start
attrs[ATTR_CLEAN_STOP] = self.last_clean.end

if self.vacuum_state.got_error:
attrs[ATTR_ERROR] = self.vacuum_state.error
return attrs
Expand Down Expand Up @@ -368,6 +375,7 @@ def update(self):

self.consumable_state = self._vacuum.consumable_status()
self.clean_history = self._vacuum.clean_history()
self.last_clean = self._vacuum.last_clean_details()
self.dnd_state = self._vacuum.dnd_status()

self._available = True
Expand Down

0 comments on commit bc69309

Please sign in to comment.