Repository navigation
Add missing fields and correct sleep docs in Huawei schemas - #451
Open
yatharthranjan wants to merge 6 commits into
Open
yatharthranjan wants to merge 6 commits into
yatharthranjan wants to merge 6 commits into
Conversation
Huawei's activityRecords response describes the recording device as
deviceInfo {devType: "Smart watch", deviceCode: 308517120, ...}. The
existing int deviceType field can only hold the code, so add an optional
deviceTypeName string for devType and document deviceType as the
deviceCode. The new field defaults to null, keeping the schema
backward compatible.
Claude-Session: https://claude.ai/code/session_01PeNFs67cbLTGQ6xKiyDHdC
Huawei's continuous.exercise_intensity.v2.statistics sample points carry a totalIntensity integer next to intensity_map. In the live response it was 32 while the map's entries summed to 30, so it can't be derived from the map. Add it as an optional int with a null default, keeping the schema backward compatible. Claude-Session: https://claude.ai/code/session_01PeNFs67cbLTGQ6xKiyDHdC
A live night of Huawei sleep data shows the health.record.sleep durations are minutes, not milliseconds: light 161 + deep 77 + REM 58 equals all_sleep_time 296, and adding awake_time 52 gives the 348 minutes between fall_asleep_time and wakeup_time. Summing the same night's one-minute continuous.sleep.fragment points per sleep_state gives 1: 161, 2: 58, 3: 77 and 4: 58 minutes, matching light, REM, deep and awake (52 plus the 6 minutes between going to bed and falling asleep). Fix the stage codes, which had 1, 3 and 4 swapped. Documentation only; no field types change.
The Health Kit polymerize API returns individual instantaneous.heart_rate (bpm, one-minute points) and instantaneous.spo2 (saturation and oxygen_supply_flow_rate) readings all day, including during sleep, but the spec only covered their daily statistics. Add a schema and topic for each.
Per the Health Kit sleep.on_off_bed_record reference, onOffBedState is 1 when getting in bed and 2 when getting out of bed. A live night returned two 2 events, the second at the sleep record's wakeup_time.
mpgxvii
reviewed
Dec 1, 2026
| "int" | ||
| ], | ||
| "doc": "Sleep stage: 1=awake, 2=REM, 3=light sleep, 4=deep sleep.", | ||
| "doc": "Sleep stage: 1=light sleep, 2=REM, 3=deep sleep, 4=awake.", |
Member
There was a problem hiding this comment.
Do you think we should have another key like sleepStateString or something just for values?
Member
Author
There was a problem hiding this comment.
do you mean like an enum?
Member
There was a problem hiding this comment.
Yeah like in addition to. the int sleepState so we have the value as well?
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
huawei_activity_record.avsc:deviceTypeNamestring for Huawei'sdeviceInfo.devType(for example"Smart watch").deviceTypedoc: the int field holdsdeviceInfo.deviceCode.huawei_continuous_exercise_intensity_v2_statistics.avsc: adds an optionaltotalIntensityint.huawei_health_record_sleep.avsc: the stage durations are documented in minutes rather than ms.huawei_continuous_sleep_fragment.avsc: corrects thesleepStatecodes to 1 = light, 2 = REM, 3 = deep, 4 = awake.huawei_sleep_on_off_bed_record.avsc: documents theonOffBedStatecodes, 1 = getting in bed and 2 = getting out of bed, per Huawei's data type reference.huawei_heart_rate.avsc(HuaweiHeartRate) andhuawei_spo2.avsc(HuaweiSpo2), with topicsconnect_huawei_instantaneous_heart_rateandconnect_huawei_instantaneous_spo2in the spec, for individual readings. The spec only had their daily statistics.All of these were found by probing the live Health Kit API.
v2/activityRecordsdescribes the device as:The existing int
deviceTypefield can't holddevType, which is a string.sampleSet:dailyPolymerizeforcom.huawei.continuous.exercise_intensity.v2.statisticsreturns:[{"fieldName": "totalIntensity", "integerValue": 32}, {"fieldName": "intensity_map", "mapValue": [{"key": "1", "value": {"integerValue": 11}}, ...]}]In that response
totalIntensity(32) differs from the sum of the map (30), so it has to be stored separately.One night of live sleep data confirms the units and codes:
health.record.sleeprecord, light 161 + deep 77 + REM 58 equalsall_sleep_time296. Addingawake_time52 gives 348, the number of minutes betweenfall_asleep_timeandwakeup_time.continuous.sleep.fragmentpoints add up to 1: 161, 2: 58, 3: 77 and 4: 58 minutes. That matches light, REM, deep and awake (52, plus the 6 minutes between going to bed and falling asleep).sampleSet:polymerizereturns individual readings all day, including during sleep (two days: 567 heart rate and 26 SpO2 points):{"dataTypeName": "com.huawei.instantaneous.heart_rate", "value": [{"fieldName": "bpm", "floatValue": 82.0}]} {"dataTypeName": "com.huawei.instantaneous.spo2", "value": [{"fieldName": "saturation", "floatValue": 98.0}, {"fieldName": "oxygen_supply_flow_rate", "floatValue": 0.0}]}Compatibility
Both new fields are optional with a
nulldefault, so the existing schemas stay backward compatible. The sleep changes only touch docs. The heart rate and SpO2 schemas are new.Test plan
./gradlew checkinjava-sdkRelated: RADAR-base/RADAR-REST-Connector#204 (the Huawei connector) and #450 (blood pressure last values).