From 4df34bbd61991cfaae1eec624edc5331c6a74307 Mon Sep 17 00:00:00 2001 From: YorkshireIoT Date: Sat, 2 Mar 2024 11:34:00 +0000 Subject: [PATCH] Check that sleep time is greater than awake time before subtracting --- custom_components/google_fit/coordinator.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/custom_components/google_fit/coordinator.py b/custom_components/google_fit/coordinator.py index ac3d84f..95b14b8 100644 --- a/custom_components/google_fit/coordinator.py +++ b/custom_components/google_fit/coordinator.py @@ -229,6 +229,8 @@ def _get_session(activity_id: int) -> FitnessSessionResponse: if ( self.fitness_data["sleepSeconds"] is not None and self.fitness_data["awakeSeconds"] is not None + and self.fitness_data["sleepSeconds"] + >= self.fitness_data["awakeSeconds"] ): self.fitness_data["sleepSeconds"] -= self.fitness_data[ "awakeSeconds"