Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Some weights measurements discarded incorrectly #175

Open
integeruser opened this issue Sep 23, 2024 · 2 comments
Open

Some weights measurements discarded incorrectly #175

integeruser opened this issue Sep 23, 2024 · 2 comments
Labels
in triage not quite clear whats the issue

Comments

@integeruser
Copy link

Hello, this line of code:

del sync_dict[dt]

incorrectly deletes all entries that may have already been stored in sync_dict[dt] in previous iterations of the loop.

I've looked around briefly but simply removing the line seems the proper fix, and it solves my problem of some weights measurements gone missing.
Thanks!

@longstone
Copy link
Collaborator

Could you please provide an anonymized log?
you can get all the output with 'withings-sync -v'
The statement you found should remove any entry which can or should not be processed.

@longstone longstone added the in triage not quite clear whats the issue label Nov 29, 2024
@integeruser
Copy link
Author

Here's an example log obtained with latest withing-sync from PyPI (should contain a single set of measurements—I've redacted all measurements except the weight with ?):

(.venv)$ python3 --version
(.venv)$ pip list | grep withings
withings-sync                 4.2.7
(.venv)$ withings-sync -f 2024-11-30 -v
2024-11-30 22:09:32,378 - root - DEBUG - withings-sync script version 4.2.7
2024-11-30 22:09:32,378 - root - DEBUG - Script invoked with the following arguments: Namespace(garmin_username='', garmin_password='', trainerroad_username='', trainerroad_password='', fromdate=datetime.datetime(2024, 11, 30, 0, 0), todate=datetime.date(2024, 11, 30), to_fit=False, to_json=False, output=None, no_upload=False, features=[], verbose=True)
2024-11-30 22:09:32,378 - withings - INFO - Refresh Access Token
2024-11-30 22:09:32,383 - urllib3.connectionpool - DEBUG - Starting new HTTPS connection (1): wbsapi.withings.net:443
2024-11-30 22:09:32,631 - urllib3.connectionpool - DEBUG - https://wbsapi.withings.net:443 "POST /v2/oauth2 HTTP/11" 200 220
2024-11-30 22:09:32,636 - root - INFO - Fetching measurements from 2024-11-30 00:00 to 2024-11-30 23:59
2024-11-30 22:09:32,636 - withings - DEBUG - Get Height
2024-11-30 22:09:32,637 - urllib3.connectionpool - DEBUG - Starting new HTTPS connection (1): wbsapi.withings.net:443
2024-11-30 22:09:32,968 - urllib3.connectionpool - DEBUG - https://wbsapi.withings.net:443 "POST /measure?action=getmeas HTTP/11" 200 371
2024-11-30 22:09:32,969 - withings - DEBUG - Height received
2024-11-30 22:09:32,972 - withings - INFO - Get Measurements
2024-11-30 22:09:32,974 - urllib3.connectionpool - DEBUG - Starting new HTTPS connection (1): wbsapi.withings.net:443
2024-11-30 22:09:33,219 - urllib3.connectionpool - DEBUG - https://wbsapi.withings.net:443 "POST /measure?action=getmeas HTTP/11" 200 1454
2024-11-30 22:09:33,220 - withings - DEBUG - Measurements received
2024-11-30 22:09:33,224 - root - DEBUG - 2024-11-30 09:20:17 Detected data:
2024-11-30 22:09:33,224 - root - DEBUG - Weight: 67.57700299999999 kg
2024-11-30 22:09:33,225 - root - DEBUG - Fat Free Mass: ??.??? kg
2024-11-30 22:09:33,225 - root - DEBUG - Fat Ratio: ??.??? %
2024-11-30 22:09:33,225 - root - DEBUG - Fat Mass Weight: ??.??? kg
2024-11-30 22:09:33,225 - root - DEBUG - Muscle Mass: ??.??? kg
2024-11-30 22:09:33,225 - root - DEBUG - Hydration: ??.??? kg
2024-11-30 22:09:33,225 - root - DEBUG - Bone Mass: ??.??? kg
2024-11-30 22:09:33,225 - root - DEBUG - Extracellular Water: ?? kg
2024-11-30 22:09:33,225 - root - DEBUG - unknown: ????
2024-11-30 22:09:33,225 - root - DEBUG - unknown: ????
2024-11-30 22:09:33,225 - root - DEBUG - Record: 2024-11-30 09:20:17, type=weight
height=?.?? m, weight=??.??? kg, fat_ratio=?.??? %, muscle_mass=??.??? kg, percent_hydration=??.??? %, bone_mass=??.??? kg, bmi=??.???
2024-11-30 22:09:33,225 - root - INFO - 2024-11-30 09:20:17 This Withings metric contains no weight data.  Not syncing...
2024-11-30 22:09:33,225 - root - DEBUG - Heart Pulse: ?? bpm
2024-11-30 22:09:33,226 - root - ERROR - Invalid or no data detected
2024-11-30 22:09:33,226 - root - DEBUG - Generating fit data...
2024-11-30 22:09:33,226 - root - INFO - No weight data to sync for FIT file
2024-11-30 22:09:33,226 - root - INFO - No blood pressure data to sync for FIT file
2024-11-30 22:09:33,226 - root - DEBUG - Fit data generated...
2024-11-30 22:09:33,226 - root - DEBUG - Generating json data...
2024-11-30 22:09:33,226 - root - DEBUG - Json data generated...
2024-11-30 22:09:33,226 - root - INFO - No TrainerRoad username or a new measurement - skipping sync
2024-11-30 22:09:33,226 - root - INFO - No Garmin data selected - skipping sync

