Repository navigation
fix: Pass the user's weight unit to scale handlers (#1562) - #1564
Open
daniel-walker wants to merge 1 commit into
Open
daniel-walker wants to merge 1 commit into
daniel-walker wants to merge 1 commit into
Conversation
ScaleUser.scaleUnit was never set: BluetoothFacade.toScaleUser() copied id, name, birthday, height and gender only, so every handler saw the default KG. Handlers that push a unit to the scale (MGB, Etekcity, Yunmai, QN, Mi Scale, Runstar R5 and others) switched it to kg even for users who chose lb or st. The app keeps the weight unit on the Weight measurement type, not on the user. The facade now combines the selected user with the measurement types and sets scaleUnit from the Weight type's unit, refreshing it when either changes. It falls back to KG while the types are not loaded, so users on kg see no change. Five handlers also convert incoming weights with scaleUnit (Mi Scale, Hume Dara 2, Excelvan CF36x, FitTrack Dara, Hoffen BBS-8107). Each one configures the scale with the same unit it later reads weights in, so for lb/st users they now read the unit they configured instead of assuming kg. None of these were tested on hardware for this change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Daniel Walker <dwalker@fifo99.com>
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.
Closes #1562.
ScaleUser.scaleUnitwas never set:BluetoothFacade.toScaleUser()copied id, name, birthday, height and gender only, so every scale handler saw the defaultKG. Handlers that push a unit to the scale (MGB, Etekcity, Yunmai, QN, Mi Scale, Runstar R5 and others) switched it to kg even for users who chose lb or st.Change
The app keeps the weight unit on the Weight measurement type, not on the user.
BluetoothFacadeImplnow combines the selected user withmeasurementFacade.getAllMeasurementTypes()and setsscaleUnitfrom the Weight type's unit, refreshing it whenever either changes. A newscaleUnitFor()helper does the lookup and falls back toKGwhile the types aren't loaded or have no weight unit, so users on kg see no change.Handlers that convert weights with
scaleUnitFive handlers also convert incoming weights with
scaleUnit: Mi Scale, Hume Dara 2, Excelvan CF36x, FitTrack Dara and Hoffen BBS-8107. Each one configures the scale with the same unit it later reads weights in. So for lb/st users they now read the unit they configured, instead of applying kg to a scale they just set to kg. They weren't tested on hardware for this change, so reports from owners would be welcome.Testing
Unit tests: new
ScaleUnitForTest(kg/lb/st mapping, other mass types such as LBM and bone ignored, KG fallback). Full suite:./gradlew :app:testDebugUnitTest, 930 tests, 0 failures.On hardware: a debug build of this branch merged with feat: Add support for the Lescale F4P (Runstar R6 protocol) #1563 (Lescale F4P support), on a Pixel (Android 13). Two weigh-ins, before and after saving the Weight type's unit as lb:
The unit change reached the handler as soon as it was saved. The F4P switched its display from kg to lb, and its frames came back with the pounds flag (
0x0F→0x3E=0x20 | 0x1E). Both measurements were stored as 74.3 kg with all 9 values.This removes the known limitation noted in #1563. The two PRs are independent and can be merged in either order.
🤖 Generated with Claude Code