Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compress data #1443

Merged
merged 1 commit into from
Dec 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion bin/ns-upload-entries.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ fi

# requires API_SECRET and NIGHTSCOUT_HOST to be set in calling environment (i.e. in crontab)
(
curl -m 30 -s -X POST --data-binary @${ENTRIES} \
curl --compressed -m 30 -s -X POST --data-binary @${ENTRIES} \
${API_SECRET_HEADER} -H "content-type: application/json" \
${REST_ENDPOINT}
) && ( test -n "${OUTPUT}" && touch ${OUTPUT} ; logger "Uploaded ${ENTRIES} to ${NIGHTSCOUT_HOST}" ) || logger "Unable to upload to ${NIGHTSCOUT_HOST}"
Expand Down
4 changes: 2 additions & 2 deletions bin/ns-upload.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@ fi
if [[ "${API_SECRET,,}" =~ "token=" ]]; then
REST_ENDPOINT="${REST_ENDPOINT}?${API_SECRET}"
(test "$ENTRIES" != "-" && cat $ENTRIES || cat )| (
curl -m 30 -s -X POST --data-binary @- \
curl --compressed -m 30 -s -X POST --data-binary @- \
-H "content-type: application/json" \
$REST_ENDPOINT
) && ( test -n "$OUTPUT" && touch $OUTPUT ; logger "Uploaded $ENTRIES to $NIGHTSCOUT_HOST" ) || ( logger "Unable to upload to $NIGHTSCOUT_HOST"; exit 2 )
else
(test "$ENTRIES" != "-" && cat $ENTRIES || cat )| (
curl -m 30 -s -X POST --data-binary @- \
curl --compressed -m 30 -s -X POST --data-binary @- \
-H "API-SECRET: $API_SECRET" \
-H "content-type: application/json" \
$REST_ENDPOINT
Expand Down
2 changes: 2 additions & 0 deletions bin/oref0-get-ns-entries.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,12 +180,14 @@ var oref0_get_ns_engtires = function oref0_get_ns_engtires(argv_params, print_ca
headers["If-Modified-Since"] = lastDate.toISOString();
}

headers["User-Agent"] = 'openaps';
var uri = nsurl + '/api/v1/entries/sgv.json?count=' + records + tokenAuth;
var options = {
uri: uri
, json: true
, timeout: 90000
, headers: headers
, gzip : true
};

request(options, function(error, res, data) {
Expand Down
12 changes: 6 additions & 6 deletions bin/oref0-pushover.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env bash
#!/usr/bin/env bash

source $(dirname $0)/oref0-bash-common-functions.sh || (echo "ERROR: Failed to run oref0-bash-common-functions.sh. Is oref0 correctly installed?"; exit 1)

Expand Down Expand Up @@ -87,7 +87,7 @@ fi
CURL_AUTH='-H api-secret:'${API_SECRET}
fi

if snooze=$(curl -s ${CURL_AUTH} ${URL} | jq '.[] | select(.snooze=="carbsReq") | select(.date>'$(date +%s -d "10 minutes ago")')' | jq -s .[0].date | noquotes | grep -v null); then
if snooze=$(curl --compressed -s ${CURL_AUTH} ${URL} | jq '.[] | select(.snooze=="carbsReq") | select(.date>'$(date +%s -d "10 minutes ago")')' | jq -s .[0].date | noquotes | grep -v null); then
#echo $snooze
#echo date -Is -d @$snooze; echo
touch -d $(date -Is -d @$snooze) monitor/pushover-sent
Expand All @@ -107,7 +107,7 @@ elif [[ $ONLYFOR =~ "insulin" ]] && ! cat $FILE | egrep "maxBolus" > /dev/null;
elif file_is_recent monitor/pushover-sent $SNOOZE; then
echo -n "Last pushover sent less than $SNOOZE minutes ago. "
else
curl -s -F token=$TOKEN -F user=$USER $SOUND_OPTION -F priority=$PRIORITY $PRIORITY_OPTIONS -F "message=$(jq -c "{bg, tick, carbsReq, insulinReq, reason}|del(.[] | nulls)" $FILE) - $(hostname)" https://api.pushover.net/1/messages.json | jq .status| grep 1 >/dev/null && touch monitor/pushover-sent && echo '{"date":'$(epochtime_now)',"device":"openaps://'$(hostname)'","snooze":"carbsReq"}' > /tmp/snooze.json && ns-upload $NIGHTSCOUT_HOST $API_SECRET devicestatus.json /tmp/snooze.json >/dev/null && echo "carbsReq pushover sent."
curl ---compressed s -F token=$TOKEN -F user=$USER $SOUND_OPTION -F priority=$PRIORITY $PRIORITY_OPTIONS -F "message=$(jq -c "{bg, tick, carbsReq, insulinReq, reason}|del(.[] | nulls)" $FILE) - $(hostname)" https://api.pushover.net/1/messages.json | jq .status| grep 1 >/dev/null && touch monitor/pushover-sent && echo '{"date":'$(epochtime_now)',"device":"openaps://'$(hostname)'","snooze":"carbsReq"}' > /tmp/snooze.json && ns-upload $NIGHTSCOUT_HOST $API_SECRET devicestatus.json /tmp/snooze.json >/dev/null && echo "carbsReq pushover sent."
echo
fi

Expand Down Expand Up @@ -152,7 +152,7 @@ else
touch $GLANCES && touch -r $GLANCES -d '-60 mins' $GLANCES
fi

if snooze=$(curl -s ${CURL_AUTH} ${URL} | jq '.[] | select(.snooze=="glance") | select(.date>'$(date +%s -d "$glanceDelay minutes ago")')' | jq -s .[0].date | noquotes | grep -v null); then
if snooze=$(curl --compressed -s ${CURL_AUTH} ${URL} | jq '.[] | select(.snooze=="glance") | select(.date>'$(date +%s -d "$glanceDelay minutes ago")')' | jq -s .[0].date | noquotes | grep -v null); then
#echo $snooze
#echo date -Is -d @$snooze; echo
touch -d $(date -Is -d @$snooze) $GLANCES
Expand Down Expand Up @@ -195,7 +195,7 @@ else
subtext="$carbsMsg${rate}U/h ${duration}m"

# echo "pushover glance text=${text} subtext=${subtext} delta=${delta} title=${title} battery percent=${battery}"
curl -s -F "token=$TOKEN" -F "user=$USER" -F "text=${text}" -F "subtext=${subtext}" -F "count=$bgNow" -F "percent=${battery}" -F "title=${title}" https://api.pushover.net/1/glances.json | jq .status| grep 1 >/dev/null && echo '{"date":'$(epochtime_now)',"device":"openaps://'$(hostname)'","snooze":"glance"}' > /tmp/snooze.json && ns-upload $NIGHTSCOUT_HOST $API_SECRET devicestatus.json /tmp/snooze.json >/dev/null && echo "Glance uploaded and snoozed"
curl --compressed -s -F "token=$TOKEN" -F "user=$USER" -F "text=${text}" -F "subtext=${subtext}" -F "count=$bgNow" -F "percent=${battery}" -F "title=${title}" https://api.pushover.net/1/glances.json | jq .status| grep 1 >/dev/null && echo '{"date":'$(epochtime_now)',"device":"openaps://'$(hostname)'","snooze":"glance"}' > /tmp/snooze.json && ns-upload $NIGHTSCOUT_HOST $API_SECRET devicestatus.json /tmp/snooze.json >/dev/null && echo "Glance uploaded and snoozed"
touch $GLANCES
else
echo -n "Pushover glance last updated less than $glanceDelay minutes ago @ "
Expand Down Expand Up @@ -223,7 +223,7 @@ if ! [ -z "$MAKER_KEY" ] && [[ "$MAKER_KEY" != "null" ]] && cat $FILE | egrep "a

echo $values > $ifttt

curl --request POST \
curl --compressed --request POST \
--header 'Content-Type: application/json' \
-d @$ifttt \
https://maker.ifttt.com/trigger/carbs-required/with/key/${key} && touch monitor/ifttt-sent
Expand Down