Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Adding ns-upload-glucose.sh
  • Loading branch information
cjo20 committed Sep 26, 2015
commit 0bc352dabc379a992f1cbeeb4b69523d9e4ee3e5
17 changes: 17 additions & 0 deletions bin/ns-upload-glucose.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash

# Author: Ben West, Maintainer: Scott Leibrand

HISTORY=${1-glucosehistory.json}
OUTPUT=${2-glucosehistory.ns.json}
#TZ=${3-$(date +%z)}

cat $HISTORY | \
json -e "this.medtronic = this._type;" | \
json -e "this.dateString = this.date + '$(date +%z)'" | \
json -e "this.date = new Date(this.dateString).getTime();" | \
json -e "this.type = 'medtronic'" \
> $OUTPUT

# requires API_SECRET and NIGHTSCOUT_HOST to be set in calling environment (i.e. in crontab)
curl -s -X POST --data-binary @$OUTPUT -H "API-SECRET: $API_SECRET" -H "content-type: application/json" $NIGHTSCOUT_HOST/api/v1/entries.json >/dev/null && ( touch /tmp/openaps.online && echo "Uploaded $OUTPUT to $NIGHTSCOUT_HOST" ) || echo "Unable to upload to $NIGHTSCOUT_HOST"