Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions miio/tests/test_vacuum.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,9 +233,9 @@ def test_history_details(self):
"send",
return_value=[[1488347071, 1488347123, 16, 0, 0, 0]],
):
assert self.device.clean_details(
123123, return_list=False
).duration == datetime.timedelta(seconds=16)
assert self.device.clean_details(123123).duration == datetime.timedelta(
seconds=16
)

def test_history_details_dict(self):
with patch.object(
Expand All @@ -256,9 +256,9 @@ def test_history_details_dict(self):
}
],
):
assert self.device.clean_details(
123123, return_list=False
).duration == datetime.timedelta(seconds=950)
assert self.device.clean_details(123123).duration == datetime.timedelta(
seconds=950
)

def test_history_empty(self):
with patch.object(
Expand Down
21 changes: 3 additions & 18 deletions miio/vacuum.py
Original file line number Diff line number Diff line change
Expand Up @@ -406,36 +406,21 @@ def last_clean_details(self) -> Optional[CleaningDetails]:
return None

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

@command(
click.argument("id_", type=int, metavar="ID"),
click.argument("return_list", type=bool, default=False),
)
def clean_details(
self, id_: int, return_list=True
self, id_: int
) -> Union[List[CleaningDetails], Optional[CleaningDetails]]:
"""Return details about specific cleaning."""
details = self.send("get_clean_record", [id_])

if not details:
_LOGGER.warning("No cleaning record found for id %s" % id_)
_LOGGER.warning("No cleaning record found for id %s", id_)
return None

if return_list:
_LOGGER.warning(
"This method will be returning the details "
"without wrapping them into a list in the "
"near future. The current behavior can be "
"kept by passing return_list=True and this "
"warning will be removed when the default gets "
"changed."
)
return [CleaningDetails(entry) for entry in details]

if len(details) > 1:
_LOGGER.warning("Got multiple clean details, returning the first")

res = CleaningDetails(details.pop())
return res

Expand Down