Skip to content
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
19 changes: 9 additions & 10 deletions bin/oref0-iftt-notify → bin/oref0-ifttt-notify
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ self=$(basename $0)
# Something like this:
# https://maker.ifttt.com/trigger/{event}/with/key/MyKey
IFTTT_TRIGGER=${IFTTT_TRIGGER-${1}}
IFTT_NOTIFY_USAGE="${2-pump model}"
IFTTT_NOTIFY_USAGE="${2-pump model}"

function help_message ( ) {
cat <<EOF
Expand Down Expand Up @@ -42,18 +42,18 @@ By default $self will check that the stick works, and notify the IFTTT_TRIGGER
endpoint only if the the stick fails to check out. If the stick diagnostics
indicate the carelink stick is working, $self will run:

openaps use $IFTT_NOTIFY_USAGE
openaps use $IFTTT_NOTIFY_USAGE

You can specify which openaps use command to use in the second argument, or by
setting the IFTT_NOTIFY_USAGE environment variable in crontab:
setting the IFTTT_NOTIFY_USAGE environment variable in crontab:

Command line, note the quotes, the second term must be passed as single word.

$self https://maker.ifttt.com/trigger/{event}/with/key/MyKey 'pump model'

Crontab:

IFTT_NOTIFY_USAGE='pump model'
IFTTT_NOTIFY_USAGE='pump model'

Author: @audiefile
EOF
Expand All @@ -72,26 +72,25 @@ help)
help_message
;;
*)
if [[ -z "$IFTTT_TRIGGER" || -z "$IFTT_NOTIFY_USAGE" ]] ; then
if [[ -z "$IFTTT_TRIGGER" || -z "$IFTTT_NOTIFY_USAGE" ]] ; then
help_message
exit 1
fi
;;
esac


empty='""'
# check carelink is working - if not send notification
# maybe switch:
# mm-stick diagnose > /dev/null || curl -X POST $IFTTT_TRIGGER

python -m decocare.stick $(python -m decocare.scan) >/dev/null || curl -X POST $IFTTT_TRIGGER
mm-stick diagnose > /dev/null || curl -X POST $IFTTT_TRIGGER
# python -m decocare.stick $(python -m decocare.scan) >/dev/null || curl -X POST $IFTTT_TRIGGER
echo "Carelink Stick OK"

# check carelink can talk to pump - if not send notification
model=$(openaps use $IFTT_NOTIFY_USAGE)
model=$(openaps use $IFTTT_NOTIFY_USAGE)
echo "Model: " $model
if [ x$model = x$empty ];
if [ -z "$model" ];
then
echo "Model is empty"
curl -X POST $IFTTT_TRIGGER
Expand Down
2 changes: 1 addition & 1 deletion bin/oref0.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ $self <cmd>
Valid commands:
oref0 env - print information about environment.
oref0 pebble
oref0 iftt-notify
oref0 ifttt-notify
oref0 get-profile
oref0 calculate-iob
oref0 determine-basal
Expand Down