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

Dev #1

Open
wants to merge 61 commits into
base: look-ahead-dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
188487b
Upload NS status when possible. (#1346)
tzachi-dar Feb 14, 2020
e777301
deprecate adv_target_adjustments; reorder code for readability (#1344)
scottleibrand Feb 14, 2020
7571845
deprecate/remove support for max_bg and wide_bg_target_range (#1345)
scottleibrand Feb 14, 2020
38732f8
target_bg preference (#1358)
scottleibrand Feb 14, 2020
236b82e
Only install local hostspot if selected (#1323)
scottleibrand Feb 14, 2020
c37b8c4
Installer fixes (#1366)
cluckj Feb 25, 2020
504a478
shared-node (#1361)
scottleibrand Mar 17, 2020
1aed0e9
Fix pancreabble config paths (#1372)
kurbezz May 13, 2020
5313363
calculate effective temp basal rate for Omnipod Loop (#1364)
scottleibrand Jun 23, 2020
b51cfe2
maxDelta bg % threshold as hidden preference (#1382)
Foxy7 Aug 30, 2020
06f2ed4
add mills to status upload to reduce NS client workload (#1385)
jpcunningh Sep 5, 2020
2835986
correct ns sgv query (#1386)
jpcunningh Sep 12, 2020
37a50e4
Fix issue 1377, install correct version of py-parsedatetime (#1387)
sksksksksksksk Sep 18, 2020
5635387
equal sign typo (#1388)
diabeticpilot Nov 22, 2020
1d9e5f5
Update app.py to show sgv via workaround (#1391)
Foxy7 Jan 5, 2021
bec71ed
Fix oref0-ns-loop.sh pushover_snooze NS authorization (#1393)
jpcunningh Apr 20, 2021
839a250
Improve error message on Autotune run without BG-data (#1404)
petervanrijt Jul 22, 2021
7157ef4
Fix SyntaxError for unexpected token on console.error (#1410)
geekygirlsarah Oct 17, 2021
1954758
rewind, prime and battery indicates change (#1409)
Foxy7 Dec 11, 2021
1ec3528
Bugfixes (#1411)
jimrandomh Dec 11, 2021
c454ecd
per #1401 set highest sensitivity on low TT and halfBasal (#1403)
jncchds Dec 18, 2021
fe6e492
replace git:// with https:// (#1398)
Foxy7 Dec 18, 2021
d15d8d4
Enable SMB when BG greater than specified value (#1365)
stevebell117 Dec 18, 2021
d8af80b
Add a script to delete device status entries that are older than 2 mo…
tzachi-dar Dec 18, 2021
cb133de
Fix python script and allow autotune prep/core to write to file direc…
hsghori Dec 18, 2021
da70837
fix #1405 - rT.reason extended (#1415)
mountrcg Dec 18, 2021
912ab07
Tzachi shared node phase2 (#1370)
tzachi-dar Dec 20, 2021
5d0984e
comment out shared-node cp to avoid full disk (#1416)
scottleibrand Dec 21, 2021
5e4ee98
define undefined var dev5m (#1418)
scottleibrand Jan 5, 2022
da7015c
carbsReq pushover improvements (#1421)
scottleibrand Jun 14, 2022
f35b4ff
Support for Debian Bullseye and aarch64 (Raspberry Pi OS/Bullseye 64 …
dcacklam Jun 19, 2022
7d53991
omit string formating in convert_bg (#1414)
mountrcg Jun 19, 2022
8881c7f
Improved handling of node installation (& miscellaneous improvements)…
ChanceHarrison Sep 10, 2022
2162018
TODO: revert before release; use dev/bin/openaps-packages.sh
scottleibrand Sep 10, 2022
3a730ed
check out the specified branch when cloning
scottleibrand Sep 10, 2022
a8ec51c
use golangversion=1.19.1 and go install to fix #1435
scottleibrand Sep 11, 2022
84f1011
symlink Go-mmtune to point to oref0-mmtune
scottleibrand Sep 18, 2022
151b1ab
Revert "symlink Go-mmtune to point to oref0-mmtune"
scottleibrand Sep 18, 2022
9c20dc6
install mmtune
scottleibrand Sep 18, 2022
e354807
symlink /usr/local/bin/Go-mmtune to point to /root/go/bin/mmtune
scottleibrand Sep 18, 2022
399e3d6
have to go install each medtronic command individually
scottleibrand Sep 18, 2022
fdb2a16
go install puts things in /root/go/bin/
scottleibrand Sep 18, 2022
d08c86f
have to comment out if clause if it has no uncommented contents
scottleibrand Sep 18, 2022
f6ac451
use ... to install all medtronic commands
scottleibrand Sep 18, 2022
4248d68
don't die if Go-mmtune symlink already exists
scottleibrand Sep 18, 2022
12d6024
fix path to openaps.jq
scottleibrand Sep 18, 2022
7c85d32
wget openaps.jq instead of symlinking to the 20210712211734 version
scottleibrand Sep 19, 2022
80493da
fix(lib/iob): Move value checks up to index.js
Oct 22, 2022
abf9c6b
Merge branch 'ChanceHarrison-chance/fix-1436' (#1437) into dev
scottleibrand Dec 9, 2022
1a25d53
Use compression for operations that go to nightscout. (#1443)
tzachi-dar Dec 29, 2022
673dbc6
convert_bg missing in many statements for rT (#1438)
mountrcg Jan 16, 2023
10f9e27
Revert "fix(lib/iob): Move value checks up to index.js"
scottleibrand Mar 5, 2023
9ac3910
wait upto45s and try preflight; if successful, refresh pumphistory, e…
scottleibrand Aug 20, 2023
bc37601
0.7.1
scottleibrand Jun 19, 2022
8cae7b3
fix missing declaration
hpeuscher Sep 14, 2023
9585e5a
Fixed NS perms checking
inventor96 Mar 25, 2024
c0578dc
Removed duplicate line
inventor96 Mar 25, 2024
edf8bf6
Fixed NS perms checking
inventor96 Mar 25, 2024
2595eca
Removed duplicate line
inventor96 Mar 25, 2024
9b57b06
Revert scope promotion
inventor96 Mar 26, 2024
3430f6b
rT.reason missing colons (:)
Jon-b-m Apr 18, 2024
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,6 @@ bin/__pycache__
package-lock.json

*.pyc

bash-unit-test-temp

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ API_SECRET="..." NIGHTSCOUT_HOST=localhost:1337 ns-upload-entries <input> <outpu
### Get the source

```
git clone git://github.com/openaps/oref0.git
git clone https://github.com/openaps/oref0.git
cd oref0
git checkout dev
git checkout -b wip/my-enhancement-fix-or-proposal
Expand Down
13 changes: 11 additions & 2 deletions bin/mm-format-ns-treatments.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,25 @@ EOT
# | json -e "this.type = 'mm://openaps/$self'" \
model=$(jq -r . $MODEL)

oref0-normalize-temps $HISTORY \
#load ns event preferences
PREF=${4-preferences.json}
rewind_indicates_cartridge_change=$(jq -r .rewind_indicates_cartridge_change $PREF)
prime_indicates_pump_site_change=$(jq -r .prime_indicates_pump_site_change $PREF)
battery_indicates_battery_change=$(jq -r .battery_indicates_battery_change $PREF)

run_remote_command "oref0-normalize-temps $HISTORY" \
| jq '[ .[]
| .medtronic = ( [ "mm://openaps/'$self'/", ( . | if ._type then ._type else .eventType end ) ] | join("") )
| .created_at = if .created_at then .created_at else .timestamp end
| .enteredBy = "openaps://medtronic/'$model'"
| if .glucose and (.glucoseType | not) and .glucose > 0 then .glucoseType = .enteredBy else . end
| if ._type == "Rewind" and "'$rewind_indicates_cartridge_change'" == "true" then .eventType = "Insulin Change" else . end
| if ._type == "Prime" and .type == "fixed" and "'$prime_indicates_pump_site_change'" == "true" then .eventType = "Site Change" else . end
| if ._type == "Battery" and "'$battery_indicates_battery_change'" == "true" then .eventType = "Pump Battery Change" else . end
| .eventType = if .eventType then .eventType else "Note" end
| if ._type == "AlarmSensor" and .alarm_description then .notes = .alarm_description else . end
| ( if .notes then .notes else "" end ) as $note
| if ( .eventType == "Note" ) and ( .alarm_description | not ) then .notes = ( [ ._type, "'" $model "'", $note ] | join("") ) else . end
| if ( .eventType == "Note" or .eventType == "Insulin Change" or .eventType == "Site Change" or .eventType == "Pump Battery Change" ) and ( .alarm_description | not ) then .notes = ( [ ._type, "'" $model "'", $note ] | join("") ) else . end
]' \
> $OUTPUT

2 changes: 1 addition & 1 deletion bin/nightscout.sh
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ ns)
| openaps use ${ZONE} select --date dateString --current now --gaps - ${FILE} | jq .
;;
latest-entries-time)
PREVIOUS_TIME=$(ns-get host $NIGHTSCOUT_HOST entries.json 'find[type]=sgv' | jq .[0])
PREVIOUS_TIME=$(ns-get host $NIGHTSCOUT_HOST entries.json 'find[type][$eq]=sgv' | jq .[0])
test -z "${PREVIOUS_TIME}" && echo -n 0 || echo $PREVIOUS_TIME | jq .dateString
exit 0
;;
Expand Down
60 changes: 60 additions & 0 deletions bin/ns-delete-old-devicestatus.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#!/bin/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)

usage "$@" <<EOF
Usage: $self --find <NIGHTSCOUT_HOST> <API_SECREAT> <number_of_days>- No-op version, find out what delete would do.
$self delete <NIGHTSCOUT_HOST> <API_SECREAT> <number_of_days> - move entries from NIGHTSCOUT_HOST devicestatus collection to "$HOME/myopenaps/backup
$self nightly <number_of_days> - move entries from NIGHTSCOUT_HOST devicestatus collection to "$HOME/myopenaps/backup
EOF

function write_backup() {
json -a -o jsony-0 >> $BACKUP_DIR/devicestatus.txt
}

export API_SECRET
test -n "$3" && API_SECRET=$(nightscout hash-api-secret $3)
test -n "$4" && NUM_DAYS=$4
BACKUP_DIR="$HOME/myopenaps"/backup
mkdir -p $BACKUP_DIR

ENDPOINT=$2/api/v1/devicestatus

if [ $1 = "nightly" ]; then
test -n "$2" && NUM_DAYS=$2
ENDPOINT=$NIGHTSCOUT_HOST/api/v1/devicestatus
fi

if [[ -z "$API_SECRET" || -z "$NUM_DAYS" ]] ; then
test -z "$API_SECRET" && echo API_SECRET undefined.
test -z "$NUM_DAYS" && echo NUM_DAYS undefined.
print_usage
exit 1;
fi

date_string=$(date -d "-$NUM_DAYS days" +%Y-%m-%d)
fetch_cmd="curl --compressed -s -g $ENDPOINT.json?find\[created_at\]\[\\"\$"lte\]=$date_string\&count=100000"
delete_cmd="curl -X DELETE -H \"API-SECRET: $API_SECRET\" -s -g $ENDPOINT.json?find\[created_at\]\[\\"\$"lte\]=$date_string\&count=100000"

case "$1" in
--find)
echo $fetch_cmd
echo $delete_cmd
;;
delete)
#echo $fetch_cmd
#echo $delete_cmd
eval $fetch_cmd | write_backup
eval $delete_cmd
;;
nightly)
#echo $fetch_cmd
#echo $delete_cmd
eval $fetch_cmd | write_backup
eval $delete_cmd
;;
*|help|--help|-h)
print_usage
exit 1;
;;
esac
70 changes: 53 additions & 17 deletions bin/ns-status.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@
'use strict';

var os = require("os");
var fs = require('fs');
var moment = require("moment");

var requireUtils = require('../lib/require-utils');
var safeRequire = requireUtils.safeRequire;
var requireWithTimestamp = requireUtils.requireWithTimestamp;
var safeLoadFile = requireUtils.safeLoadFile;

/*
Prepare Status info to for upload to Nightscout
Expand All @@ -23,7 +25,7 @@ var requireWithTimestamp = requireUtils.requireWithTimestamp;

*/

function mmtuneStatus (status) {
function mmtuneStatus (status, cwd, mmtune_input) {
var mmtune = requireWithTimestamp(cwd + mmtune_input);
if (mmtune) {
if (mmtune.scanDetails && mmtune.scanDetails.length) {
Expand All @@ -35,7 +37,7 @@ function mmtuneStatus (status) {
}
}

function preferencesStatus (status) {
function preferencesStatus (status, cwd ,preferences_input) {
var preferences = requireWithTimestamp(cwd + preferences_input);
if (preferences) {
status.preferences = preferences;
Expand All @@ -47,8 +49,8 @@ function preferencesStatus (status) {
}
}

function uploaderStatus (status) {
var uploader = require(cwd + uploader_input);
function uploaderStatus (status, cwd, uploader_input) {
var uploader = JSON.parse(fs.readFileSync(cwd + uploader_input, 'utf8'));
if (uploader) {
if (typeof uploader === 'number') {
status.uploader = {
Expand All @@ -60,9 +62,12 @@ function uploaderStatus (status) {
}
}

if (!module.parent) {

var argv = require('yargs')


var ns_status = function ns_status(argv_params) {

var argv = require('yargs')(argv_params)
.usage("$0 <clock.json> <iob.json> <suggested.json> <enacted.json> <battery.json> <reservoir.json> <status.json> [--uploader uploader.json] [mmtune.json] [--preferences preferences.json]")
.option('preferences', {
alias: 'p',
Expand All @@ -77,10 +82,16 @@ if (!module.parent) {
default: false
})
.strict(true)
.fail(function (msg, err, yargs) {
if (err) {
return console.error('Error found', err);
}
return console.error('Parsing of command arguments failed', msg)
})
.help('help');

var params = argv.argv;
var inputs = params._;

var clock_input = inputs[0];
var iob_input = inputs[1];
var suggested_input = inputs[2];
Expand All @@ -94,9 +105,11 @@ if (!module.parent) {

if (inputs.length < 7 || inputs.length > 8) {
argv.showHelp();
process.exit(1);
return;
}

// TODO: For some reason the following line does not work (../package.json ia not found).
//var pjson = JSON.parse(fs.readFileSync('../package.json', 'utf8'));
var pjson = require('../package.json');

var cwd = process.cwd() + '/';
Expand All @@ -117,6 +130,7 @@ if (!module.parent) {
if (iobArray && iobArray.length) {
iob = iobArray[0];
iob.timestamp = iob.time;
iob.mills = moment(iob.time).valueOf();
delete iob.time;
}

Expand All @@ -129,6 +143,14 @@ if (!module.parent) {
}
}

if (enacted && enacted.timestamp) {
enacted.mills = moment(enacted.timestamp).valueOf();
}

if (suggested && suggested.timestamp) {
suggested.mills = moment(suggested.timestamp).valueOf();
}

var status = {
device: 'openaps://' + os.hostname(),
openaps: {
Expand All @@ -138,27 +160,41 @@ if (!module.parent) {
version: pjson.version
},
pump: {
clock: safeRequire(cwd + clock_input),
battery: safeRequire(cwd + battery_input),
reservoir: safeRequire(cwd + reservoir_input),
clock: safeLoadFile(cwd + clock_input),
battery: safeLoadFile(cwd + battery_input),
reservoir: safeLoadFile(cwd + reservoir_input),
status: requireWithTimestamp(cwd + status_input)
}
},
created_at: new Date()
};

if (mmtune_input) {
mmtuneStatus(status);
mmtuneStatus(status, cwd, mmtune_input);
}

if (preferences_input) {
preferencesStatus(status);
preferencesStatus(status, cwd ,preferences_input);
}

if (uploader_input) {
uploaderStatus(status);
uploaderStatus(status, cwd, uploader_input);
}

console.log(JSON.stringify(status));
return JSON.stringify(status);
} catch (e) {
return console.error("Could not parse input data: ", e);
}
}

if (!module.parent) {
// remove the first parameter.
var command = process.argv;
command.shift();
command.shift();
var result = ns_status(command);
if(result !== undefined) {
console.log(result);
}
}

exports = module.exports = ns_status
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
17 changes: 6 additions & 11 deletions bin/openaps-install.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env bash
set -e

BRANCH=${1:-master}
BRANCH=${1:-dev}
read -p "Enter your rig's new hostname (this will be your rig's "name" in the future, so make sure to write it down): " -r
myrighostname=$REPLY
echo $myrighostname > /etc/hostname
Expand Down Expand Up @@ -42,21 +42,16 @@ if cat /etc/os-release | grep 'PRETTY_NAME="Debian GNU/Linux 8 (jessie)"' &> /de
echo "Acquire::Check-Valid-Until false;" | tee -a /etc/apt/apt.conf.d/10-nocheckvalid
# Replace apt sources.list with archive.debian.org locations
echo -e "deb http://security.debian.org/ jessie/updates main\n#deb-src http://security.debian.org/ jessie/updates main\n\ndeb http://archive.debian.org/debian/ jessie-backports main\n#deb-src http://archive.debian.org/debian/ jessie-backports main\n\ndeb http://archive.debian.org/debian/ jessie main contrib non-free\n#deb-src http://archive.debian.org/debian/ jessie main contrib non-free" > /etc/apt/sources.list
echo "Please consider upgrading your rig to Jubilinux 0.3.0 (Debian Stretch)!"
echo "Jubilinux 0.2.0, based on Debian Jessie, is no longer receiving security or software updates!"
fi

#Workaround for Jubilinux to install nodejs/npm from nodesource
if getent passwd edison &> /dev/null; then
#Use nodesource setup script to add nodesource repository to sources.list.d
curl -sL https://deb.nodesource.com/setup_8.x | bash -
fi

#dpkg -P nodejs nodejs-dev
# TODO: remove the `-o Acquire::ForceIPv4=true` once Debian's mirrors work reliably over IPv6
apt-get -o Acquire::ForceIPv4=true update && apt-get -o Acquire::ForceIPv4=true -y dist-upgrade && apt-get -o Acquire::ForceIPv4=true -y autoremove
apt-get -o Acquire::ForceIPv4=true update && apt-get -o Acquire::ForceIPv4=true install -y sudo strace tcpdump screen acpid vim python-pip locate ntpdate ntp
apt-get -o Acquire::ForceIPv4=true update && apt-get -o Acquire::ForceIPv4=true install -y sudo strace tcpdump screen acpid vim locate ntpdate ntp
#check if edison user exists before trying to add it to groups

grep "PermitRootLogin yes" /etc/ssh/sshd_config || echo "PermitRootLogin yes" > /etc/ssh/sshd_config
grep "PermitRootLogin yes" /etc/ssh/sshd_config || echo "PermitRootLogin yes" >>/etc/ssh/sshd_config

if getent passwd edison > /dev/null; then
echo "Adding edison to sudo users"
Expand All @@ -71,7 +66,7 @@ sed -i "s/daily/hourly/g" /etc/logrotate.conf
sed -i "s/#compress/compress/g" /etc/logrotate.conf

curl -s https://raw.githubusercontent.com/openaps/oref0/$BRANCH/bin/openaps-packages.sh | bash -
mkdir -p ~/src; cd ~/src && ls -d oref0 && (cd oref0 && git checkout $BRANCH && git pull) || git clone git://github.com/openaps/oref0.git
mkdir -p ~/src; cd ~/src && ls -d oref0 && (cd oref0 && git checkout $BRANCH && git pull) || git clone https://github.com/openaps/oref0.git -b $BRANCH
echo "Press Enter to run oref0-setup with the current release ($BRANCH branch) of oref0,"
read -p "or press ctrl-c to cancel. " -r
cd && ~/src/oref0/bin/oref0-setup.sh
Loading