Skip to content

Commit

Permalink
Merge e3e343a into 9692296
Browse files Browse the repository at this point in the history
  • Loading branch information
rytilahti committed Feb 2, 2019
2 parents 9692296 + e3e343a commit e5309c8
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions miio/vacuum.py
Expand Up @@ -189,9 +189,15 @@ def clean_history(self) -> CleaningSummary:
return CleaningSummary(self.send("get_clean_summary"))

@command()
def last_clean_details(self) -> CleaningDetails:
"""Return details from the last cleaning."""
last_clean_id = self.clean_history().ids.pop(0)
def last_clean_details(self) -> Optional[CleaningDetails]:
"""Return details from the last cleaning.
Returns None if there has been no cleanups."""
history = self.clean_history()
if not history.ids:
return None

last_clean_id = history.ids.pop(0)
return self.clean_details(last_clean_id, return_list=False)

@command(
Expand Down

0 comments on commit e5309c8

Please sign in to comment.