diff --git a/miio/vacuum.py b/miio/vacuum.py index a759d878e..2442b0fad 100644 --- a/miio/vacuum.py +++ b/miio/vacuum.py @@ -275,9 +275,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(