Skip to content

Commit

Permalink
add more help messages, add --current now to select
Browse files Browse the repository at this point in the history
Wrap usage of another device in `ns` as argument.
Ping @jasoncalabrese.
  • Loading branch information
bewest committed May 3, 2016
1 parent b6593f4 commit 0d55b4e
Showing 1 changed file with 38 additions and 8 deletions.
46 changes: 38 additions & 8 deletions bin/nightscout.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,30 @@ TODO: improve help
openaps use ns shell get entries.json 'count=10'
openaps use ns shell upload treatments.json recently/combined-treatments.json
-h This message.
get type args Get records of type from Nightscout matching args.
upload endpoint file Upload a file to the Nightscout endpoint.
latest-treatment-time - get latest treatment time from Nightscout
format-recent-history-treatments history model - Formats medtronic pump history and model into Nightscout compatible treatments.
upload-non-empty-treatments file - Upload a non empty treatments file to Nightscout.
lsgaps tz entries - Re-use openaps timezone device to find gaps in a type (entries) by default.
-h This message.
get type args Get records of type from
Nightscout matching args.
upload endpoint file Upload a file to the Nightscout endpoint.
latest-treatment-time - get latest treatment time from Nightscout
format-recent-history-treatments history model - Formats medtronic pump
history and model into
Nightscout compatible
treatments.
format-recent-type ZONE type file - Selects elements from the
file where the elements would
satisfy a gap in the last 1000
Nightscout records.
upload-non-empty-treatments file - Upload a non empty treatments
file to Nightscout.
lsgaps tz entries - Re-use openaps timezone device
to find gaps in a type (entries)
by default.
upload-non-empty-type type file
status - Retrieve status
preflight - NS preflight
EOF
}
case $NAME in
Expand All @@ -74,6 +91,19 @@ ns)
exec ns-get host $NIGHTSCOUT_HOST $*
exit 0
;;
preflight)
STATUS=$(ns-get host $NIGHTSCOUT_HOST status.json | json status)
if [[ $STATUS = "ok" ]] ; then
echo "true" | json -j
exit 0
else
echo "false" | json -j
exit 1
fi
;;
status)
ns-get host $NIGHTSCOUT_HOST status.json | json
;;
lsgaps)
ZONE=${1-'tz'}
TYPE=${2-'entries'}
Expand All @@ -95,7 +125,7 @@ ns)
test ! -e ${FILE} && "Third argument, contents to upload, FILE, does not exist" && exit 1
test ! -r ${FILE} && "Third argument, contents to upload, FILE, not readable." && exit 1
openaps use ns shell lsgaps ${ZONE} ${TYPE} \
| openaps use ${ZONE} select --gaps - ${FILE} | json
| openaps use ${ZONE} select --current now --gaps - ${FILE} | json
;;
latest-entries-time)
PREVIOUS_TIME=$(ns-get host $NIGHTSCOUT_HOST entries.json 'find[type]=sgv' | json 0)
Expand Down

3 comments on commit 0d55b4e

@jasoncalabrese
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need -non-empty

@jasoncalabrese
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be nice to add something for getting just carb or temp target treatments, like the hacks I'm using here:
https://github.com/jasoncalabrese/indy-e3b/blob/master/openaps.ini#L27-L28

passing event type or maybe other find params?

@bewest
Copy link
Member Author

@bewest bewest commented on 0d55b4e May 3, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

openaps use ns shell get treatments.json "find[created_at][\$gte]=$(date -d '6 hours ago' -Iminutes)&find[eventType]=Temporary+Target"

  • openaps use ns shell get treatmnts.json "find[created_at][\$gte]=$(date -d '6 hours ago' -Iminutes)&find[eventType]=Temp+Basal"
  • openaps use ns shell get treatments.json "find[created_at][\$gte]=$(date -d '6 hours ago' -Iminutes)&find[carbs][\$exists]=true" should do the same thing :-D

Please sign in to comment.