Skip to content
6 changes: 5 additions & 1 deletion bin/oref0-cron-nightly.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,9 @@ directory="$PWD"
if [[ $ENABLE =~ autotune ]]; then
# autotune nightly at 4:05am using data from NS
echo "=== Running Autotune at `date` === " | tee -a /var/log/openaps/autotune.log
(oref0-autotune -d=$directory -n=$NIGHTSCOUT_HOST && cat $directory/autotune/profile.json | jq . | grep -q start && cp $directory/autotune/profile.json $directory/settings/autotune.json) 2>&1 | tee -a /var/log/openaps/autotune.log &
(oref0-autotune -d=$directory -n=$NIGHTSCOUT_HOST && \
cat $directory/autotune/profile.json | jq . | grep -q start && \
cp $directory/autotune/profile.json $directory/settings/autotune.json && \
echo Sleeping 60s to let oref0-ns-loop generate a new profile.json to upload && sleep 60 && \
oref0-upload-profile settings/profile.json $NIGHTSCOUT_HOST $API_SECRET) 2>&1 | tee -a /var/log/openaps/autotune.log &
fi
6 changes: 4 additions & 2 deletions bin/oref0-upload-profile.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,12 +120,13 @@ if (!module.parent) {
// Basals

var new_basal = [];
var decimals = 100; // always round basal rates to 0.01 U/h

_.forEach(profiledata.basalprofile, function(basalentry) {

var newEntry = {
time: '' + basalentry.start.substring(0, 5)
, value: '' + +(Math.round(basalentry.rate + 'e+3') + 'e-3')
, value: '' + Math.round( basalentry.rate * decimals) / decimals
, timeAsSeconds: '' + basalentry.minutes * 60
};

Expand Down Expand Up @@ -220,12 +221,13 @@ if (!module.parent) {
// Carb ratios

var new_carb_ratios = [];
var decimals = 10; // always round insulin to carb ratios to 0.1g

_.forEach(profiledata.carb_ratios.schedule, function(carb_entry) {

var new_entry = {
time: carb_entry.start.substring(0, 5)
, value: '' + carb_entry.ratio
, value: '' + Math.round( carb_entry.ratio * decimals) / decimals
, timeAsSeconds: '' + carb_entry.offset * 60
};

Expand Down