Last active
January 16, 2021 15:07
-
-
Save huberf/cde9b0c9b4b4d2804e16a6cb3326edd7 to your computer and use it in GitHub Desktop.
Automated Garmin Step Streak Saving
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import datetime | |
import requests as r | |
USERNAME = '<PLACEHOLDER>' | |
TIMEZONE = -5 # EST timezone offset | |
IFTTT_MAKER_KEY = '<PLACEHOLDER>' | |
GOAL = 10000 | |
tz = datetime.timezone(datetime.timedelta(hours=TIMEZONE)) | |
date = str(datetime.datetime.now(tz))[:10] # gets current date of format '2021-01-14' | |
api_url = 'https://connect.garmin.com/modern/proxy/usersummary-service/usersummary/daily/\ | |
{}?calendarDate={}' | |
data = r.get(api_url.format(USERNAME, date)).json() | |
total_steps = data['totalSteps'] | |
if total_steps < GOAL: | |
print('Under goal at {} steps.'.format(total_steps)) | |
r.get('http://maker.ifttt.com/trigger/garmin_under_goal/with/key/{}?value1={}'. \ | |
format(IFTTT_MAKER_KEY, total_steps)) | |
else: | |
print('Met goal at {} steps.'.format(total_steps)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment