Skip to content

Instantly share code, notes, and snippets.

@harding
Created November 15, 2022 00:52
Show Gist options
  • Save harding/94f5460f5dc8833f7e0bac1cdeef4758 to your computer and use it in GitHub Desktop.
Save harding/94f5460f5dc8833f7e0bac1cdeef4758 to your computer and use it in GitHub Desktop.
#!/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