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

Is the command idempotent? #23

Closed
maruina opened this issue May 18, 2021 · 6 comments · Fixed by #38
Closed

Is the command idempotent? #23

maruina opened this issue May 18, 2021 · 6 comments · Fixed by #38
Labels
bug Something isn't working

Comments

@maruina
Copy link

maruina commented May 18, 2021

Hi, I have the script wrapped in a while loop to run every 15 minutes but I end up having a lot of duplicates on my Garmin Connect as per the screenshot.

image

Am I doing something wrong? The while loop is just something like

while true; do
            withings-sync
            echo "Command completed. Sleeping ${SLEEP} seconds..."
            sleep "${SLEEP}"
done
@stynoo
Copy link
Contributor

stynoo commented May 19, 2021

I noticed in my logs that this behavior started around may 10. Previously, duplicate fit uploads to Garmin where handled by Garmin to show up only once. Unfortunately I can't seem to find a changelog for the Garmin Connect backend services.

There do is a maintenance at the moment (the script won't upload) so lets cross our fingers that they noticed and are rolling out a fix for this.

edit: the maintenance didn't fix this... duplicates are still accepted by Garmin

@DoctorEw
Copy link

I'm seeing the same issue as well. Started on the 4th or 5th of the month for me (maybe the night of the 4th since that only had about 4 or 5 entries and my cronjob is set to run hourly). I may just set it to run once a day around lunch time to be certain for a weigh-in to occur by then, at least until Garmin's API gets fixed

@anonymous-one
Copy link

Hi big thanks for this project... Just got a garmin smart watch and thought I would have to ditch my withings scale as well as 3 years worth of weight data.

I have noticed this as well...

Is it possible to pass a date + time to the --fromdate?

At least then we could locally log last run, and increment by 60 seconds or whatever... Just an idea.

@anonymous-one
Copy link

anonymous-one commented Aug 8, 2021

Warning, I am by no means an expert with python, withings or the garmin APIs...

But I was able to resolve this using the following:

In sync.py update def date_parser(s) to return datetime.strptime(s, '%Y-%m-%d-%H:%M:%S').

This will allow you to pass a --fromdate in the following syntax:

YYYY-MM-DD-HH:MM:SS

So what I am doing is locally recording when the last withings to garmin sync was done and on subsequent requests I am passing a --fromdate with that date + time - 60 seconds, rounded down to 00 seconds.

This way I am basically only sending garmin my latest weight.

I of course did an initial push of all my past data.

This seams to do the trick for me. Its only been up for an hour or so but so far so good. Only getting the latest weigh in sent over.


Bonus round : For those like me who have a fairly well built home iot setup... I am also logging when the scale hits my wifi, and when it does, I have my scripts execute the sync. Of course be sure to script in some niceness checks to make sure that regardless of if the conditions for a sync are met you only hit the withings / germin APIs every XX minutes...

Enjoy!

@Wiigian
Copy link

Wiigian commented Sep 6, 2021

Bonus round : For those like me who have a fairly well built home iot setup... I am also logging when the scale hits my wifi, and when it does, I have my scripts execute the sync. Of course be sure to script in some niceness checks to make sure that regardless of if the conditions for a sync are met you only hit the withings / germin APIs every XX minutes...

Enjoy!

This is brilliant!
How do you detect the scale on Wifi, i'm thinking of pinging it every so often, but I am sure there must be a more elegant solution?

@nanderson
Copy link

I believe there's a PR intended to solve this problem, #38

@longstone longstone linked a pull request Mar 31, 2022 that will close this issue
@longstone longstone added the bug Something isn't working label Mar 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants