Created
November 15, 2022 00:52
-
-
Save harding/94f5460f5dc8833f7e0bac1cdeef4758 to your computer and use it in GitHub Desktop.
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
#!/bin/bash -eu | |
USER=harding | |
AUTH=FIXME | |
SCALE_GOAL=withings | |
MAX_GOAL=maxweight | |
MAX_WEIGHT=FIXME | |
current_weight=$( curl -s https://www.beeminder.com/api/v1/users/${USER}/goals/${SCALE_GOAL}.json -G -d auth_token="${AUTH}" | jq .curval ) || exit 1 | |
# bc returns 1 if true, 0 if false | |
result=$( echo "$current_weight < $MAX_WEIGHT" | bc ) | |
curl \ | |
https://www.beeminder.com/api/v1/users/${USER}/goals/${MAX_GOAL}/datapoints.json \ | |
-d auth_token="${AUTH}" \ | |
-d value=${result} \ | |
-d comment="added by ${HOSTNAME} at $(date)" \ | |
-d requestid="$( date +%Y-%m-%d )" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment