Skip to content

Fix/female body composition - #1488

Open
dkuku wants to merge 5 commits into
oliexdev:masterfrom
dkuku:fix/female-body-composition
Open

Fix/female body composition#1488
dkuku wants to merge 5 commits into
oliexdev:masterfrom
dkuku:fix/female-body-composition

Conversation

@dkuku

@dkuku dkuku commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

Summary

  • correct female lean-body-mass estimates using the bodymiscale calibration factor
  • apply a sex-specific minimum body-fat percentage
  • add regression coverage for female LBM and body-fat floors

Scope

This correction applies only to Xiaomi scales when using the Scientific body-composition mode.

Changelog reference

dkuku and others added 5 commits July 21, 2026 21:12
Mi Scale v1/v2 previously derived body composition only from the
reverse-engineered Mi Fit algorithm (MiScaleLib). This adds a per-scale
setting letting users pick between that "Xiaomi (original app)" path and
a new "Scientific" estimator.

- BodyMiScaleLib: mono-frequency estimator ported from the bodymiscale
  Home Assistant integration (GPL-3.0). SCIENCE mode chains a
  hardware-calibrated LBM with peer-reviewed formulas (Siri, Pace, Wang,
  Schofield) and additionally reports protein and BMR. Locked to
  byte-for-byte parity with the reference project via a regression test.
- MiScaleHandler: radio picker to choose the algorithm; new measurements
  use the selected path.
- ScaleDeviceHandler: extract a reusable SettingRadioGroup composable
  (settings-backed radio group) for device configuration UIs.
- CREDITS: add bodymiscale attribution.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Signed-off-by: Daniel Kukula <daniel.kuku@gmail.com>
The Mode enum threaded through every method was a vestigial artifact of
the upstream bodymiscale port. openScale already selects the algorithm at
the handler (MiScaleLib vs BodyMiScaleLib), so BodyMiScaleLib.Mode.XIAOMI
was never used in production — only by a test comparing it to MiScaleLib.

Drop Mode and its XIAOMI branches so the class is purely the scientific
path. Method signatures shrink accordingly (getProtein no longer needs
muscle/water, which existed only for the Xiaomi formula). Output is
unchanged; the regression fixture still matches byte-for-byte.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Add selectable Scientific body-composition algorithm to Mi Scale
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants