Skip to content

Navigation Menu

Sign in
Sign up

feat(scale): add manual USB-powered override for Skale - #745

Open
MaxRink wants to merge 16 commits into
decentespresso:main from
MaxRink:feat/skale-usb-power-override-716
Open

feat(scale): add manual USB-powered override for Skale #745
MaxRink wants to merge 16 commits into
decentespresso:main from
MaxRink:feat/skale-usb-power-override-716

Conversation

@MaxRink

@MaxRink MaxRink commented Aug 31, 2026
edited
Loading

Copy link
Copy Markdown

Summary

What changed, and why?

  • Add a Skale-specific, persisted, exported, REST-configurable Powered by USB setting keyed by exact device ID and defaulting off.
  • Apply each override only to its matching existing or newly connected configurable Skale.
  • While enabled, suppress battery reads/refresh, clear the previous percentage, and report usb with manualOverride provenance.
  • When disabled, perform a fresh battery read before resuming the normal refresh policy, with generation/concurrency fencing across in-flight reads and reconnects.
  • Expose the manual power-source state through Devices, REST, and WebSocket metadata.

Linked Issue

Fixes #716

Verification

  • Targeted backend/API correction suites: 63 tests passed.
  • flutter analyze completed with no issues.
  • Actual ScaleHandler.addRoutes() coverage verifies GET /api/v1/scale/info, disconnected 503, connected metadata serialization, REST and WebSocket inventory metadata exclusion, and no inventory emission for metadata refresh.
  • Hardware/end-to-end smoke testing was not run. The macOS environment lacks xcodebuild; Android requires a missing debug.keystore. An existing port-8080 ADB issue is unrelated and unchanged.

Impact

Note any user-visible behavior, compatibility, migration, API/spec, documentation, or security impact. Write None if there is none.

  • Adds a default-off manual override; it does not claim or implement USB-power autodiscovery because none of the reviewed Atomax SDKs exposes that state.
  • Manual USB mode suppresses battery percentages and low-battery interpretation and identifies user-selected provenance.
  • skalePoweredByUsbByDevice participates in persistence, export/import, and the REST settings contract. Only enabled device IDs are stored.
  • Two Skales can retain different USB-power overrides; DeviceController applies each device's own value.
  • With the override off, Decaid reports only the device-provided battery percentage; it does not claim that the electrical source was autodetected as battery.
  • Adds optional power-source/provenance fields to GET /api/v1/scale/info ScaleInfo.
  • This draft is stacked on fix(scale): make Skale battery reporting nullable and refresh it #743 and therefore indirectly feat(scale): show connected Skale firmware revision #742 . Until those merge, GitHub's diff includes their shared firmware and battery foundation.
  • Low-battery warnings remain outside this PR and are being designed generically across scales and temperature sensors in feat(devices): design cross-device battery and health warnings #717 .

Contributor Responsibility

AI-assisted development is allowed. The submitter remains responsible for the submitted work.

  • I have reviewed and understand all changes in this PR and take responsibility for their correctness, security, behavior, licensing, and provenance, including any AI-assisted or AI-generated work.

API boundary

Connected-scale metadata is exposed through GET /api/v1/scale/info as ScaleInfo. The inventory REST endpoint /api/v1/devices and the /ws/v1/devices stream do not expose deviceInfo or emit metadata-only inventory refreshes; device-specific settings and native metadata UI remain supported separately.

MaxRink and others added 10 commits September 6, 2026 20:32
Centralize USB-power setting application and remove duplicate state, resets, and test-only interface surface identified during the ponytail review. Discovered devices still receive the setting before connection without publishing inactive metadata.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The top-right Settings page did not link to the existing Devices page, leaving firmware and scale controls hidden behind the launcher navigation. Add a direct Devices row so connected-device metadata and settings are reachable from the expected entry point.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The manual USB-power override was rendered as a global switch at the bottom of the Devices page, leaving it effectively hidden and detached from the Skale it configures. Move the control behind a settings button on USB-configurable scale rows without changing its persisted global Skale semantics or battery-refresh behavior. Update the widget coverage and device-management documentation to reflect the discoverable Settings > Devices path.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Device Management is now reachable from the regular Settings page as well as the dashboard. Record both entry points so the user-facing navigation documentation matches the new discoverable route.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The USB override only produces usb with manualOverride, while the device-information enums and API schemas advertised three unused sources and an unused provenance. Keep the contract honest to implemented behavior, remove serializer-only coverage already exercised through the Devices API, and detect configurable scale rows directly instead of passing a one-use callback through the section builder.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
All three USB propagation tests repeated the same discovery, settings, and controller initialization. Extract that fixture construction into one helper so each test shows only the behavior it varies while retaining explicit cleanup and disposal coverage.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The USB-power override was global, which made one Skale setting overwrite the power-source behavior of every configurable scale.
Persist enabled device IDs, expose the per-device map through settings export and REST, and apply each value only to its matching device. Disabled entries are removed so the stored contract remains compact and defaults safely to battery reporting.
The native device dialog and tests now verify independent settings for two Skales and same-ID replacement devices.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
MaxRink force-pushed the feat/skale-usb-power-override-716 branch from ba976b9 to 11aa1ae Compare September 6, 2026 18:32
MaxRink and others added 6 commits September 7, 2026 11:10
Expose generic connected-scale metadata through /api/v1/scale/info while keeping device inventory limited to discovery and connection state. Keep metadata refreshes out of the inventory WebSocket and align the API contract.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Use the router's parameterized GET form so the connected-scale metadata endpoint is reachable, and align inventory tests with the boundary.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Keep scale metadata on the connected-scale endpoint and update affected implementations and tests.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Keep inventory payloads metadata-free and cover connected scale info responses.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

feat(scale): add a manual USB-powered override for Skale

1 participant

AltStyle によって変換されたページ (->オリジナル) /