From a27c4d22e7dd21cf5ae454886c743d28db130803 Mon Sep 17 00:00:00 2001 From: Luke Date: Sat, 9 Sep 2023 15:42:13 -0400 Subject: [PATCH] feat: add datetime parsing in cleanrecord --- roborock/containers.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/roborock/containers.py b/roborock/containers.py index 67b9233..963fa35 100644 --- a/roborock/containers.py +++ b/roborock/containers.py @@ -408,7 +408,9 @@ def __post_init__(self) -> None: @dataclass class CleanRecord(RoborockBase): begin: Optional[int] = None + begin_datetime: datetime.datetime | None = None end: Optional[int] = None + end_datetime: datetime.datetime | None = None duration: Optional[int] = None area: Optional[int] = None square_meter_area: Optional[float] = None @@ -424,6 +426,8 @@ class CleanRecord(RoborockBase): def __post_init__(self) -> None: self.square_meter_area = round(self.area / 1000000, 1) if self.area is not None else None + self.begin_datetime = datetime.datetime.fromtimestamp(self.begin).astimezone(datetime.UTC) if self.begin else None + self.end_datetime = datetime.datetime.fromtimestamp(self.end).astimezone(datetime.UTC) if self.end else None @dataclass