Severity
minor
Summary
Two related cosmetic / data-hygiene problems in the --derive polyfill path of the sleep subcommand.
1. hr_avg precision blows up on derived rows
Real Withings rows in CSV print hr_avg as a small integer-ish value. Derived rows print 16 digits of float noise:
$ withings-export sleep --since 7d --derive 2>/dev/null | head -3
date,start,end,timezone,total_sleep_min,...,hr_avg,hr_min,hr_max,...,source
2026-04-18,...,Local,385,...,45.86206896551724,0,0,...,derived
2026-04-19,...,Local,567,...,43.037974683544306,0,0,...,derived
This is the same column non-derived rows fill with a single integer. Format with %.0f (matches markdown's fmtRound) or %.1f for parity with the fmtFloat1 helper already in cmd/shared.go.
2. Derived rows put all minutes into light_min
Every derived row has total_sleep_min == light_min and deep_min == rem_min == 0. That isn't surprising for an HR-only polyfill, but consumers can't tell whether "deep_min=0" means "this user had zero deep sleep" or "we don't actually know". For derived rows, please leave the per-stage columns blank/null rather than zero, or at minimum document this in prime / --help. Same applies to wakeup_count, time_to_sleep_sec, etc.
Reproduce
See command above.
Expected
- Round derived
hr_avg to integer or one decimal in CSV/markdown.
- For derived rows, emit empty CSV cells / JSON
null for fields the heuristic cannot infer (deep, rem, wakeups, latencies).
Severity
minor
Summary
Two related cosmetic / data-hygiene problems in the
--derivepolyfill path of thesleepsubcommand.1.
hr_avgprecision blows up on derived rowsReal Withings rows in CSV print
hr_avgas a small integer-ish value. Derived rows print 16 digits of float noise:This is the same column non-derived rows fill with a single integer. Format with
%.0f(matches markdown'sfmtRound) or%.1ffor parity with thefmtFloat1helper already incmd/shared.go.2. Derived rows put all minutes into
light_minEvery derived row has
total_sleep_min == light_minanddeep_min == rem_min == 0. That isn't surprising for an HR-only polyfill, but consumers can't tell whether "deep_min=0" means "this user had zero deep sleep" or "we don't actually know". For derived rows, please leave the per-stage columns blank/null rather than zero, or at minimum document this inprime/--help. Same applies towakeup_count,time_to_sleep_sec, etc.Reproduce
See command above.
Expected
hr_avgto integer or one decimal in CSV/markdown.nullfor fields the heuristic cannot infer (deep, rem, wakeups, latencies).