mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-08 20:42:43 +00:00
A bridge such as Tasker or Home Assistant could only send sleep stages through the batch route, in HealthKit's terms: the category identifier, a stage codepoint from 0 to 5, and a value it had to work out in minutes. It can now post one segment to `POST /api/measurements` with `type: "SLEEP_DURATION"`, a `sleepStage` of `IN_BED`, `ASLEEP`, `AWAKE`, `CORE`, `DEEP` or `REM`, and either `startDate` + `endDate` or `measuredAt` (the end) + `value` (minutes). The row is the one the batch route writes for the same segment, and the dedupe is the batch route's: the opposite-source same-reading check, then one reconcile over both unique identities. Without an `externalId` the server derives one from the stage and both instants, so a re-post answers 200 `duplicate`, a corrected start answers 200 `updated`, and a new segment answers 201 `inserted`. The narrow `measurements:write` token is accepted and still writes only MANUAL rows. Every other body on this route behaves as before. Requested in #972.
2.5 MiB
2.5 MiB