Files
EverShelf/evershelf-scale-gateway
dadaloop82 3ff91b3018 fix(scale): progress-bar restart loop + low-weight warning + gateway auto-reconnect cycle
- Fix progress-bar restarting continuously when weight is stable:
  add _cancelScaleTimersOnly() that stops timers/animations without
  _cancelScaleTimersOnly() so the same value resumes counting when
  stability returns instead of always restarting the 5-s wait.
  Add 'else if' branch in _scaleAutoFillUse / _scaleAutoFillRecipeUse
  to restart stability wait after brief instability for the same value.

- Show red blinking warning in scale-live-box when weight < 10 g:
  adds scale-low-weight CSS class with pulsing border/shadow animation,
  the label shows '< 10 g · inserisci manualmente' instead of the
  stability progress bar.  No auto-confirm fires below 10 g.

- Gateway Android app: scale auto-reconnect now retries indefinitely.
  isAutoReconnecting flag keeps the scan→wait→scan cycle running until
  the scale is found again; onScanStopped schedules a new scan after
  10 s whenever autoReconnect is active and scale is still offline.
2026-04-16 06:25:40 +00:00
..

EverShelf Scale Gateway

Android gateway app that bridges Bluetooth LE smart scales with EverShelf via WebSocket.


How it works

Smart Scale ──(BLE)──► Android Gateway App ──(WebSocket/LAN)──► EverShelf (browser)

The app runs a local WebSocket server (port 8765) on your Android device. EverShelf connects to it over your home Wi-Fi and receives weight readings in real time.


Supported scale protocols

Protocol Service UUID Notes
Bluetooth SIG Weight Scale 0x181D / char 0x2A9D Most compatible; works with most smart scales
Bluetooth SIG Body Composition 0x181B / char 0x2A9C Reports weight + body fat %, BMI
Generic fallback Any notifiable characteristic Auto-heuristic parsing for 100+ models

Verified compatible scales (community list)

  • Xiaomi Mi Body Composition Scale 2
  • Renpho Smart Body Fat Scale
  • INEVIFIT Smart Body Fat Scale
  • Any OpenScale-compatible scale (see openScale supported devices)

Your scale (B09MRXVBV6): If it implements the standard BLE Weight Scale or Body Composition profile (very likely for modern Amazon smart scales), the gateway will connect automatically. If not, check the openScale wiki and open an issue.


Download

Download the latest APK directly: evershelf-scale-gateway.apk


Requirements

  • Android 7.0 (API 24) or later
  • Bluetooth LE (BLE) support
  • Both the Android device and the device running EverShelf must be on the same Wi-Fi network

Setup (step by step)

1. Install the APK

Download and install the APK from the Releases page. You may need to allow "Install from unknown sources" in Android settings.

2. Launch the app

The app starts the WebSocket gateway server immediately. You will see the gateway URL (e.g. ws://192.168.1.100:8765) at the top.

3. Connect your scale

Tap "Cerca Bilance Bluetooth" (Find Bluetooth Scales). Make sure your scale is turned on. Tap it in the list to connect.

4. Configure EverShelf

In EverShelf → ⚙️ Settings → ⚖️ Bilancia Smart:

  1. Enable the toggle
  2. Paste the gateway URL shown in the Android app
  3. Tap "Testa connessione" — you should see

5. Use it

When adding or consuming a product with unit g or ml, a "⚖️ Leggi dalla bilancia" button appears. Tap it, place the product on the scale, and the weight is filled in automatically.


WebSocket protocol reference

All messages are JSON. The server sends these to connected clients:

// Scale status update
{"type":"status","state":"connected","device":"Mi Scale 2","battery":85}
{"type":"status","state":"disconnected"}

// Weight reading (broadcast continuously while scale is active)
{"type":"weight","value":72.50,"unit":"kg","stable":true,"timestamp":1712345678000}

// Response to ping
{"type":"pong"}

Clients can send:

{"type":"get_status"}   // Request current status
{"type":"get_weight"}   // Request next stable weight reading
{"type":"ping"}         // Keep-alive

Build from source

Prerequisites

  • Android Studio Hedgehog (2023.1) or later
  • Java 8+

Steps

# 1. Clone the repo
git clone https://github.com/dadaloop82/EverShelf.git
cd EverShelf/evershelf-scale-gateway

# 2. Download the Gradle wrapper (if not included)
gradle wrapper --gradle-version 8.4

# 3. Build debug APK
./gradlew assembleDebug

# APK is at: app/build/outputs/apk/debug/app-debug.apk

Project structure

evershelf-scale-gateway/
├── app/src/main/
│   ├── kotlin/it/dadaloop/evershelf/scalegate/
│   │   ├── MainActivity.kt          — UI, orchestration
│   │   ├── BleScaleManager.kt       — BLE scanning & GATT connection
│   │   ├── ScaleProtocol.kt         — Parsing for all supported protocols
│   │   └── GatewayWebSocketServer.kt — WebSocket server (Java-WebSocket)
│   ├── res/layout/
│   │   ├── activity_main.xml
│   │   └── item_device.xml
│   └── AndroidManifest.xml
├── build.gradle.kts
└── settings.gradle.kts

License

MIT — see LICENSE