Note for example ERROR - Invalid or no data detected and INFO - No weight data to sync for FIT file—the weight measurement has been incorrectly discarded.

Here's the log with the code patched as mentioned in my previous comment:

(.venv)$ withings-sync -f 2024-11-30 -v
2024-11-30 22:10:06,723 - root - DEBUG - withings-sync script version 4.2.7
2024-11-30 22:10:06,723 - root - DEBUG - Script invoked with the following arguments: Namespace(garmin_username='', garmin_password='', trainerroad_username='', trainerroad_password='', fromdate=datetime.datetime(2024, 11, 30, 0, 0), todate=datetime.date(2024, 11, 30), to_fit=False, to_json=False, output=None, no_upload=False, features=[], verbose=True)
2024-11-30 22:10:06,723 - withings - INFO - Refresh Access Token
2024-11-30 22:10:06,727 - urllib3.connectionpool - DEBUG - Starting new HTTPS connection (1): wbsapi.withings.net:443
2024-11-30 22:10:06,975 - urllib3.connectionpool - DEBUG - https://wbsapi.withings.net:443 "POST /v2/oauth2 HTTP/11" 200 220
2024-11-30 22:10:06,979 - root - INFO - Fetching measurements from 2024-11-30 00:00 to 2024-11-30 23:59
2024-11-30 22:10:06,979 - withings - DEBUG - Get Height
2024-11-30 22:10:06,981 - urllib3.connectionpool - DEBUG - Starting new HTTPS connection (1): wbsapi.withings.net:443
2024-11-30 22:10:07,272 - urllib3.connectionpool - DEBUG - https://wbsapi.withings.net:443 "POST /measure?action=getmeas HTTP/11" 200 371
2024-11-30 22:10:07,273 - withings - DEBUG - Height received
2024-11-30 22:10:07,275 - withings - INFO - Get Measurements
2024-11-30 22:10:07,277 - urllib3.connectionpool - DEBUG - Starting new HTTPS connection (1): wbsapi.withings.net:443
2024-11-30 22:10:07,505 - urllib3.connectionpool - DEBUG - https://wbsapi.withings.net:443 "POST /measure?action=getmeas HTTP/11" 200 1454
2024-11-30 22:10:07,506 - withings - DEBUG - Measurements received
2024-11-30 22:10:07,508 - root - DEBUG - 2024-11-30 09:20:17 Detected data:
2024-11-30 22:10:07,509 - root - DEBUG - Weight: 67.57700299999999 kg
2024-11-30 22:10:07,509 - root - DEBUG - Fat Free Mass: ??.??? kg
2024-11-30 22:10:07,509 - root - DEBUG - Fat Ratio: ??.??? %
2024-11-30 22:10:07,509 - root - DEBUG - Fat Mass Weight: ??.??? kg
2024-11-30 22:10:07,509 - root - DEBUG - Muscle Mass: ??.??? kg
2024-11-30 22:10:07,509 - root - DEBUG - Hydration: ??.??? kg
2024-11-30 22:10:07,509 - root - DEBUG - Bone Mass: ??.??? kg
2024-11-30 22:10:07,509 - root - DEBUG - Extracellular Water: ?? kg
2024-11-30 22:10:07,509 - root - DEBUG - unknown: ????
2024-11-30 22:10:07,509 - root - DEBUG - unknown: ????
2024-11-30 22:10:07,509 - root - DEBUG - Record: 2024-11-30 09:20:17, type=weight
height=?.?? m, weight=??.??? kg, fat_ratio=?.??? %, muscle_mass=??.??? kg, percent_hydration=??.??? %, bone_mass=??.??? kg, bmi=??.???
2024-11-30 22:10:07,509 - root - INFO - 2024-11-30 09:20:17 This Withings metric contains no weight data.  Not syncing...
2024-11-30 22:10:07,509 - root - DEBUG - Heart Pulse: ?? bpm
2024-11-30 22:10:07,509 - root - DEBUG - Processed data:
2024-11-30 22:10:07,509 - root - DEBUG - date_time=2024-11-30 09:20:17
2024-11-30 22:10:07,509 - root - DEBUG - height=?.??
2024-11-30 22:10:07,509 - root - DEBUG - weight=??.???
2024-11-30 22:10:07,509 - root - DEBUG - fat_ratio=??.???
2024-11-30 22:10:07,509 - root - DEBUG - muscle_mass=??.???
2024-11-30 22:10:07,509 - root - DEBUG - hydration=??.???
2024-11-30 22:10:07,509 - root - DEBUG - percent_hydration=??.???
2024-11-30 22:10:07,509 - root - DEBUG - bone_mass=??.???
2024-11-30 22:10:07,509 - root - DEBUG - pulse_wave_velocity=None
2024-11-30 22:10:07,509 - root - DEBUG - heart_pulse=None
2024-11-30 22:10:07,509 - root - DEBUG - bmi=??.???
2024-11-30 22:10:07,509 - root - DEBUG - raw_data=[<withings_sync.withings2.WithingsMeasure object at 0x1034679d0>, <withings_sync.withings2.WithingsMeasure object at 0x103467750>, <withings_sync.withings2.WithingsMeasure object at 0x103599220>, <withings_sync.withings2.WithingsMeasure object at 0x103598e90>, <withings_sync.withings2.WithingsMeasure object at 0x10344a7b0>, <withings_sync.withings2.WithingsMeasure object at 0x1033b7130>, <withings_sync.withings2.WithingsMeasure object at 0x1033b7ac0>, <withings_sync.withings2.WithingsMeasure object at 0x10352a050>, <withings_sync.withings2.WithingsMeasure object at 0x10352a250>, <withings_sync.withings2.WithingsMeasure object at 0x1034c8f50>]
2024-11-30 22:10:07,510 - root - DEBUG - type=weight
2024-11-30 22:10:07,510 - root - DEBUG - last_dt: 2024-11-30 09:20:17 last_weight: None
2024-11-30 22:10:07,510 - root - DEBUG - Generating fit data...
2024-11-30 22:10:07,510 - root - INFO - No blood pressure data to sync for FIT file
2024-11-30 22:10:07,510 - root - DEBUG - Fit data generated...
2024-11-30 22:10:07,510 - root - DEBUG - Generating json data...
2024-11-30 22:10:07,510 - root - DEBUG - Json data generated...
2024-11-30 22:10:07,510 - root - INFO - No TrainerRoad username or a new measurement - skipping sync
2024-11-30 22:10:07,510 - root - INFO - No Garmin data selected - skipping sync

The weight measurement is in this case not removed.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
in triage not quite clear whats the issue
Projects
None yet
Development

No branches or pull requests

2 participants