Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Add gar_wg_state and gar_bp_state variables to Sync.py #153

Merged
merged 3 commits into from
Dec 27, 2023

Conversation

AlaskaJedi
Copy link
Contributor

Error accessing variable 'gar_wg_state' when only using Withings blood pressure device. Moved set_lastsyn() under reach fit_data if statements so the other variable isn't used..

UnboundLocalError: cannot access local variable 'gar_wg_state' where it is not associated with a value

Error accessing variable 'gar_wg_state' when only using Withings blood pressure device.  Moved set_lastsyn() under reach fit_data if statements so the other variable isn't used..

UnboundLocalError: cannot access local variable 'gar_wg_state' where it is not associated with a value
@stynoo
Copy link
Contributor

stynoo commented Dec 26, 2023

Oh, I see what's going on here. This most likely also explains the duplicate entries we see sometimes in the blood pressure stats.
There is no need to duplicate the code block, just declare both variables at the start of the function.
Try something like this:

        # Upload to Garmin Connect
        if ARGS.garmin_username and (
            fit_data_weight is not None or fit_data_blood_pressure is not None
        ):
            logging.debug("attempting to upload fit file...")
            gar_wg_state = None
            gar_bp_state = None

Error accessing variable 'gar_wg_state' when only using Withings blood pressure device.  Added variables to prevent this.

UnboundLocalError: cannot access local variable 'gar_wg_state' where it is not associated with a value
@AlaskaJedi AlaskaJedi changed the title Update sync.py Add gar_wg_state and gar_bp_state variables to Sync.py Dec 27, 2023
@AlaskaJedi
Copy link
Contributor Author

@stynoo thanks, that is cleaner than my approach, and I can confirm it works when syncing only BP data. (I don't own the scale)

@@ -470,6 +472,7 @@ def sync():
logging.info(
"Fit file with blood pressure information uploaded to Garmin Connect"
)
# Save this sync so we don't re-download the same data again (if no range has been specified)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no longer need for this comment here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed, thanks!

Removed unneeded comment
@stynoo
Copy link
Contributor

stynoo commented Dec 27, 2023

lgtm!

@longstone longstone merged commit 0d8025c into jaroslawhartman:master Dec 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants