-
Notifications
You must be signed in to change notification settings - Fork 40
Open
Description
Reproduce
api = WithingsApi(get_credentials())
sleep_data = api.sleep_get_summary(
data_fields=[GetSleepSummaryField.SLEEP_SCORE],
startdateymd=arrow.utcnow().shift(days=-2),
)
series = getattr(sleep_data, "series", [])
print([f"{s.date.format('YYYY-MM-DD')} {s.data.sleep_score}" for s in series])Expected
Print sleep scores for the last two days
['2025-10-12 84', '2025-10-13 91']
Actual
API returns 0 days
[]
Workarounds
It works if you set lastupdate to None:
sleep_data = api.sleep_get_summary(
data_fields=[GetSleepSummaryField.SLEEP_SCORE],
startdateymd=arrow.utcnow().shift(days=-2),
lastupdate=None,
)
Cause
getsummary docs for lastupdate say
DO NOT USE WITH FOLLOWING PARAMS: [startdateymd, enddateymd]
So the default fields for getsummary shouldn't be setting both of these:
python_withings_api/withings_api/__init__.py
Lines 223 to 230 in 69c21c3
| def sleep_get_summary( | |
| self, | |
| data_fields: Iterable[GetSleepSummaryField], | |
| startdateymd: Optional[DateType] = arrow.utcnow(), | |
| enddateymd: Optional[DateType] = arrow.utcnow(), | |
| offset: Optional[int] = None, | |
| lastupdate: Optional[DateType] = arrow.utcnow(), | |
| ) -> SleepGetSummaryResponse: |
Related problems
I checked through the withings API, and saw similar issues in measure_get_activity (docs)
If you search "DO NOT USE WITH FOLLOWING PARAMS" there are a couple other APIs with incompatible paramater sets.
Metadata
Metadata
Assignees
Labels
No labels