Skip to content

Commit

Permalink
Merge pull request #188 from YorkshireIoT/145-dont-include-awake-time…
Browse files Browse the repository at this point in the history
…-in-overall-sleep-time-calculation

Add sleep time adjustment to subtract awake time from total sleep time
  • Loading branch information
YorkshireIoT authored Feb 8, 2024
2 parents 189efa7 + 31c6934 commit 4296fdb
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions custom_components/google_fit/coordinator.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,18 @@ def _get_session(activity_id: int) -> FitnessSessionResponse:
# Update globally stored data with fetched and parsed data
self.fitness_data = parser.fit_data

# Google Fit provides us with a total sleep time that also includes
# time awake as well. To more accurately reflect actual sleep time
# we should readjust this before submitting the data
if self.fitness_data is not None:
if (
self.fitness_data["sleepSeconds"] is not None
and self.fitness_data["awakeSeconds"] is not None
):
self.fitness_data["sleepSeconds"] -= self.fitness_data[
"awakeSeconds"
]

# Increment and modulo the counter
self.sensor_update_counter = (
self.sensor_update_counter + 1
Expand Down

0 comments on commit 4296fdb

Please sign in to comment.