Skip to content

S400 hydration shift loses decreases and exact zero in ScaleMeasurement #1588

Open

Description

@aronnoordhoek

The S400 handler reports a signed hydration shift, but ScaleMeasurement.set() drops every non-positive number. A decrease or unchanged value therefore disappears before saving.

Minimal reproduction with the existing key:

val measurement = ScaleMeasurement()
measurement[MiScaleS400Handler.HYDRATION_SHIFT] = Percent(-4f)
check(measurement[MiScaleS400Handler.HYDRATION_SHIFT] == Percent(-4f)) // fails: null

Percent(0f) is discarded too; positive values survive.

S400HydrationShift.shiftPct() calculates a signed change and MiScaleS400Handler publishes it. The positive-only checks in android_app/app/src/main/java/com/health/openscale/core/bluetooth/data/ScaleMeasurement.kt cause the loss. This is also present on the current default branch.

I'm working on adding support for the Tanita RD-545 and ran into the same problem with its scores. A possible fix is an allowNonPositive flag on measurement keys, so fields like hydration shift and signed scores can keep zero/negative values while weight still requires a positive value.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions