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 #13

Merged
merged 57 commits into from
Sep 22, 2021
Merged

Dev #13

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
86a9517
Merge pull request #1316 from openaps/master
danamlewis Nov 10, 2019
ee1cdf3
Add ability to calculate glucose noise (#1298)
jpcunningh Nov 10, 2019
6bc60eb
Remove aCOBpredBGs (accelerated carbohydrate absorption) as it is not…
tzachi-dar Nov 15, 2019
1f8c400
Allow to upload profile even when the url ends with / (for example: h…
tzachi-dar Nov 16, 2019
62875eb
Make explicit that NS secret prompt will follow (#1320)
old-square-eyes Nov 22, 2019
f3b5207
xdrip-js also works with G6
scottleibrand Dec 1, 2019
cb8e949
fix bug in #1258 breaking don't loop on too-flat CGM data behavior
scottleibrand Dec 2, 2019
b6e831b
clarify CGM too flat error
scottleibrand Dec 2, 2019
2094321
fix glucose-noise lastDelta logic error (#1326)
jpcunningh Dec 3, 2019
f9c8b69
flat CGM data isn't really an error, just a reason to dose neutrally
scottleibrand Dec 4, 2019
b9f6cf5
More comments (#1321)
scottleibrand Dec 4, 2019
f14f6d8
add test to ensure we correctly fall back to dateString property
Dec 4, 2019
87c5813
fix bug by using correct glucose object when parsing current date
Dec 4, 2019
b32880a
encapsulate logic for accessing entry date into a single function
Dec 4, 2019
e9f6922
Mraa ccprog install (#1322)
scottleibrand Dec 6, 2019
d0d8a84
update too-flat language (#1327)
scottleibrand Dec 6, 2019
95cc3cd
Merge branch 'GLUCOSE-GET-LAST' of https://github.com/jakobsandberg/o…
scottleibrand Dec 6, 2019
8f4845c
skip meter bg when getting last glucose (#1328)
jakobsandberg Dec 9, 2019
f889c1a
Merge remote-tracking branch 'origin/dev' into jakobsandberg-GLUCOSE-…
scottleibrand Dec 9, 2019
4f5a325
Merge branch 'jakobsandberg-GLUCOSE-GET-LAST' into dev
scottleibrand Dec 9, 2019
9d4c739
upgrade setuptools to avoid install_requires error per #1303
scottleibrand Dec 10, 2019
f841fa7
set up xdrip-js with DEXCOM_CGM_TX_ID
scottleibrand May 28, 2019
303833c
Add a shutdown function for pi based rigs (#1332)
juehv Dec 15, 2019
c01674b
Ping to default gateways (per network) to see if local connection is …
tzachi-dar Dec 23, 2019
2808a14
Kill ns-loop if it lasts for more than 10 minutes. (#1340)
tzachi-dar Dec 28, 2019
95443cb
simple oref0-simulator (#1325)
scottleibrand Dec 31, 2019
eaac5c0
ignore null glucose records (may fix #1265) (#1324)
scottleibrand Dec 31, 2019
c94b445
Warn users that the status screen is hard coded for the myopenaps dir…
tepidjuice Dec 31, 2019
6648279
Add public ip information to status file (#1331)
juehv Dec 31, 2019
6a1a662
if disk has less than 10MB free, delete something and logrotate (#1337)
scottleibrand Dec 31, 2019
c16a841
whitespace cleanup
scottleibrand Dec 31, 2019
89a90b8
Fix cgm with share2 via nightscout with tokenbased authentication wit…
PieterGit Jan 1, 2020
5b753ad
re-add openaps first-upload (mentioned in docs) (#1338)
scottleibrand Jan 5, 2020
04daea2
wait for silence before running scripts that might use the radio like…
scottleibrand Jan 6, 2020
113a871
Remove unused functions. (#1347)
tzachi-dar Jan 9, 2020
7d58ea9
Add quotation marks around egrep expression. (#1351)
tzachi-dar Jan 21, 2020
90d5ceb
add timeout to oref0-get-ns-entries request call (#1349)
jpcunningh Jan 22, 2020
78cd0a7
Make sure .bash_profile exists (#1354)
cluckj Feb 2, 2020
3cddf42
simulator support for BG target schedules (#1355)
scottleibrand Feb 3, 2020
16b9840
simulator bugfix and better logging (#1356)
scottleibrand Feb 3, 2020
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
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
434 changes: 434 additions & 0 deletions bin/get_profile.py

Large diffs are not rendered by default.

18 changes: 18 additions & 0 deletions bin/glucose-stats.awk
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
BEGIN {
min=1000
if (!min_bg) { min_bg=70 }
if (!max_bg) { max_bg=180 }
}
{ sum+=$1; count++; squares+=$1^2; }
($1 < 39) { next }
($1 < min) { min=$1 }
($1 > max) { max=$1 }
($1 <= max_bg && $1 >= min_bg) { inrange++ }
($1 > max_bg) { high++ }
($1 < min_bg) { low++ }
END { # print "Count: " count;
printf "Count %.0f / Min %.0f / Max %.0f / Average %.1f / StdDev %.1f / ", count, min, max, sum/count, sqrt(squares/count-(sum/count)^2)
#printf "%%TIR / low / high (%.0f-%.0f): ", min_bg, max_bg
printf "%.1f%% TIR / %.1f%% low / %.1f%% high (%.0f-%.0f)\n", inrange/(high+inrange+low)*100, low/(high+inrange+low)*100, high/(high+inrange+low)*100, min_bg, max_bg
printf "%.0f,%.1f,%.1f,%.1f,%.1f", count, sum/count, low/(high+inrange+low)*100, high/(high+inrange+low)*100, sqrt(squares/count-(sum/count)^2)
}
3 changes: 2 additions & 1 deletion bin/mm-format-ns-treatments.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ EOT
# | json -e "this.type = 'mm://openaps/$self'" \
model=$(jq -r . $MODEL)

oref0-normalize-temps $HISTORY \

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
Expand Down
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
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: 2 additions & 0 deletions bin/openaps-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ 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
Expand Down
33 changes: 20 additions & 13 deletions bin/openaps-packages.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,28 +12,35 @@ apt-get install -y sudo
sudo apt-get update && sudo apt-get -y upgrade
sudo apt-get install -y git python python-dev software-properties-common python-numpy python-pip watchdog strace tcpdump screen acpid vim locate lm-sensors || die "Couldn't install packages"

# We require jq >= 1.5 for --slurpfile for merging preferences. Debian Jessie ships with 1.4
# We require jq >= 1.5 for --slurpfile for merging preferences. Debian Jessie ships with 1.4.
if cat /etc/os-release | grep 'PRETTY_NAME="Debian GNU/Linux 8 (jessie)"' &> /dev/null; then
echo "Please consider upgrading your rig to Jubilinux 0.3.0 (Debian Stretch)!"
sudo apt-get -y -t jessie-backports install jq || die "Couldn't install jq from jessie-backports"
else
# Debian Stretch & Buster ship with jq >= 1.5, so install from apt
sudo apt-get -y install jq || die "Couldn't install jq"
fi

# install/upgrade to latest node 8 if neither node 8 nor node 10+ LTS are installed
# Install/upgrade to latest version of node (v10) using apt if neither node 8 nor node 10+ LTS are installed
if ! nodejs --version | grep -e 'v8\.' -e 'v1[02468]\.' &> /dev/null ; then
# nodesource doesn't support armv6
if ! arch | grep -e 'armv6' &> /dev/null ; then
sudo bash -c "curl -sL https://deb.nodesource.com/setup_8.x | bash -" || die "Couldn't setup node 8"
sudo apt-get install -y nodejs=8.* || die "Couldn't install nodejs"
else
sudo apt-get install -y nodejs npm || die "Couldn't install nodejs and npm"
npm install npm@latest -g || die "Couldn't update npm"
fi
## You may also need development tools to build native addons:
##sudo apt-get install gcc g++ make
if getent passwd edison; then
# Only on the Edison, use nodesource setup script to add nodesource repository to sources.list.d, then install nodejs (npm is a part of the package)
curl -sL https://deb.nodesource.com/setup_8.x | bash -
sudo apt-get install -y nodejs=8.* || die "Couldn't install nodejs"
else
sudo apt-get install -y nodejs npm || die "Couldn't install nodejs and npm"
fi

# Upgrade npm to the latest version using its self-updater
sudo npm install npm@latest -g || die "Couldn't update npm"

## You may also need development tools to build native addons:
## sudo apt-get install gcc g++ make
fi

sudo pip install -U openaps || die "Couldn't install openaps toolkit"
# upgrade setuptools to avoid "'install_requires' must be a string" error
sudo pip install setuptools -U # no need to die if this fails
sudo pip install -U --default-timeout=1000 git+https://github.com/openaps/openaps.git || die "Couldn't install openaps toolkit"
sudo pip install -U openaps-contrib || die "Couldn't install openaps-contrib"
sudo openaps-install-udev-rules || die "Couldn't run openaps-install-udev-rules"
sudo activate-global-python-argcomplete || die "Couldn't run activate-global-python-argcomplete"
Expand Down
1 change: 1 addition & 0 deletions bin/oref0-autotune-prep.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ if (!module.parent) {
var glucose_data = JSON.parse(fs.readFileSync(glucose_input, 'utf8'));
} catch (e) {
console.error("Warning: could not parse "+glucose_input);
return console.error("Warning: could not parse "+glucose_input", e);
}

var carb_data = { };
Expand Down
2 changes: 1 addition & 1 deletion bin/oref0-autotune.sh
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ do
cp profile.pump.json profile.json
exit
else
die "Could not run oref0-autotune-core autotune.$i.json profile.json profile.pump.json"
die "Could not run oref0-autotune-core autotune.$i.json profile.json profile.pump.json. Make sure Nightscout contains BG-values for the selected date range, Autotune(Web) does not work without BG-values. See documentation on the how-to check http://nightscout.github.io/nightscout/reports/#day-to-day ."
fi
else
# Copy tuned profile produced by autotune to profile.json for use with next day of data
Expand Down
Loading