Skip to content
Open
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
32 changes: 32 additions & 0 deletions withings_api/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,11 +210,14 @@ class GetSleepField(Enum):
HR = "hr"
RR = "rr"
SNORING = "snoring"
SDNN_1 = "sdnn_1"
RMSSD = "rmssd"


class GetSleepSummaryField(Enum):
"""Fields for get sleep summary api call."""

APNEA_HYPOPNEA_INDEX = "apnea_hypopnea_index"
BREATHING_DISTURBANCES_INTENSITY = "breathing_disturbances_intensity"
DEEP_SLEEP_DURATION = "deepsleepduration"
DURATION_TO_SLEEP = "durationtosleep"
Expand All @@ -223,15 +226,23 @@ class GetSleepSummaryField(Enum):
HR_MAX = "hr_max"
HR_MIN = "hr_min"
LIGHT_SLEEP_DURATION = "lightsleepduration"
OUT_OF_BED_COUNT = "out_of_bed_count"
REM_SLEEP_DURATION = "remsleepduration"
REM_COUNT = "nb_rem_episodes"
RR_AVERAGE = "rr_average"
RR_MAX = "rr_max"
RR_MIN = "rr_min"
SLEEP_EFFICENCY = "sleep_efficiency"
SLEEP_LATENCY = "sleep_latency"
SLEEP_SCORE = "sleep_score"
SNORING = "snoring"
SNORING_EPISODE_COUNT = "snoringepisodecount"
TOTAL_IN_BED = "total_timeinbed"
TOTAL_SLEEP = "total_sleep_time"
WAKEUP_COUNT = "wakeupcount"
WAKEUP_DURATION = "wakeupduration"
WAKEUP_LATENCY = "wakeup_latency"
WASO = "waso"


class AuthScope(Enum):
Expand Down Expand Up @@ -275,6 +286,8 @@ class SleepGetSerie(ConfiguredBaseModel):
hr: Tuple[SleepGetTimestampValue, ...] = () # pylint: disable=invalid-name
rr: Tuple[SleepGetTimestampValue, ...] = () # pylint: disable=invalid-name
snoring: Tuple[SleepGetTimestampValue, ...] = ()
sdnn_1: Tuple[SleepGetTimestampValue, ...] = ()
rmssd: Tuple[SleepGetTimestampValue, ...] = ()

@validator("hr", pre=True)
@classmethod
Expand All @@ -291,6 +304,16 @@ def _rr_to_tuple(cls, value: Dict[str, int]) -> Tuple:
def _snoring_to_tuple(cls, value: Dict[str, int]) -> Tuple:
return SleepGetSerie._timestamp_value_to_object(value)

@validator("sdnn_1", pre=True)
@classmethod
def _sdnn_1_to_tuple(cls, value: Dict[str, int]) -> Tuple:
return SleepGetSerie._timestamp_value_to_object(value)

@validator("rmssd", pre=True)
@classmethod
def _rmssd_to_tuple(cls, value: Dict[str, int]) -> Tuple:
return SleepGetSerie._timestamp_value_to_object(value)

@classmethod
def _timestamp_value_to_object(
cls, value: Any
Expand Down Expand Up @@ -330,6 +353,7 @@ class GetSleepSummaryData(
): # pylint: disable=too-many-instance-attributes
"""GetSleepSummaryData."""

apnea_hypopnea_index: Optional[float]
breathing_disturbances_intensity: Optional[int]
deepsleepduration: Optional[int]
durationtosleep: Optional[int]
Expand All @@ -338,15 +362,23 @@ class GetSleepSummaryData(
hr_max: Optional[int]
hr_min: Optional[int]
lightsleepduration: Optional[int]
out_of_bed_count: Optional[int]
remsleepduration: Optional[int]
nb_rem_episodes: Optional[int]
rr_average: Optional[int]
rr_max: Optional[int]
rr_min: Optional[int]
sleep_efficiency: Optional[int]
sleep_latency: Optional[int]
sleep_score: Optional[int]
snoring: Optional[int]
snoringepisodecount: Optional[int]
total_sleep_time: Optional[int]
total_timeinbed: Optional[int]
wakeupcount: Optional[int]
wakeupduration: Optional[int]
wakeup_latency: Optional[int]
waso: Optional[int]


class GetSleepSummarySerie(ConfiguredBaseModel):
Expand Down