openScale icon indicating copy to clipboard operation
openScale copied to clipboard

Problem sync at Mi Body Composition Scale 2

Open ddelaqua opened this issue 1 year ago • 4 comments

Sync is creating duplicate data When synchronization occurs, the application reads and records previously synchronized measurements in duplicate. It doesn't matter whether a new measurement was taken or not.

Initially, I manually deleted the duplicate data and performed a new sync, but the data was duplicated again. However, I later performed a new sync without deleting the synced data, and the import duplicated the most recent data again.

In some cases, after duplicate import, the time the measurement was taken is automatically changed by the openScale app.

Image

In the example above, no new measurements were taken, and the time of 10:27 is not accurate. This screenshot was taken at 7:35.

To Reproduce Steps to reproduce the behavior:

  1. Take a measurement by stepping on the scale;
  2. Wait for it to finish and step off the scale;
  3. In the openScale app, start the synchronization by clicking the "Bluetooth" icon;
  4. Wait for the synchronization complete notification;
  5. End the synchronization;
  6. Start a new synchronization;
  7. See error.

Reproduced with (https://github.com/oliexdev/openScale/releases/tag/beta-build): openScale 3.0 beta build (commit 9cb4b22)

Expected behavior That only data is synchronized without duplication.

Additional context The scale on which the errors were recorded Name: Mi Body Composition Scale 2 Model: XMTZC05HM

Debug log openScale_current_log.txt

ddelaqua avatar Sep 11 '25 13:09 ddelaqua

Thanks for reporting this. I’ve checked the behavior and updated the synchronization logic. Now, during the first sync, all measurements from the scale are imported. After that, only new measurements that have never been imported will be synced. Please try out the latest beta build.

oliexdev avatar Sep 11 '25 16:09 oliexdev

I've got that exact model scale and encountered the same bug. Now to test this fix I've had to uninstall the dev-build and switched to the play beta build, importing my backup.

The first import is much worse than before. It duplicated 22 measurements and sat there for a minute just playing each "XX kg measurement imported" toast-like messages at the bottom of the app after another.

Why don't we stop the initial import when the first timestamp that's already in the db is encountered?

fallingcats avatar Sep 15 '25 09:09 fallingcats

Hi, installed latest beta build (https://github.com/oliexdev/openScale/commit/1a5d7c3f36310d4633081f4e53fcaa1062a1ee8b) and issue of duplicated values seems to not appear anymore, but 2 things appeared. Can not import backup DB (seems diff version) and the other one is historic data was not loaded, just latest 3 measures. All other versions, imported full data history on connect.

jmventar avatar Sep 16 '25 06:09 jmventar

Again the sync logic is as follow: Now, during the first sync, all measurements from the scale are imported. After that, only new measurements that have never been imported will be synced.

oliexdev avatar Sep 27 '25 16:09 oliexdev