Skip to content

fix: detect source unit from companion app package name in UiBasedCollector - #4648

Open
ryceg wants to merge 1 commit into
NightscoutFoundation:masterfrom
ryceg:fix/uibased-collector-source-units
Open

fix: detect source unit from companion app package name in UiBasedCollector#4648
ryceg wants to merge 1 commit into
NightscoutFoundation:masterfrom
ryceg:fix/uibased-collector-source-units

Conversation

@ryceg

@ryceg ryceg commented Jul 21, 2026

Copy link
Copy Markdown

Split out of #4529 so it can be reviewed on its own merits.

Many companion apps encode their glucose unit in the package name (e.g. .mmol, .mmoll, .mgdl). UiBasedCollector previously interpreted scraped values using xDrip's own display unit preference, so an mmol/L value from a companion app could be parsed as mg/dL (or vice versa) when the two disagreed. This detects the source unit from the companion package name and falls back to xDrip's preference when the name carries no unit hint.

Includes unit tests for the package-name detection.

…lector

Companion apps like CamAPS and Dexcom encode their unit choice in the package
suffix (e.g. `.mmoll`, `.mgdl`). Previously UiBasedCollector parsed scraped
values using xDrip's own unit preference, which silently corrupted readings
when the user's xDrip was set to mg/dL but the source app was a mmol build
(or vice-versa).

Introduces `sourcePackageUsesMgDl()` which checks the captured `lastPackage`
for `.mmol`/`.mmoll`/`.mgdl` markers before falling back to xDrip's
`Unitized.usingMgDl()`. Covers CamAPS fx_alert (mmoll/mgdl, with optional hx
and region suffixes) and Dexcom G6 region1/2/4 variants.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.

1 participant