Skip to content

Commit

Permalink
carbsReq pushover improvements (#1421)
Browse files Browse the repository at this point in the history
* comment out shared-node cp to avoid full disk

* don't send carbsReq alerts if COB is zero due to clock data parsing error

* run pushover in pump-loop

* run pushover in pump-loop

* check pushover_snooze immediately before sending a pushover

* pathfix

* run pushover in pump-loop instead of cron-every-minute

* don't background pushover for now

* uncomment debug line

* debugging

* debugging

* debugging

* -e to make jq return non-zero if no snooze found

* apparently this line never worked

* comment out debug line

* no newline

* don't print date

* remove extra logging

* fix check for empty MAKER_KEY

* only print snooze message if there's something to snooze

* don't print contents of file

* update Pushover Glances to include temp basal rate*duration

* direction arrows

* U/h

* use NS to coordinate glances snoozes between rigs

* more compact carbsreq string

* make glanceDelay configurable

* better check of whether pushoverGlances is a number

* fix glanceDelay=pushoverGlances if numeric check

* wait_for_silence  before refreshing profile and pumphistory

* fix glanceDelay=pushoverGlances if numeric check

* fix carbhistory egrep syntax

* ls profile.json.new if invalid

* Invalid profile.json.new debugging

* Invalid profile.json.new debugging

* Invalid profile.json.new debugging

* NS uses UTC now

* grep -q exits early w/ 141 in some race conditions: use grep >/dev/null instead

* remove debug lines

* Revert "NS uses UTC now"

This reverts commit e9f8810.

* convert NS UTC date into local time

* don't print

* comment out debug lines

* don't print snooze.json, just the fact we uploaded one

* check that glance api returns status: 1

* don't print snooze.json

* just print the fact we sent a carbsReq pushover

* don't print meal.json (twice)

* less verbose logging after wait_for_silence

* don't print

* check that pushover api returns status: 1

* spacing

* just print COB after refreshing meal.json

* less verbose logging

* print entirer meal.json, colorized

* remove duplicate cat of meal.json

* add delta to glance title

* print last_glance time inline

* display tick instead of delta

* tick before arrow

* remove quotes

* retry w/o new BG after failure to parse clock data

* don't use grep -q to avoid return code 141 race condition

* don't use grep -q to avoid return code 141 race condition

* don't use grep -q to avoid return code 141 race condition

* don't mkdir: directory entries eventually fill up the disk
  • Loading branch information
scottleibrand authored Jun 14, 2022
1 parent 5e4ee98 commit da7015c
Show file tree
Hide file tree
Showing 7 changed files with 104 additions and 57 deletions.
8 changes: 4 additions & 4 deletions bin/oref0-autosens-loop.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ function completed_recently {
# openaps use detect-sensitivity shell monitor/glucose.json settings/pumphistory-24h-zoned.json settings/insulin_sensitivities.json settings/basal_profile.json settings/profile.json monitor/carbhistory.json settings/temptargets.json
function autosens {
# only run autosens if pumphistory-24h is newer than autosens
if find monitor/ -newer settings/autosens.json | grep -q pumphistory-24h-zoned.json \
|| find settings/ -size -5c | grep -q autosens.json \
|| ! find settings/ | grep -q autosens \
if find monitor/ -newer settings/autosens.json | grep pumphistory-24h-zoned.json \
|| find settings/ -size -5c | grep autosens.json \
|| ! find settings/ | grep autosens \
|| ! find settings/autosens.json >/dev/null; then
if oref0-detect-sensitivity monitor/glucose.json monitor/pumphistory-24h-zoned.json settings/insulin_sensitivities.json settings/basal_profile.json settings/profile.json monitor/carbhistory.json settings/temptargets.json > settings/autosens.json.new && cat settings/autosens.json.new | jq .ratio | grep -q [0-9]; then
if oref0-detect-sensitivity monitor/glucose.json monitor/pumphistory-24h-zoned.json settings/insulin_sensitivities.json settings/basal_profile.json settings/profile.json monitor/carbhistory.json settings/temptargets.json > settings/autosens.json.new && cat settings/autosens.json.new | jq .ratio | grep "[0-9]"; then
mv settings/autosens.json.new settings/autosens.json
echo -n "Autosens refreshed: "
else
Expand Down
2 changes: 1 addition & 1 deletion bin/oref0-bash-common-functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,7 @@ function wait_for_silence {
echo -n .
# returns true if it hears pump comms, false otherwise
if ! listen -t $waitfor's' 2>&4 ; then
echo "No interfering pump comms detected from other rigs (this is a good thing!)"
echo " All clear."
echo -n "Continuing oref0-pump-loop at "; date
return 0
else
Expand Down
2 changes: 1 addition & 1 deletion bin/oref0-cron-every-minute.sh
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ if [[ ! -z "$BT_PEB" || ! -z "$BT_MAC" ]]; then
fi

if [[ ! -z "$PUSHOVER_TOKEN" && ! -z "$PUSHOVER_USER" ]]; then
oref0-pushover $PUSHOVER_TOKEN $PUSHOVER_USER 2>&1 >> /var/log/openaps/pushover.log &
#oref0-pushover $PUSHOVER_TOKEN $PUSHOVER_USER 2>&1 >> /var/log/openaps/pushover.log &
fi

# if disk has less than 10MB free, delete something and logrotate
Expand Down
22 changes: 11 additions & 11 deletions bin/oref0-ns-loop.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ main() {
fi
fi

pushover_snooze
#pushover_snooze
ns_temptargets || die "ns_temptargets failed"
ns_meal_carbs || echo "ns_meal_carbs failed"
battery_status
Expand Down Expand Up @@ -73,7 +73,7 @@ function get_ns_bg {
# if ns-glucose.json data is <10m old, no more than 5m in the future, and valid (>38),
# copy cgm/ns-glucose.json over to cgm/glucose.json if it's newer
valid_glucose=$(find_valid_ns_glucose)
if echo $valid_glucose | grep -q glucose; then
if echo $valid_glucose | grep glucose >/dev/null; then
echo Found recent valid BG:
echo $valid_glucose | colorize_json '.[0] | { glucose: .glucose, dateString: .dateString }'
cp -pu cgm/ns-glucose.json cgm/glucose.json
Expand Down Expand Up @@ -104,7 +104,7 @@ function find_valid_ns_glucose {
function ns_temptargets {
#openaps report invoke settings/temptargets.json settings/profile.json >/dev/null
nightscout ns $NIGHTSCOUT_HOST $API_SECRET temp_targets > settings/ns-temptargets.json.new
cat settings/ns-temptargets.json.new | jq .[0].duration | egrep -q [0-9] && mv settings/ns-temptargets.json.new settings/ns-temptargets.json
cat settings/ns-temptargets.json.new | jq .[0].duration | egrep "[0-9]" >/dev/null && mv settings/ns-temptargets.json.new settings/ns-temptargets.json
# TODO: merge local-temptargets.json with ns-temptargets.json
#openaps report invoke settings/ns-temptargets.json settings/profile.json
echo -n "Latest NS temptargets: "
Expand All @@ -119,11 +119,11 @@ function ns_temptargets {

dir_name=~/test_data/oref0-get-profile$(date +"%Y-%m-%d-%H%M")-ns
#echo dir_name = $dir_name
mkdir -p $dir_name
# mkdir -p $dir_name
#cp settings/settings.json settings/bg_targets.json settings/insulin_sensitivities.json settings/basal_profile.json preferences.json settings/carb_ratios.json settings/temptargets.json settings/model.json settings/autotune.json $dir_name

run_remote_command 'oref0-get-profile settings/settings.json settings/bg_targets.json settings/insulin_sensitivities.json settings/basal_profile.json preferences.json settings/carb_ratios.json settings/temptargets.json --model=settings/model.json --autotune settings/autotune.json' | jq . > settings/profile.json.new || die "Couldn't refresh profile"
if cat settings/profile.json.new | jq . | grep -q basal; then
if cat settings/profile.json.new | jq . | grep basal > /dev/null; then
mv settings/profile.json.new settings/profile.json
else
die "Invalid profile.json.new after refresh"
Expand All @@ -134,11 +134,11 @@ function ns_temptargets {
function ns_meal_carbs {
#openaps report invoke monitor/carbhistory.json >/dev/null
nightscout ns $NIGHTSCOUT_HOST $API_SECRET carb_history > monitor/carbhistory.json.new
cat monitor/carbhistory.json.new | jq .[0].carbs | egrep -q [0-9] && mv monitor/carbhistory.json.new monitor/carbhistory.json
cat monitor/carbhistory.json.new | jq .[0].carbs | egrep "[0-9]" >/dev/null && mv monitor/carbhistory.json.new monitor/carbhistory.json

dir_name=~/test_data/oref0-meal$(date +"%Y-%m-%d-%H%M")
#echo dir_name = $dir_name
mkdir -p $dir_name
# mkdir -p $dir_name
#cp monitor/pumphistory-24h-zoned.json settings/profile.json monitor/clock-zoned.json monitor/glucose.json settings/basal_profile.json monitor/carbhistory.json $dir_name


Expand Down Expand Up @@ -191,7 +191,7 @@ function upload {
function upload_ns_status {
set -o pipefail
#echo Uploading devicestatus
grep -q iob monitor/iob.json || die "IOB not found"
grep iob monitor/iob.json >/dev/null || die "IOB not found"
# set the timestamp on enact/suggested.json to match the deliverAt time
touch -d $(cat enact/suggested.json | jq .deliverAt | sed 's/"//g') enact/suggested.json
if ! file_is_recent_and_min_size enact/suggested.json 10; then
Expand All @@ -200,12 +200,12 @@ function upload_ns_status {
return 1
fi
ns_status_file_name=ns-status$(date +"%Y-%m-%d-%T").json
format_ns_status $ns_status_file_name && grep -q iob upload/$ns_status_file_name || die "Couldn't generate ns-status.json"
format_ns_status $ns_status_file_name && grep iob upload/$ns_status_file_name >/dev/null || die "Couldn't generate ns-status.json"
# Delete files older than 24 hours.
find upload -maxdepth 1 -mmin +1440 -type f -name "ns-status*.json" -delete
# Upload the files one by one according to their order.
ls upload/ns-status*.json | while read -r file_name ; do
if ! grep -q iob $file_name ; then
if ! grep iob $file_name >/dev/null ; then
#echo deleteing file $file_name
rm $file_name
continue
Expand Down Expand Up @@ -239,7 +239,7 @@ function upload_recent_treatments {
}

function latest_ns_treatment_time {
nightscout latest-openaps-treatment $NIGHTSCOUT_HOST $API_SECRET | jq -r .created_at
date -Is -d $(nightscout latest-openaps-treatment $NIGHTSCOUT_HOST $API_SECRET | jq -r .created_at)
}

#nightscout cull-latest-openaps-treatments monitor/pumphistory-zoned.json settings/model.json $(openaps latest-ns-treatment-time) > upload/latest-treatments.json
Expand Down
24 changes: 16 additions & 8 deletions bin/oref0-pump-loop.sh
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,17 @@ main() {
fi
fi
touch /tmp/pump_loop_completed -r /tmp/pump_loop_enacted
# run pushover immediately after completing loop for more timely carbsReq notifications without race conditions
PUSHOVER_TOKEN="$(get_pref_string .pushover_token "")"
PUSHOVER_USER="$(get_pref_string .pushover_user "")"
if [[ ! -z "$PUSHOVER_TOKEN" && ! -z "$PUSHOVER_USER" ]]; then
oref0-pushover $PUSHOVER_TOKEN $PUSHOVER_USER # 2>&1 >> /var/log/openaps/pushover.log &
fi

# before each of these (optional) refresh checks, make sure we don't have fresh glucose data
# if we do, then skip the optional checks to finish up this loop and start the next one
if ! glucose-fresh; then
wait_for_silence $upto10s
if onbattery; then
refresh_profile 30
else
Expand Down Expand Up @@ -317,7 +325,7 @@ function smb_suggest {
}
function determine_basal {
cat monitor/meal.json
#cat monitor/meal.json
update_glucose_noise
Expand Down Expand Up @@ -480,7 +488,7 @@ function refresh_after_bolus_or_enact {
function unsuspend_if_no_temp {
# If temp basal duration is zero, unsuspend pump
if (cat monitor/temp_basal.json | jq '. | select(.duration == 0)' | grep -q duration); then
if (cat monitor/temp_basal.json | jq '. | select(.duration == 0)' | grep duration); then
if check_pref_bool .unsuspend_if_no_temp false; then
echo Temp basal has ended: unsuspending pump
mdt resume 2>&3
Expand Down Expand Up @@ -600,15 +608,15 @@ function refresh_pumphistory_and_meal {
dir_name=~/test_data/oref0-meal$(date +"%Y-%m-%d-%H%M")
#echo dir_name = $dir_name
mkdir -p $dir_name
# mkdir -p $dir_name
#cp monitor/pumphistory-24h-zoned.json settings/profile.json monitor/clock-zoned.json monitor/glucose.json settings/basal_profile.json monitor/carbhistory.json $dir_name
if ! retry_return run_remote_command 'oref0-meal monitor/pumphistory-24h-zoned.json settings/profile.json monitor/clock-zoned.json monitor/glucose.json settings/basal_profile.json monitor/carbhistory.json' > monitor/meal.json.new ; then
echo; echo "Couldn't calculate COB"
return 1
fi
try_return check_cp_meal || return 1
echo -n "refreshed: "
cat monitor/meal.json
cat monitor/meal.json | jq -cC .
}
function check_cp_meal {
Expand All @@ -631,7 +639,7 @@ function check_cp_meal {
function calculate_iob {
dir_name=~/test_data/oref0-calculate-iob$(date +"%Y-%m-%d-%H%M")
#echo dir_name = $dir_name
mkdir -p $dir_name
# mkdir -p $dir_name
#cp monitor/pumphistory-24h-zoned.json settings/profile.json monitor/clock-zoned.json settings/autosens.json $dir_name
run_remote_command 'oref0-calculate-iob monitor/pumphistory-24h-zoned.json settings/profile.json monitor/clock-zoned.json settings/autosens.json' > monitor/iob.json.new || { echo; echo "Couldn't calculate IOB"; fail "$@"; }
Expand Down Expand Up @@ -687,7 +695,7 @@ function get_settings {

#dir_name=~/test_data/oref0-get-profile$(date +"%Y-%m-%d-%H%M")-pump
#echo dir_name = $dir_name
mkdir -p $dir_name
# mkdir -p $dir_name
#cp settings/settings.json settings/bg_targets.json settings/insulin_sensitivities.json settings/basal_profile.json preferences.json settings/carb_ratios.json settings/temptargets.json settings/model.json $dir_name

run_remote_command 'oref0-get-profile settings/settings.json settings/bg_targets.json settings/insulin_sensitivities.json settings/basal_profile.json preferences.json settings/carb_ratios.json settings/temptargets.json --model=settings/model.json' 2>&3 | jq . > settings/pumpprofile.json.new || { echo "Couldn't refresh pumpprofile"; fail "$@"; }
Expand All @@ -701,7 +709,7 @@ function get_settings {
# generate settings/profile.json.new with autotune
dir_name=~/test_data/oref0-get-profile$(date +"%Y-%m-%d-%H%M")-pump-auto
#echo dir_name = $dir_name
mkdir -p $dir_name
# mkdir -p $dir_name
#cp settings/settings.json settings/bg_targets.json settings/insulin_sensitivities.json settings/basal_profile.json preferences.json settings/carb_ratios.json settings/temptargets.json settings/model.json settings/autotune.json $dir_name

run_remote_command 'oref0-get-profile settings/settings.json settings/bg_targets.json settings/insulin_sensitivities.json settings/basal_profile.json preferences.json settings/carb_ratios.json settings/temptargets.json --model=settings/model.json --autotune settings/autotune.json' | jq . > settings/profile.json.new || { echo "Couldn't refresh profile"; fail "$@"; }
Expand Down Expand Up @@ -736,7 +744,7 @@ function onbattery {
function wait_for_bg {
if [ "$(get_pref_string .cgm '')" == "mdt" ]; then
echo "MDT CGM configured; not waiting"
elif egrep -q "Warning:" enact/smb-suggested.json 2>&3; then
elif egrep -q "Warning:" enact/smb-suggested.json 2>&3 || egrep -q "Could not parse clock data" monitor/meal.json 2>&3; then
echo "Retrying without waiting for new BG"
elif egrep -q "Waiting [0](\.[0-9])?m ([0-6]?[0-9]s )?to microbolus again." enact/smb-suggested.json 2>&3; then
echo "Retrying microbolus without waiting for new BG"
Expand Down
99 changes: 68 additions & 31 deletions bin/oref0-pushover.sh
Original file line number Diff line number Diff line change
Expand Up @@ -76,21 +76,38 @@ else
PRIORITY_OPTIONS=""
fi

date
#date

if file_is_recent monitor/pushover-sent $SNOOZE; then
echo "Last pushover sent less than $SNOOZE minutes ago."
elif ! file_is_recent "$FILE"; then
#function pushover_snooze {
# check Nightscout to see if another rig has already sent a carbsReq pushover recently
URL=$NIGHTSCOUT_HOST/api/v1/devicestatus.json?count=100
if [[ "${API_SECRET}" =~ "token=" ]]; then
URL="${URL}&${API_SECRET}"
else
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
#echo $snooze
#echo date -Is -d @$snooze; echo
touch -d $(date -Is -d @$snooze) monitor/pushover-sent
#ls -la monitor/pushover-sent | awk '{print $8,$9}'
fi
#}

if ! file_is_recent "$FILE"; then
echo "$FILE more than 5 minutes old"
exit
elif ! cat $FILE | egrep "add'l|maxBolus"; then
echo "No additional carbs or bolus required."
elif [[ $ONLYFOR =~ "carb" ]] && ! cat $FILE | egrep "add'l"; then
echo "No additional carbs required."
elif [[ $ONLYFOR =~ "insulin" ]] && ! cat $FILE | egrep "maxBolus"; then
echo "No additional insulin required."
elif ! cat $FILE | egrep "add'l|maxBolus" > /dev/null; then
echo -n "No carbsReq. "
elif [[ $ONLYFOR =~ "carb" ]] && ! cat $FILE | egrep "add'l" > /dev/null; then
echo -n "No carbsReq. "
elif [[ $ONLYFOR =~ "insulin" ]] && ! cat $FILE | egrep "maxBolus" > /dev/null; then
echo -n "No additional insulin required. "
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 && touch monitor/pushover-sent && echo '{"date":'$(epochtime_now)',"device":"openaps://'$(hostname)'","snooze":"carbsReq"}' | tee /tmp/snooze.json && ns-upload $NIGHTSCOUT_HOST $API_SECRET devicestatus.json /tmp/snooze.json
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."
echo
fi

Expand All @@ -106,6 +123,8 @@ source $HOME/.bash_profile
key=${MAKER_KEY:-"null"}
carbsReq=`jq .carbsReq ${FILE}`
tick=`jq .tick ${FILE}`
tick="${tick%\"}"
tick="${tick#\"}"
bgNow=`jq .bg ${FILE}`
delta=`echo "${tick}" | tr -d +`
delta="${delta%\"}"
Expand All @@ -119,50 +138,68 @@ pushoverGlances=$(get_prefs_json | jq -M '.pushoverGlances')
if [ "${pushoverGlances}" == "null" -o "${pushoverGlances}" == "false" ]; then
echo "pushoverGlances not enabled in preferences.json"
else
# if pushoverGlances is a number instead of just true, use it to set the minutes allowed between glances
re='^[0-9]+$'
if [[ ${pushoverGlances} =~ $re ]]; then
glanceDelay=${pushoverGlances}
else
glanceDelay=10
fi
GLANCES="monitor/last_glance"
GLUCOSE="monitor/glucose.json"
if [ ! -f $GLANCES ]; then
# First time through it will get created older than 10 minutes so it'll fire
touch $GLANCES && touch -r $GLANCES -d '-11 mins' $GLANCES
# First time through it will get created 1h old so it'll fire
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
#echo $snooze
#echo date -Is -d @$snooze; echo
touch -d $(date -Is -d @$snooze) $GLANCES
#ls -la $GLANCES | awk '{print $8,$9}'
fi

if test `find $GLANCES -mmin +10`
if test `find $GLANCES -mmin +$glanceDelay` || cat $FILE | egrep "add'l" >/dev/null
then
enactTime=$(ls -l --time-style=+"%l:%M" ${FILE} | awk '{printf ($6)}')
curTime=$(ls -l --time-style=+"%l:%M" ${FILE} | awk '{printf ($6)}')

lastDirection=`jq -M '.[0] .direction' $GLUCOSE`
lastDirection="${lastDirection%\"}"
lastDirection="${lastDirection#\"}"

rate=`jq -M '.rate' monitor/temp_basal.json`
duration=`jq -M '.duration' monitor/temp_basal.json`
#echo lastDirection=$lastDirection

if [ "${lastDirection}" == "SingleUp" ]; then
direction="+"
direction=""
elif [ "${lastDirection}" == "FortyFiveUp" ]; then
direction="++"
direction=""
elif [ "${lastDirection}" == "DoubleUp" ]; then
direction="+++"
direction="↑↑"
elif [ "${lastDirection}" == "SingleDown" ]; then
direction="-"
direction=""
elif [ "${lastDirection}" == "FortyFiveDown" ]; then
direction="--"
direction=""
elif [ "${lastDirection}" == "DoubleDown" ]; then
direction="---"
direction="↓↓"
else
direction="" # default for NONE or Flat
direction="" # default for NONE or Flat
fi

if [ test cat $FILE | egrep "add'l" ]; then
subtext="cr ${carbsReq}g"
else
subtext="e${enactTime}"
title="${bgNow} ${tick} ${direction} @ ${curTime}"
text="IOB ${iob}, COB ${cob}"
if cat $FILE | egrep "add'l" >/dev/null; then
carbsMsg="${carbsReq}g req "
fi
text="${bgNow}${direction}"
title="cob ${cob}, iob ${iob}"
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
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"
touch $GLANCES
else
echo -n "Pushover glance last updated less than $glanceDelay minutes ago @ "
ls -la $GLANCES | awk '{print $8}'
fi
fi

Expand All @@ -174,7 +211,7 @@ fi
# call with this event that will read out in human language the additional carbs and other
# vital facts. It will leave a voice mail if not answered.

if [[ "$MAKER_KEY" != "null" ]] && cat $FILE | egrep "add'l"; then
if ! [ -z "$MAKER_KEY" ] && [[ "$MAKER_KEY" != "null" ]] && cat $FILE | egrep "add'l"; then
if file_is_recent monitor/ifttt-sent 60; then
echo "carbsReq=${carbsReq} but last IFTTT event sent less than 60 minutes ago."
else
Expand Down
Loading

0 comments on commit da7015c

Please sign in to comment.