Skip to content

Conversation

@sulkaharo
Copy link
Collaborator

Check for xDrip CGM noise, issue neutral temps in case of extreme noise (similar to Dexcom ??? CGM state)

@philipgo
Copy link
Contributor

What does XDrip with G4 or G5 report if blood glucose actually is 38? If it reports 38 + noise level, I think this information should be used.

@sulkaharo
Copy link
Collaborator Author

@drnoname82 CGMs don’t report very low glucose levels as a numeric value, as the opposes to just LOW. I suspect this is both due to safety reasons (communicate a rapid treatment is needed right now) but also because super low glucose can’t be measured reliably with the current tech, so the sensor can’t distinguish between a malfunction and low glucose when we go to very low numbers.

@tepidjuice
Copy link
Contributor

Does the xdripAPS script upload noise values to the rig?

@philipgo
Copy link
Contributor

@sulkaharo I was just wondering whether the transmitter transmits "low" or whether it transmits e.g 38 and the receiver turns it into low. We have not had any BG this low since using OpenAPS (amazing), so I cannot check what XDrip reports. I just want to be sure that during a severe low OpenAPS would zero temp when being used with XDrip instead of defaulting to ""CGM is calibrating, in ??? state or noise is high" because reporting behavior of XDrip might differ from Dexcom

@tepidjuice Interesting point! I think XDripAPS could use an overhaul to also upload treatments to the rig.

@tim2000s
Copy link
Contributor

@tepidjuice it just copies the xdrip data across directly.

@philipgo
Copy link
Contributor

@sulkaharo I found a pre-looping entry that seems to show that XDrip reports values < 39

{
    "_id": {
        "$oid": "123456"
    },
    "device": "xDrip-DexcomG5",
    "date": 1497191959611,
    "dateString": "2017-06-11T16:39:19.611+0200",
    "sgv": 38,
    "direction": "NOT COMPUTABLE",
    "type": "sgv",
    "filtered": 0,
    "unfiltered": 0,
    "rssi": 100,
    "noise": 1,
    "delta": -1.75
}

@sulkaharo
Copy link
Collaborator Author

@drnoname82 It does, but that's probably not actionable data. @jamorham might have insight into the data quality at these levels, but I'm pretty sure Dexcom has had a good reason to not give the exact number at this level.

@philipgo
Copy link
Contributor

Just to make sure that I understand: What would OpenAPS do with the entry I posted. Treat it a) as 38 b) as "low" or c) as "no valid data"?

@tim2000s
Copy link
Contributor

@drnoname82 someone in the itb Gitter channel has done the work to have xDrip pass the data over. He’s also written an equivalent to the glucose test to ensure that NightScout null values aren't overwritten.

@scottleibrand
Copy link
Contributor

Dexcom reports all LOW values with a glucose of 39. If xDrip reports glucose < 39, we'll need to do something to ensure that they are converted before use or something to avoid neutral temping when LOW.

@philipgo
Copy link
Contributor

Does Dexcom always provide a "noise" entry? If so, is the < 39check necessary at all? Would noise >= 3 not suffice?

@philipgo
Copy link
Contributor

Any ideas, whether the "< 39" check is still necessary at all?

@scottleibrand
Copy link
Contributor

Dexcom does not provide the "noise" level directly, so we need to infer it by the absence of a glucose value >=39. When reported via the Share bridge and NS, Dexcom reports:

  {
    "direction": "Flat",
    "trend": 4,
    "dateString": "2017-10-26T11:55:35-07:00",
    "sgv": 126,
    "device": "share2",
    "date": 1509044135000,
    "_id": "59f22feabce7a8312aa0a4b5",
    "type": "sgv",
    "glucose": 126
  },

and a plugged in CGM reports:

  {
    "trend_arrow": "NOT_COMPUTABLE",
    "display_time": "2017-10-25T23:40:54-07:00",
    "system_time": "2017-10-26T07:43:42-07:00",
    "direction": "NOT COMPUTABLE",
    "sgv": 10,
    "dateString": "2017-10-25T23:40:54-07:00",
    "date": 1509000054000,
    "unfiltered": 94880,
    "filtered": 106272,
    "device": "openaps://edison-eb3/cgm",
    "rssi": 183,
    "_id": "59f18384bce7a8312aa0a36d",
    "type": "sgv",
    "glucose": 10
  },

@philipgo
Copy link
Contributor

Since it does not seem possible to positively identify "real" Dexcom sources, the most universal solution seems to be to exclude any values where
bg < 39 AND (noise is not reported OR noise >=3)
This solution however still causes neutral temping for a reported BG < 39 for CGM sources other than Dexcom and XDrip-DexcomG5 that do not report noise levels. Any better ideas?

@scottleibrand
Copy link
Contributor

What CGM sources are those, and how low do their readings go? I think Dexcom only uses numbers up to about 12 for error codes, so we could probably change that < 39 to be something more like < 20 if that would help.

@sulkaharo
Copy link
Collaborator Author

I think they main sources for CGM data in NS are xDrip, NS Uploader and the Enlite Uploader. 600-series uploader is probably also gaining traction. @arbox0 / @pazaan might have things to contribute here too. If needed, I can add filtering to the API to disregard invalid data, but given people can directly inject data to Mongo, we can't prevent uploaders that inject values in the error range that's supposed to represent BG values.

@philipgo
Copy link
Contributor

Then there are iOSxdripreader and all the numerous Libre solution, Wixels, Parakeets. I think it is impossible to identify and continously follow the reporting behavior of all these solutions. So one (not ideal) solution would be to set the Dexcom bg threshold as low as possible, only consider values below this threshold when an adequate noise level is reported.

Another possible solution would be to make OpenAPS behavior dependent on a preference or a question asked during setup.

@JohanDegraeve
Copy link

@drnoname82 I copied actually code from xdrip-experimental a version back in May 2016
It looks like I'm not setting any value (null value)

Do you know what algorithm should be used for the noise ?

@philipgo
Copy link
Contributor

@JohanDegraeve Understanding the XDrip code is far beyond my skills. I can only say that this commit brought noise values to the Nightscout entries:

NightscoutFoundation/xDrip@b4b632f

Before, XDrip would always report "noise": 1

@JohanDegraeve
Copy link

@drnoname82 ok looks interesting actually, but quite a long calculation to do. I'll note it down and keep you informed

@AdrianLxM
Copy link
Contributor

38 is an xDrip error state indicating "lower than low".
The actual value calculated would be < 10 mg/dl.

This usually indicates sensor failure of some kind.
I would see it as rather impossible that anyone could have a BG even close to that.

@pazaan
Copy link

pazaan commented Oct 28, 2017

@sulkaharo Do we need a more thorough data model to describe state? 600-series won't send a CGM value lower than 40 mg/dL. There are flags for calibrating, out of range ("lo" and "hi"), and ISIG. We don't have a value for "noise".

@sulkaharo
Copy link
Collaborator Author

@pazaan Yes sounds like it. A combination of 1) well spec'd abstraction layer on top of device protocol, which unified error messaging, 2) reference implementation for using the data and 3) had open source loops require the CGM source support this format, would probably extremely beneficial for reducing bugs / simplifying logic on the data use side & reduce the amount of unvetted sources of CGM data used for looping. Nightscout would also benefit - looking at the data samples from people, the data is all over the place right now; I'd be happy to eventually update the API to only accept data that had certain required fields present.

@philipgo
Copy link
Contributor

philipgo commented Oct 30, 2017

So we are currently looping on noisy values and may be setting neutral basals where a low temp would be safer. It does not seem like a universal solution is easy to find. How about a variable like neutral_temp_on_bg_less_than with a default of 39 - that would preserve the status quo for users of original Dexcom solutions and provide an easy fix for XDrip users.

@sulkaharo Did the change work on your rig? I just manually changed the two lines in my determine-basal.js and found that OpenAPS respects the bg limits, but ignores noise values although provided in glucose.json

@scottleibrand
Copy link
Contributor

scottleibrand commented Nov 1, 2017

I just searched our NS for records with an sgv between 10 and 39, and only found results for those two values, not anything in between. Would neutral temps for sgv == 38 be the proper behavior for xDrip users? It should be safe enough to neutral temp for sgv == 38 and sgv <= 10, and treat all other SGVs as valid readings (therefore zero temping for them). Thoughts?

@AdrianLxM
Copy link
Contributor

To me it seems to be the right behaviour for xDrip as I have seen the "38" cases only with extreme noise, bad calibrations (e.g. settings mg/dl and value mmol/l ) or ripped off sensors/transmitters. So all cases where a neutral temp seems appropriate.

@scottleibrand
Copy link
Contributor

Just updated this branch to neutral temp only for bg <= 10 || bg == 38. Does this now look good to merge from y'all's perspectives?

Copy link
Contributor

@alimhassam alimhassam left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems like a good solution to me

@philipgo
Copy link
Contributor

philipgo commented Nov 5, 2017

Has anyone else tested whether the rig actually respects the noise values after these changes? Since our sensor only provides clean readings ("noise" 1) at the moment, I attempted to test this by changing the code to set neutral temps for noise >= 1, but the rig only seemed to respect the BG limits and ignore the noise limit.

@philipgo
Copy link
Contributor

philipgo commented Nov 7, 2017

I just tested this PR again on a new rig and changed the code to set neutral temps for noise >= 1 instead of noise >= 3 for testing purposes. Again, the rig loops happily although it should not. I have no idea why...

@scottleibrand scottleibrand added this to the 0.6.1 milestone Nov 14, 2017
@alimhassam
Copy link
Contributor

i just checked this, and i'm wondering if this should be noise >=2 instead of >=3 or configurable. I personally get daily situations with noise of 2 which clear rapidely, after taking a shower, and i'm wondering if loop should be making decision based on these readings which seems a little higher than they should be (non scientific guestimation).

@philipgo
Copy link
Contributor

Does it work at all for you? This change is a bit difficult to test because I cannot artificially generate high noise readings, but I think the rig should stop looping entirely when set to noise>=1, which it does not.

What would you think about different acceptable noise levels for high and low glucose values. I personally would prefer low temping even when the glucose values are somewhat questionable (eg. glucose 60, noise 2) but avoid high temping/SMB on questionable high glucose values (eg. glucose 180, noise 2).

@alimhassam
Copy link
Contributor

Pretty much all my readings have noise >=1 so i think thats' too aggressive. I agree with making a distinction between low temping (acceptable with nosice 2), but avoid high temping unless noise is 1, as that's the issue i've been seeing pretty much everyday.

@scottleibrand
Copy link
Contributor

I have a branch for changing how we loop off raw data that would probably be appropriate to discuss using for high noise data too if y’all can get the noise data being used. If not, we might want to do a prep step to convert sgv to raw and remove glucose when noise is high.

@alimhassam
Copy link
Contributor

alimhassam commented Nov 26, 2017

i merged this branch to test, and added this log statement after

var noise = glucose_status.noise;
console.error("Noise level: ",noise);

and i only get Noise level: undefined in the logs, so something is missing, even if i do have noise values in my cgm data in mlab

coresponding mlab record:

{
    "_id": "5a1b1e52421c480d4d89250a",
    "direction": "FortyFiveUp",
    "noise": 1,
    "dateString": "2017-11-26T15:02:42.128000-05:00",
    "sgv": 159,
    "device": "xDrip-DexcomG5",
    "unfiltered": 153216,
    "filtered": 146496,
    "date": 1511726562128,
    "rssi": 100,
    "type": "sgv",
    "glucose": 159
}

scottleibrand and others added 2 commits November 26, 2017 20:48
Conflicts:
	lib/determine-basal/determine-basal.js
Propagate the noise field of glucose data so it can be used by determine_basal.
@alimhassam
Copy link
Contributor

alimhassam commented Nov 27, 2017

@drnoname82 you can try testing this again, i fixed the bug we found together, which was probably causing the issue you mentioned here: #735 (comment)

@philipgo
Copy link
Contributor

philipgo commented Nov 27, 2017

Now that the noise field is propagated, it works when I change

if (bg < 39 || minAgo > 12 || minAgo < -5) {
to if (bg < 10 || bg == 38 || noise >= 2 || minAgo > 12 || minAgo < -5) (don't know how to commit this to someone else's PR, though)

Now we only need to agree on the limits for acceptable noise. I personally would prefer a conservative approach by default (only loop when noise = 1, maybe changeable through a hidden preference).

@scottleibrand
Copy link
Contributor

Or maybe we could treat noise == 2 the same way we treat raw data from Dexcom, and noise == 3 as no data? And FWIW, I'm thinking about change the way we loop off of raw data, so that we use a multiplier (default of 0.75) to modify the raw values (to be more conservative and handle uncalibrated new sensors), and further limit us to only looping if the resulting value is <= 150 (aka the raw value is <=200). (There's a branch with these changes, but I haven't yet PR'd them.)

@tim2000s
Copy link
Contributor

I’ve been reviewing the data that xDrip provides to NightScout. There are a few places where the data is showing a noise level of 2 although a visual inspection suggests that there is no issue with the cleanliness of the day. 3 generally represents a significant shift from the previous level. I need to quantify it.

@alimhassam
Copy link
Contributor

How often do you get noise of 2? I personally notice noise 2 almost daily but for a short period of time. We would need more data to confirm what the right behavior should be with more cases.
In my case the BG are mostly correct while noise is 2 in my case but sometimes a bit higher than reality.

We probably need more data but my inclination is for openAps to use the BG but be more conservative when noise is 2, and go to neutral temp with a noise of 3... What do you think?

@tim2000s
Copy link
Contributor

It’s interesting. I’ve been using it for ages with xDrip and for a long time there was no noise data.

Since there has been noise data, I’ve not found “2” to be remotely far enough out to require any difference in behaviour.

I also think we only need to disable SMB with “3” and not neutral temp, as generally this occurs with a failing sensor and you see a lot of jumping around. I’ve run the loop without SMB when it’s been noisy and the jumping up and down has been comfortably smoothed by the look back over the previous 15-30 mins perfectly safely.

@philipgo
Copy link
Contributor

philipgo commented Nov 28, 2017

The are good reasons for each argument how noise should be treated. However, since OpenAPS keeps becoming easier to install and use (which is fantastic), there seem to be more and more users who do not have a proper understanding of the safety concept and the potential risks involved.

I would therefore favor a very conservative default behavior treating noise >= 2 like raw values and at the same time make this behavior easily configurable through a (hidden) preference (Only looping on noise=1 is recommended by @jamorham NightscoutFoundation/xDrip#191 (comment) )

@AdrianLxM
Copy link
Contributor

When testing noise-levels and how "loopable" they are, could you please also do the following:

  1. Enable engineering mode
  2. Switch on untra sensitive mode for work around noisy values
  3. Upload the display glucose to Nightscout

(1) To enable the engineering mode, enter "enable engineering mode" as spoken treatment:

  • On the main screen press the syringe
  • press the microphone button and say "enable engineering mode"
  • or: long press the microphone button and write "enable engineering mode"
  • -> a toast should appear telling you to be careful.

(2) Settings > xDrip+ Display Settings > Smooth sensor noise and then Settings > xDrip+ Display Settings > Smooth sensor noise ultrasensitive (with engineering mode enabled right below the first one)

(3) Settings > Clout Upload > Nightscout sync (REST-API) > Send Display glucose

This way xDrip+ tries to smooth the values when noise is detected. In AndroidAPS this works quite well even with some noise. I also often use the shortAvgDelta for both the 5min-Delta and the shortAvgDelta.

@scottleibrand
Copy link
Contributor

Just opened #833 - please review and comment.

@tim2000s
Copy link
Contributor

@AdrianLxM - what noise level does xDrip+ report when smoothing, etc. are turned on?

scottleibrand added a commit that referenced this pull request Dec 25, 2017
* use raw_safety_multiplier=0.75 instead of max_raw

* disable SMB on really big jumps for safety

* raise SMB-disable threshold to delta > 15% of bg

* 15% is too low

* re-enable max_raw (applied after raw_safety_multiplier adjustment)

* round insulinReq down to nearest 0.1U to safely allow eSMB on small basals

* Treat xDrip noise >= 3 similar to Dexcom showing ???

* neutral temp only for bg <= 10 || bg == 38

* Propagate the noise field. (#820)

Propagate the noise field of glucose data so it can be used by determine_basal.

* define vars

* pass noise to determine-basal; adjust target instead of BG

* let's merge #735 instead

* raw=noise; raise target 1.3x for noise; adjust maxraw accordingly

* rename rawTargetMultiplier to noisyCGMTargetMultiplier

* update unit tests

* check noise and cancel/shorten temps if needed

* fix test
@philipgo
Copy link
Contributor

I think this PR can be closed since #833 was merged.

@scottleibrand scottleibrand deleted the xDrip-noise-detection branch January 8, 2018 00:32
ThomasEmge added a commit to ThomasEmge/oref0 that referenced this pull request Dec 5, 2018
* fix remaining references to half_basal_target (#712)

* fix remaining reference to half_basal_target

* fix remaining reference to half_basal_target

* raise SMB-disable threshold to > 20% of bg to catch fast carb rises (#717)

* BlueZ update - min  version 5.47 due (BlueBorne vulnerability fix) (#724)

https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2017-1000250
http://www.bluez.org/release-of-bluez-5-47/

* fix logic fail for ! enableUAM case to set minGuardBG from COB (#721)

* Upload entries from G5 to nightscout (#718)

* Update packages.json

Add the new script

* oref0-upload-entries.json

This script uploads new CGM entries to Nightscout. If the network connection is lost for a period of time the entries from the last time the upload was successful (stored in ``entries-last-date.json``) buffer in ``entries-upload.json`` until the next successful upload, at which point the file is deleted. This allows the device to be offline for any number of days and you get all the entries, not just the last 288, once it comes back online.

* Rename oref0-upload-entries.json to oref0-upload-entries.sh

* Update oref0-setup.sh to support "g5-upload" CGM type

* Add the Bash indicator

* Eliminate basal vs. bolus distinctions (#685)

* remove all explicit references to basaliob

* add enableSMB_always preference, but don't add to displayedDefaults yet

* comment out all bolus snooze code

* comment out bolus snooze / IOB code

* comment out bolus snooze code

* comment out bolus snooze code

* comment out bolus snooze code

* remove bolus snooze code

* comment out bolus snooze code

* comment out bolus snooze test

* uncomment eventualBG < max_bg code and remove snoozeBG

* comment out bolus snooze tests

* rate <=0

* no more need to track hightempinsulin

* no more need to track netbasalinsulin

* no more need to track microBolus(IOB|Insulin)

* remove one more bolus snooze reference

* re-add basaliob and netbasalinsulin etc.

* oref0-ns-loop (#713)

* use IPv4 only to wget

* add package-lock.json to .gitignore

* match on spidev0.0 already in use too for Pi with Explorer HAT

* first untested attempt at moving ns-loop aliases into oref0-ns-loop.sh

* add oref0-ns-loop

* syntax

* fix get_ns_bg

* change ns_temptargets back for now

* improve logging

* improve logging

* return not exit

* improve logging

* improve logging

* improve logging

* improve logging

* improve logging

* improve logging

* improve logging

* improve logging

* improve logging

* improve logging

* improve logging

* install new oref0-ns-loop

* revert to settings/temptargets.json for now

* improve logging

* don't wait for 40s twice on random failures

* consistent messaging regardless of mmeowlink version

* syntax

* fix comment

* killall bluetoothd again immediately before installing it (#726)

*  apply 20g/h carbAbsorptionRate to COB not total carbs (#715)

* apply carbAbsorptionRate to COB not total carbs

* round allDeviations array for readability

* change initial carbAbsorptionRate assumption to 20g/h

* fix broken safety checks with a single pump-loop type (#725)

* consolidate down to a single pump-loop type

* touch /tmp/pump_loop_completed even w/o SMB

*  in two more places

* replace chained && with || fail

* syntax

* syntax

* timeout ns-get curls after 30s (#728)

* 0.6.0-dev2

* Fix pump-loop (#729)

* install SMB aliases regardless for pump-loop to work

* remove no-longer-applicable comments

* chmod +x bin/*.sh

* predBGs with zero temps (#714)

* remove all explicit references to basaliob

* add enableSMB_always preference, but don't add to displayedDefaults yet

* comment out all bolus snooze code

* comment out bolus snooze / IOB code

* comment out bolus snooze code

* comment out bolus snooze code

* comment out bolus snooze code

* remove bolus snooze code

* comment out bolus snooze code

* comment out bolus snooze test

* uncomment eventualBG < max_bg code and remove snoozeBG

* comment out bolus snooze tests

* rate <=0

* no more need to track hightempinsulin

* no more need to track netbasalinsulin

* no more need to track microBolus(IOB|Insulin)

* remove one more bolus snooze reference

* re-add basaliob and netbasalinsulin etc.

* add IOBWithZeroTemps

* calculate iobWithZeroTemp

* include the entire iobWithZeroTemp array

* calculate ZTpredBGs

* show all ZTpredBGs for now

* use predZTBGI for ZTpredBGs

* stop displaying ZTpredBGs once they're rising and above target

* calculate and log minZTUAMPredBG

* use minZTUAMPredBG to adjust dosing

* debugging output

* only show 30m of ZTpredBGs if rising above target

* disable aCOB for now

* use >= to make it more clear when ZTpredBGs have flattened out

* fix logic

Conflicts:
	lib/determine-basal/determine-basal.js

* if avgPredBG is below minZTGuardBG, bring it up to that level

* start the zero temp 1m in the future to avoid clock skew

* if minZTGuardBG is between threshold and target, blend in the averaging

* move minZTUAMPredBG outside of if (meal_data.carbs)

* round minZTUAMPredBG for readability

* round predCIs for readability

* round remainingCIs for readability

* align predCIs and remainingCIs

* fix comment

* copy old_preferences.json for reference

* disable adv_target_adjustments and enableUAM by default

* use old ns-loop for MDT CGM for now (#730)

* Use autosens basal adjustments in IOB calculations (#705)

* set exercise mode basal and ISF based on temptarget

* adjust slightly less, and only if temptarget > 110

* for temptargets > 110, adjust sensitivityRatio and IOB

* don't set neutral temp if carbsReq

* make sure autosens doesn't use temptarget-adjusted insulin calculations

* define var sensitivityRatio

* define basal before bg < 39 check

* allow exercise mode to be disabled in preferences.json

* flag autosens IOB calculations to avoid feedback loops

* make temptarget that generates 50% basal configurable

* pass optional autosens data for IOB recalculation

* pass optional autosens data for IOB recalculation

* use new formula in calculating IOB too

* actually update basal before calculating IOB

* use autosens_data if defined

* make it work

* turns out we don't need this

* pass autosens.json to calculate-iob

* disable autosens_adjust_targets by default now

* don't adjust carb_ratio with autosens

* adjust remainingCATime (instead of CR) for autosens

* stop excluding positive deviations as soon as mealCOB=0 if meal has been absorbing for >5h

* add one neutral deviation per hour to help decay over long exclusion periods

* use 0.5 cutoff for rounding

* no more need for a gap now that we're paddng with hourly 0 deviations

* clearer reporting of % negative vs. positive deviations

* only add one neutral deviation every 2 hours

* add negative deviations for high temp targets

* add EdisonVoltage upload back in to oref0-ns-loop (#731)

* add EdisonVoltage upload back in

* no more need for edisonbattery aliases now that they're in oref0-ns-loop.sh

* jq pretty colors

* jq pretty colors

* clarity

* check preferences.json is valid json (#738)

* check preferences.json is valid json

* please go correct your typo

* Only SMB every 3m; retry up to 2m (#744)

* only SMB every 3m now that we retry

* retry SMB if for up to 2m if waiting

* adding cron start/stop aliases (#746)

* adding cron stop/start aliases

* typo fix

* round insulinReq down to nearest 0.1U to safely allow eSMB on small basals (#732)

* make sure all apt-get packages are up to date (#733)

* Limit carb impact predictions to 30g/h (#740)

* limit Carb Impact to 12 mg/dL per 5m

* limit Carb Impact to 12 mg/dL per 5m before calculating CATime

* limit carb impact based on maxCarbAbsorptionRate = 30 g/h

* allow use of 39 (LOW) to calculate currentDeviation

* disable SMB if either avgDelta is >20% too (#742)

* pad up to 90m of zero deviations after site change (#743)

* upgrade to mmeowlink v0.11.1 for clearer pump comms messaging (#534)

* only use monitor/edison-battery.json if it exists (#750)

* match on spidev5.1 to indicate explorer (for runagain); fix if syntax (#751)

* optionally allow SMBs with activity mode (#734)

* if disableSMB_with_temptarget: false, allow (smaller) SMBs with high targets

* limit Carb Impact to 12 mg/dL per 5m

* limit Carb Impact to 12 mg/dL per 5m before calculating CATime

* limit carb impact based on maxCarbAbsorptionRate = 30 g/h

* allow use of 39 (LOW) to calculate currentDeviation

* go back to profile.sens to allow activity mode sensitivityRatio to adjust CR

* always print old and new ISF

* preflight after rssi_wait to make other rigs keep rssi_waiting

* print CR

* print CR

* clarify disableSMB_with_temptarget: true to be allowSMB_with_temptarget: false

* that should be allowSMB_with_high_temptarget not allowSMB_with_temptarget

* more user-friendly output when there aren't any temptargets

* remove "Excess"

* check validity of iob.json and profile.json and refresh if invalid (#745)

* check validity of iob.json and profile.json and refresh if invalid

* bash doesn't like empty if clauses

* specify which file was invalid

* only check profile.json not iob.json in refresh_old_profile

* don't proceed to a suggested.json if report invoke fails

* call determine-basal directly, not via openaps

* convert openaps get-settings to get_settings with error checking

* just check validity, not contents

* cleaner log output

* convert settings/pumpprofile.json to direct, and get rid of No temptargets warning

* Fix edisonbattery for MDT and xDrip. (#752)

* Revert "add EdisonVoltage upload back in to oref0-ns-loop (#731)"

This reverts commit a865517fcc575e118015c056ea565a3b4b8011f4.

Conflicts:
	bin/oref0-setup.sh

* revert

* use old ns-loop for xdrip too

* 0.6.0-dev3

* remove duplicate from merge conflict

* Calculate UAM and eventualBG when insufficient data for COB (#747)

* Optimize oref0-ns-loop.sh (#739)

* don't get_ns_bg if fresh; only run every 5m if highload

* fix glucose fresh check

* json is slow: just check file age

* use oref0_glucose_since directly; only get 24h of glucose every hour

* syntax

* use nightscout carb_history directly

* set mtime of ns-glucose.json based on its last reading

* update glucose-24h.json if not enough glucose to calculate COB

* undefined check

* on insufficient glucose data, only set COB to 0; still do UAM

* A52 risk reduction (#749)

* add A52_risk_enable setting in preferences.json

* calculate and return nsCarbs vs. bwCarbs for A52 safety checks

* don't need these

* SMB not enabled for Bolus Wizard

* don't enable SMB without A52_risk_enable if bolus wizard in use

* print SMB disabled when ! microBolusAllowed

* more/better SMB enabled logging

* this is actually only 6h for now

* comment out undefined/unused variable

* press ESC three times on the pump to exit Bolus Wizard before SMBing, to help prevent A52 errors

* clean up press_keys output

* send all three esc in a row, and don't bolus unless successful

*  press ESC three times on the pump to exit Bolus Wizard before SMBing (#753)

* press ESC three times on the pump to exit Bolus Wizard before SMBing, to help prevent A52 errors

* clean up press_keys output

* send all three esc in a row, and don't bolus unless successful

* log what we're doing with ESC ESC ESC

* don't treat suspended pump as a complete failure (#755)

* 0.6.0-dev4

* change default curve to rapid-acting (#769)

* Remove unnecessary verbose logging of the oref0-subg-ww-radio-paramet… (#763)

* Remove unnecessary verbose logging of the oref0-subg-ww-radio-parameters.

This logs every line being executed, which is probably overkill and fills the pump loop logs.

* Commenting out set -x

per @pietergit's recommendation

* Offline local-only wifi hotspot (#716)

* refactor oref0-online to use functions

* start_hotspot if no connectivity; stop_hotspot if online via BT

* refactor one more check_ip

* pass MACs to function

* pass MACs to function

* pass MACs to function

* stop/start backwards

* check if hostapd is running before stop/start

* stop_hotspot if running any time we have a public IP

* logic

* grep -q  instead of checking pid

* syntax

* make variables global

* ifup before hostapd; systemctl daemon-reload

* ifdown/ifup wlan0 in stop_hotspot

* stop_hotspot when we get BT

* try ifdown later

* stop udhcpd before starting dnsmasq

* echo

* no more need for sleep

* install prerequisites and configs for local-only hotspot

* only do local-only hotspot if BT configured

* offline webapp

* check if wlan0 is still in AP mode

* pass MACs to start_hotspot

* make sure hostapd and dnsmasq services are running if hotspot is up

* only stop hotspot if we have internet

* get ns-temptargets directly, then merge with any local-temptargets

* print temptarget start time

* untested set-local-temptarget.js

* use current time if unspecified

* oref0-set-local-temptarget

* oref0-append-local-temptarget

* oref0-append-local-temptarget

* regenerate profile after refreshing temptargets

* regenerate profile after merging temptargets

* allow oref0-append-local-temptarget.sh to run oref0-set-local-temptarget

* parse inputs as integers

* remove spurious output

* delete any local-temptarget files last modified more than 24h ago

* make offline_hotspot a preference, false by default

* per #716 it'd be better for xDrip to keep BT connected when offline

* if no wifi and no BT, try cycling wlan0

* make sure all apt-get packages are up to date

* Optimize oref0-ns-loop.sh (#739)

* don't get_ns_bg if fresh; only run every 5m if highload

* fix glucose fresh check

* json is slow: just check file age

* use oref0_glucose_since directly; only get 24h of glucose every hour

* syntax

* use nightscout carb_history directly

* set mtime of ns-glucose.json based on its last reading

* write profile.json.new and validate before mv'ing

* don't trust awk exit status

* cd to ~/myopenaps for oref0-online to read preferences.json

* Create linux-bootup.sh

Instructions for /etc/rc.local startup

* Update oref0-setup.sh

Stop automatic startup of hostapd & dnsmasq

* Update oref0-setup.sh

add linux-bootup.sh to /etc/rc.local

* Update linux-bootup.sh

check to see if .conf actually exists before overwriting with an empty file.

* Update oref0-setup.sh

Edit /etc/hostapd/hostapd.conf for Hostname and wpa

* Update package.json

add linux-bootup.sh

* Delete linux-bootup.sh

bad idea

* Update package.json

removed bad idea

* Update oref0-setup.sh

removed bad idea and writing to rc.local directly

* Update oref0-setup.sh

change hotspot name

* Update oref0-setup.sh

add wpa security for Hotspot with #OpenAPS

* Update oref0-setup.sh

add logic to rc.local

* Update hostapd.conf

add security to hotspot

* Update oref0-setup.sh

Changes for Hotspot setup

* Update oref0-setup.sh

change to setup for local-only hotspot

* Update oref0-setup.sh

changes for the different type of wpa-roam or wpa-conf

* reverse logic so failure = not enabled

* remove HostAPDIP if still configured after stop_hotspot

* Update oref0-online.sh

Changes to improve oref0-online

* Update oref0-setup.sh

changes to cron

* syntax

* if online via BT, cycle wlan0

* check for interfaces.ap; stop_hotspot if not enabled

* reorder to always stop_hotspot if not enabled

* don't release hotspot IP; reorder to stop_hotspot w/o BT MAC

* add /tmp/disable_hotspot support

* grammar capitalization etc.

* logic

* don't wait for 47 years if clock is mismatched

* mv offline folder to www so it doesn't conflict with branch name

* only release the wifi IP/route if it's from DHCP

* whitepace

* print Connected to Bluetooth with IP:

* consistency

* display wifi is not connected if no SSID

* whitepace

* consistency

* whitepace

* consistency

* whitepace

* print unassigned if no

* reorder and print local wifi/BT IPs separately

* syntax

* print name of phone we're connected to with Bluetooth

* only run check_ip once

* print start/finish times

* don't try to dhcp_renew when running hostapd

* print when PUBLIC_IP not found

* fix return code

* don't renew wlan0 IP/route if it's failing

* logging

* syntax

* don't wifi_dhcp_renew if bad_wifi

* f we can't connect via BT, might as well try previously bad wifi networks again

* remove extra -HotSpot from SSID

* disconnect bnep0 even w/o an IP

* temporarily disable hotspot for 1m every hour to allow it to try to connect via wifi again

* download carbhistory to carbhistory.json.new and mv it over if valid

* egrep quietly

* download ns-temptargets to .new and mv it over if valid

* escape $directory for crontab

* let's play spot that syntax error

* only retry SMB w/o waiting if it was <1 m wait

* change default curve to rapid-acting

* 0.6.0-dev5

* oref0-version (#759)

* oref0-version.js

Check and report current oref0 version as well as check for changes on remote.

* adding oref0-version

* Update oref0-version.js

* Add oref0-version check every hour.

* Language tweaks

* Revert "Add oref0-version check every hour."

This reverts commit 846b0f20857c89d320f7493a9dcd2f43d8dcb3b4.

* check-for-updates after each successful pump-loop

* replace backticks with quotes

* chmod +x

* port oref0-version.js to bash to avoid nodejs compatibility issues

* switch to oref0-version.sh to avoid nodejs compatibility issues

* rm oref0-version.js now that oref0-version.sh works

* don't display git fetch output

* revised text for master

* remove extra newlines to save space

* timeout git fetch after 30s if it hangs

* grammar

* tabs to spaces

* only check-for-updates once an hour, outside of pump-loop

* Removing "enable" requirement for SMB - use preferences only  (#748)

* remove extra SMB safety gates

* remove remaining  references

* kill bluetoothd AFTER download in case WAN access is through bluetooth (#771)

* Sensitivity and targets (#757)

* replace autosens_adjust_targets with more detailed preferences

* split autosens_adjust_targets to sensitivity_raises_target and resistance_lowers_target

* add low_temptarget_lowers_sensitivity support

* update comments to be correct

* make high-temptarget added deviations half as strong

* store/upload sensitivityRatio

* adjust CSF for temptarget sensitivityRatio, but not for autosens

* let 105-110 temp target trigger exercise mode

* oref0-autosens-loop (#767)

* refactor oref0-online to use functions

* start_hotspot if no connectivity; stop_hotspot if online via BT

* refactor one more check_ip

* pass MACs to function

* pass MACs to function

* pass MACs to function

* stop/start backwards

* check if hostapd is running before stop/start

* stop_hotspot if running any time we have a public IP

* logic

* grep -q  instead of checking pid

* syntax

* make variables global

* ifup before hostapd; systemctl daemon-reload

* ifdown/ifup wlan0 in stop_hotspot

* stop_hotspot when we get BT

* try ifdown later

* stop udhcpd before starting dnsmasq

* echo

* no more need for sleep

* install prerequisites and configs for local-only hotspot

* only do local-only hotspot if BT configured

* offline webapp

* check if wlan0 is still in AP mode

* pass MACs to start_hotspot

* make sure hostapd and dnsmasq services are running if hotspot is up

* only stop hotspot if we have internet

* get ns-temptargets directly, then merge with any local-temptargets

* print temptarget start time

* untested set-local-temptarget.js

* use current time if unspecified

* oref0-set-local-temptarget

* oref0-append-local-temptarget

* oref0-append-local-temptarget

* regenerate profile after refreshing temptargets

* regenerate profile after merging temptargets

* allow oref0-append-local-temptarget.sh to run oref0-set-local-temptarget

* parse inputs as integers

* remove spurious output

* delete any local-temptarget files last modified more than 24h ago

* make offline_hotspot a preference, false by default

* per #716 it'd be better for xDrip to keep BT connected when offline

* if no wifi and no BT, try cycling wlan0

* make sure all apt-get packages are up to date

* Optimize oref0-ns-loop.sh (#739)

* don't get_ns_bg if fresh; only run every 5m if highload

* fix glucose fresh check

* json is slow: just check file age

* use oref0_glucose_since directly; only get 24h of glucose every hour

* syntax

* use nightscout carb_history directly

* set mtime of ns-glucose.json based on its last reading

* write profile.json.new and validate before mv'ing

* don't trust awk exit status

* cd to ~/myopenaps for oref0-online to read preferences.json

* Create linux-bootup.sh

Instructions for /etc/rc.local startup

* Update oref0-setup.sh

Stop automatic startup of hostapd & dnsmasq

* Update oref0-setup.sh

add linux-bootup.sh to /etc/rc.local

* Update linux-bootup.sh

check to see if .conf actually exists before overwriting with an empty file.

* Update oref0-setup.sh

Edit /etc/hostapd/hostapd.conf for Hostname and wpa

* Update package.json

add linux-bootup.sh

* Delete linux-bootup.sh

bad idea

* Update package.json

removed bad idea

* Update oref0-setup.sh

removed bad idea and writing to rc.local directly

* Update oref0-setup.sh

change hotspot name

* Update oref0-setup.sh

add wpa security for Hotspot with #OpenAPS

* Update oref0-setup.sh

add logic to rc.local

* Update hostapd.conf

add security to hotspot

* Update oref0-setup.sh

Changes for Hotspot setup

* Update oref0-setup.sh

change to setup for local-only hotspot

* Update oref0-setup.sh

changes for the different type of wpa-roam or wpa-conf

* reverse logic so failure = not enabled

* remove HostAPDIP if still configured after stop_hotspot

* Update oref0-online.sh

Changes to improve oref0-online

* Update oref0-setup.sh

changes to cron

* syntax

* if online via BT, cycle wlan0

* check for interfaces.ap; stop_hotspot if not enabled

* reorder to always stop_hotspot if not enabled

* don't release hotspot IP; reorder to stop_hotspot w/o BT MAC

* add /tmp/disable_hotspot support

* grammar capitalization etc.

* logic

* don't wait for 47 years if clock is mismatched

* mv offline folder to www so it doesn't conflict with branch name

* only release the wifi IP/route if it's from DHCP

* whitepace

* print Connected to Bluetooth with IP:

* consistency

* display wifi is not connected if no SSID

* whitepace

* consistency

* whitepace

* consistency

* whitepace

* print unassigned if no

* reorder and print local wifi/BT IPs separately

* syntax

* print name of phone we're connected to with Bluetooth

* only run check_ip once

* print start/finish times

* don't try to dhcp_renew when running hostapd

* print when PUBLIC_IP not found

* fix return code

* don't renew wlan0 IP/route if it's failing

* logging

* syntax

* don't wifi_dhcp_renew if bad_wifi

* f we can't connect via BT, might as well try previously bad wifi networks again

* remove extra -HotSpot from SSID

* disconnect bnep0 even w/o an IP

* temporarily disable hotspot for 1m every hour to allow it to try to connect via wifi again

* download carbhistory to carbhistory.json.new and mv it over if valid

* egrep quietly

* download ns-temptargets to .new and mv it over if valid

* oref0-autosens-loop

* log why we're running autosens twice

* oref0-autosens-loop

* Add a note with the latest calculated IOB after boluses. (#770)

This is useful when multiple small micro boluses are being
administered. The notes will be visible in the pushover notifications from
nightscout.

* Disable wide_bg_target_range by default (#768)

* make wide_bg_target_range: false by default

* log target range when using wide_bg_target_range

* syntax

* Update openaps-install.sh (#778)

Add ntpdate

* Fix oref0-autotune-recommends-report for DST (#779)

* Build time_list array without using 'date' so it works with DST

* leading zeros

* only display API_SECRET not set warning if autotune fails (#774)

* set >30m zero temps when needed for low minGuardBG (#783)

* Optimize oref0-pump-loop, and bug fixes (#772)

* standardize on openaps report invoke

* not-yet-tested refactoring of monitor-pump, meal.json, etc.

* more refactoring for speed

* redirect output to the right files

* don't display full traceback on time set errors

* only run refresh_ commands if we don't have new glucose data yet

* remove end-of-line whitespace

* update pump_loop_completed before glucose-fresh checks

* reset pump clock if >55s off; better error messaging

* syntax

* nest ifs so we quit immediately if fresh

* hide red-herring 'date: invalid date ‘@’' message

* don't redirect oref0-meal stderr to meal.json

* more accurate log message

* show monitor/status.json if it's bolusing

* allow bolus and bolus wizard timestamps to differ by 1 second

* boluswizard uses current.carb_input not current.carbs

* warn if Treatment carbs unclassified

* profile.A52_risk_enable variable reference

* don't wait_for_bg after a Warning

* replace () with { ;}

* use try and retry functions

* retry basal_profile.json pull if it fails

* Couldn't

* curly braces and clearer error

* syntax

* exclude .pyc files from git

* lots more try, move suspended check to fail function

* log when Reducing insulinReq for expectedDelta

* try inside smb_suggest

* grammar

* wait_for_bg if too old; clarify error messages

* not sure how that got removed

* touch pump_loop_completed to wait for a new BG

* newlines

* check that profile has a valid current_basal

* differentiate things we can continue from if they fail

* "grep: enact/smb-suggested.json: No such file or directory" is not useful

* rename refresh_pumphistory_and_meal for error clarity

* continuing

* "grep: enact/smb-suggested.json: No such file or directory" is not useful

* install ntpdate

* only show reason too old if it's recent

* make sure status.json is fresh before checking if it says pump is suspended

* use try_return to more clearly log when ESC or bolus fails

* move calculate_iob into merge_pumphistory as it requires pumphistory-merged.json

* syntax

* 0.6.0-dev6

* if insulinReq > 0 but not enough for a microBolus, don't set an SMB zero temp (#786)

* Add some missing units conversion in reason field.

Some unit conversion were missing in the reason field, addede them.
Also changed some of the console messages.

* Add Carb ratio to reason field.

This is useful as it allows to clearly see that what is really used for the
calculation, and might avoid incorrectly thinking that the pump settings
are used when autotune is active.

* only add extra negative deviations if exercise mode is set (#790)

*  don't reduce insulinReq for expectedDelta (we have minGuardBG for that) (#793)

* log when Reducing insulinReq for expectedDelta

* don't reduce insulinReq for expectedDelta (we have minGuardBG for that now)

* comment out tests for behavior being removed

* run autotune 4am-4am instead of midnight-midnight (#794)

* run autotune 4am-4am

* run autotune at 4am instead of midnight

* gzip old autotune json and log files to save space (#792)

* gzip old autotune json and log files to save space

* force gzip to overwrite if necessary

* figure out how to not gzip the log we're currently writing to

* only gzip autotune log files more than 2 days old

* *** WARNING *** DO NOT USE enableSMB_always or enableSMB_after_carbs with xDrip+, Libre, or similar (#690)

* Restore 512/712 support (#775)

* standardize on openaps report invoke

* not-yet-tested refactoring of monitor-pump, meal.json, etc.

* more refactoring for speed

* redirect output to the right files

* don't display full traceback on time set errors

* only run refresh_ commands if we don't have new glucose data yet

* remove end-of-line whitespace

* update pump_loop_completed before glucose-fresh checks

* nest ifs so we quit immediately if fresh

* hide red-herring 'date: invalid date ‘@’' message

* don't redirect oref0-meal stderr to meal.json

* more accurate log message

* show monitor/status.json if it's bolusing

* allow bolus and bolus wizard timestamps to differ by 1 second

* boluswizard uses current.carb_input not current.carbs

* warn if Treatment carbs unclassified

* profile.A52_risk_enable variable reference

* don't wait_for_bg after a Warning

* don't run 512-incompatible currenttemp check w/o microBolusAllowed

* run old_main for 512/712 pumps

* fail preflight and quit main() if we detect an x12 pump

* use die instead of fail to prevent mmtuning on x12 pumps

* update openaps-install for Pi (#791)

* make openaps-install work for Pi

* more pi stuff

* python-software-properties is now software-properties-common

* use openaps-packages.sh

* require a NS site when running interactively

* ask for NS URL even if NIGHTSCOUT_HOST env var is set

* clarify that tokenauth has to already be set up in NS

* enumerate CGM options in detail

* explain first, then use short prompts

* require/reprompt for SN and API_SECRET

* Cancel high temps and shorten long zero temps when we lose CGM data (#796)

* put too-old-BG stuff together

* move BG too old check in with CGM error checks; shorten long zero temps

* use 12m for old BG threshold instead of 10m

* 0.6.0-rc1

* merged pi-install to dev

* oref0-pump-loop logging improvements (#800)

* print when Retrying a command

* remove duplicate old function monitor_pump

* don't print traceback when Couldn't refresh pumpprofile

* stringify status.json

* wait 15-30s for boluses to finish

* Fix "A52_risk_enable is not defined" error (#805)

* only try to get bnep0 IP if bt-pan succeeds (#803)

* only try to get bnep0 IP id bt-pan succeeds

* disable_hotspot every 20m to check for wifi

* if suggested temp is more than 20m shorter, enact it (#804)

* Delete profile.carbratio_adjustmentratio (#798)

This parameter is dangerous when used with autotune and
doesn't have the expected or described results.

Remove for now. (Docs will also need to be adjusted)

* retry bad_wifi after an hour (#806)

* print when Retrying a command

* remove duplicate old function monitor_pump

* don't print traceback when Couldn't refresh pumpprofile

* stringify status.json

* wait 15-30s for boluses to finish

* install bash-completion

* retry bad_wifi after an hour

* fix logic error in maxDelta (#807)

* fix basal schedule error checking (#808)

* validate pumpprofile.json.new before using

* fix current_basal check

* don't print filename

* show the right file

* 0.6.0-rc2

* Convert threshold where appropriate in logging output (#811)

* log-smb-disabled

* require boolean true on enableSMB preferences (#812)

* add MDT to oref0-ns-loop

* add MDT to oref0-ns-loop

* add logging data

* Fix log error

* 0.6.0

* 0.6.1-dev

* don't re-install if we already have 0.6.1

* Check OREF0_SRC env for source code location. Check for being behind upstream. Only warn if repo is ahead of local (not local ahead of remote) (#822)

* fix whitespace (convert tabs to spaces) and log messages

* test small commit

* js cleanup start
changed splice/pop to array element
cleaned up ns-status

* splice pop format

* changed var declaration

* oref0-version fetch upstream (#825)

* Check OREF0_SRC env for source code location. Check for being behind upstream. Only warn if repo is ahead of local (not local ahead of remote)

* Need to actually git fetch upstream

* Update oref0-version.sh

Clarify error message

* Process the Meal marker event from medtronic pump (#832)

* Process the Meal marker event from medtronic pump (#810)

* Changes

* Process Meal Markers from pump

* Undo changes

* tabs to spaces to fix indentation

* return journalCarbs

* copy-pasta fix

* indentation

* Improve the oref0-pump-loop debuging options by adding a debug flag. (#826)

* Improve the oref0-pump-loop debuginng options by adding a debug flag.

* Grammar

* commenting out unused and incorrect prepped_glucose code (#828)

* commenting out unused and incorrect prepped_glucose code

* remove second (yet) for consistency

* remove second (yet) for consistency

* not above means <=

* use pumpbasalprofile for autotune IOB calculations (#818)

* abort setup if we can't install bc etc. (#835)

* Basal record search (#834)

* Basal record search (#819)

* Changes

* Search through pump history for basal duration records

* undoing some changes

* Missed variable rename

* Attempt to fix failing tests, they're referring to 'date' not 'timestamp'

* loop over all of pumpHistory to find matching TempBasalDuration if it's not adjacent

* fix whitespace (tabs and trailing spaces)

* also edit settings.json and bg_targets_raw.json during setup (#815)

* Simple Remote Access Scripts (#817)

regenerate-index.sh creates a new file index.html every time it is run.  This contains simple html formatting with example data for now (intent is to add additional parameter-value pairs for display after approval of proof of concept).
setup-http.sh is intended to be called from oref0-setup.sh and adds cron entries to start SimpleHTTPServer at reboot and run regenerate-index.sh periodically.  Both files should be in ~/myopenaps/enact directory.  From a browser on any device, browse to http://[RIG_IP_ADDRESS]/index.html and the page will self-refresh periodically.

* only calculate UAM deviations for the last ~30m (#829)

* Fix typo in setup script for 512 files (#861)

* Fix typo in setup script for 512 files

Script currently saves 'bg_targets_raw.json' as 'bg_targets_raw.json,'

Remove the errant comma at the end of the output file name.

* Fix the other one too

* don't require enableSMB to enableUAM (#831)

* oref0-setup Explorer HAT support (#830)

* ask about Explorer Board HAT

* install explorer-hat branch of spi-serial for spidev0.0

* merged pi-install to dev

* pi user

* switch to decocare-clean

* enable spidev ports on the Pi

* try using packaged bluez with Rapsbian

* force apt to use IPv4 for now

* set bluetoothdminversion=5.43 to use packaged bluez with Rapsbian

* Revert "switch to decocare-clean"

This reverts commit 77dbd8a020534e30619c52316be836296832e190.

* switch to oref0/master for bin/openaps-packages.sh

* only use splitHistory internally: return un-split tempHistory (#836)

* fix Edison batteryVoltage (#837)

* refresh edison batteryVoltage

* don't rely on openaps battery-status alias

* don't require Explorer Board to use EdisonVoltage

* Allow Custom OPENAPS_DIR (#858)

* Allow Custom OPENAPS_DIR

* Fixed the dev oref0-pump-loop script to drop x12-incompaitble reports… (#862)

* Fixed the dev oref0-pump-loop script to drop x12-incompaitble reports IF an x12 pump is detected

In previous versions of oref0, this action was done by manually implementing an alias-change (as documented in past versions of the oref0 code).

Since the code here is not done via an alias anymore, but rather spelled out in the script, an if/then/else block is required to remove the offending reports when an incompatible pump is detected. 

Tested and verified against my 712.

* Update oref0-pump-loop.sh

Added -q to grep, we don't need to re-print the model num

* Restore newline before comment.

* Serve offline web page with flask (#843)

* Automate the steps to install flask as a service (#839)

Automate the steps to install flask as a service so can monitoring your rig OFFLINE with an Offline web page

IPHONE USERS To access this from an iphone browser, enter something like the following: http://172.20.10:5000

ex : http://IP_address__rig:5000

* use port 8080 for flask to avoid conflicts

* add meta refresh and title

* should we add a flask.log? (#850)

* added check for custom OPENAPSDIR enviornment var (#851)

* added check for custom OPENAPSDIR enviornment var

* change environment variable to OPENAPS_DIR

* limit SMB zero temps to 60m (#844)

* New monitoring page on port 80 (#863)

* Automate the steps to install flask as a service

Automate the steps to install flask as a service so can monitoring your rig OFFLINE with an Offline web page

IPHONE USERS To access this from an iphone browser, enter something like the following: http://172.20.10:5000

ex : http://IP_address__rig:5000

* Automate the steps to install flask as a service (#839)

Automate the steps to install flask as a service so can monitoring your rig OFFLINE with an Offline web page

IPHONE USERS To access this from an iphone browser, enter something like the following: http://172.20.10:5000

ex : http://IP_address__rig:5000

* use port 8080 for flask to avoid conflicts

* add meta refresh and title

* Change the port of offline webpage to 5001

* Create new webpage offline to monitoring the rig. Change the port of FLASK to port 80.

* Create new webpage offline to monitoring the rig. Change the port of FLASK to port 80.

* should we add a flask.log? (#850)

* added check for custom OPENAPSDIR enviornment var (#851)

* added check for custom OPENAPSDIR enviornment var

* change environment variable to OPENAPS_DIR

* convert tabs to spaces

* show Sensitivity Ratio in topbox instead of BASAL T

* Add indexError.html to handle JSON Value error (#848)

* do #849 manually

* clearer error message

* allow smartphones to zoom out to see the whole page un-scrunched

* catch IOErrors too

* make BG black

* improve column layout

* display 4h past and future

* use suggested predBGs, not enacted

* display Temp Targets

* calculate and display BG delta

* syntax

* print BG delta correctly

* shorter chart forecast legends

* 70% scale; units

* more readability improvements

* Cancel temp on error and > 55m w/ skip_netural_temps (#842)

* whitespace cleanup

* don't ignore temp cancel requests

* cancel temp on error rather than setting neutral

* with skip_neutral_temps, cancel non-zero temps before the top of the hour

* move cancel-temp logic outside of eventualBG < min_bg

* smb_enact_temp if a 0 duration temp is requested

* ignore lastTemp/currenttemp mismatches if we have <10m old lastTemp data

* if currenttemp.duration is zero because temp is canceled it won't match lastTemp

* Update oref0-ns-loop.sh (#870)

Seems to fix issue #868 - fixes uploading with oref0-ns-loop on Pi

* Better error message for self-resolving error on bad pump reads (#871)

* raise BG target for noisy / raw CGM data (#833)

* use raw_safety_multiplier=0.75 instead of max_raw

* disable SMB on really big jumps for safety

* raise SMB-disable threshold to delta > 15% of bg

* 15% is too low

* re-enable max_raw (applied after raw_safety_multiplier adjustment)

* round insulinReq down to nearest 0.1U to safely allow eSMB on small basals

* Treat xDrip noise >= 3 similar to Dexcom showing ???

* neutral temp only for bg <= 10 || bg == 38

* Propagate the noise field. (#820)

Propagate the noise field of glucose data so it can be used by determine_basal.

* define vars

* pass noise to determine-basal; adjust target instead of BG

* let's merge #735 instead

* raw=noise; raise target 1.3x for noise; adjust maxraw accordingly

* rename rawTargetMultiplier to noisyCGMTargetMultiplier

* update unit tests

* check noise and cancel/shorten temps if needed

* fix test

* comment out broken CURL_AUTH API_SECRET line (#838)

* always enable autosens-loop (#841)

* Display seconds in SMB wait time (#846)

* Display seconds in SMB wait

* Fix regex and indentation

* Ignore records with 0 sgv (#865)

* Display RMS deviation in autosens (#867)

It can be difficult to evaluate whether changes to less-intuitive settings changes like insulin peak time/DIA are likely to be helpful.  By calculating RMS deviation in autosens we have a metric measuring how well the current settings are predicting observed values.  

A change reducing RMS error will likely improve results and a change increasing RMS error will likely be unhelpful.

* Allow Custom OPENAPS_DIR (#859)

* Automate the steps to install flask as a service (#839)

Automate the steps to install flask as a service so can monitoring your rig OFFLINE with an Offline web page

IPHONE USERS To access this from an iphone browser, enter something like the following: http://172.20.10:5000

ex : http://IP_address__rig:5000

* use port 8080 for flask to avoid conflicts

* add meta refresh and title

* Allow Custom OPENAPS_DIR

* Simplify environment variable check

* use curly brackets consistently

* removed merge indicators

* fix direction calculation for negative trending (#885)

* Speed up autotune and make it work in NS (#872)

* declare vars

* convert all lib references to relative for NS autotune compatibility

* trim down IOBInputs.history to just the data for 6h prior to BGDate

Conflicts:
	lib/autotune-prep/categorize.js

* remove commented unused code

* comment out some process.stderr.write

* Autotune: avoid raising basals from UAM (#875)

* exclude >6mg/dL deviations as UAM; only add lowest 50% of UAM deviations to basals

* trim down IOBInputs.history to just the data for 6h prior to BGDate

* remove commented unused code

* remove duplicate function definitions (#892)

* run bg_targets.json after bg_targets_raw.json

* Upgrade bluez to 5.48, start bluetoothd if it's not running, remove experimental (#876)

* - bugfix: also start bluetoothd in oref0-bluetoothup if it's not running
- upgrade bluez to 5.48, changelog http://www.bluez.org/release-of-bluez-5-48/
- remove --experimental (finally) on bluetoothd startup and change it in /etc/rc.local if it's still there

* fix grep statement

* Explorer hat auto install (#897)

* Update oref0-setup.sh

* Update oref0-setup.sh

* Update oref0-setup.sh

* moving installer and code cleanup

* Update oref0-setup.sh

* indentation

* auto-detect Explorer HAT

* only generate edison-battery.json on edisons

* support openaps-menu/scripts/getvoltage.sh

* Remove external repo (#898)

* grep quietly

* Update logrotate.rsyslog (#901)

* apt-get update, upgrade, and autoclean

* re-do timerun stuff against dev (#896)

* allow pumphistory pull to take 90s (for pi0w)

* don't start oref0-pump-loop every 30s (#893)

* Fixed autotune_isf_adjustmentFraction. (#905)

* proceed to add battery-status if it doesn't exist yet

* do not produce errors when iob_data.lastTemp doesn't exist (#883)

* Pushover Priority to Urgent (#873)

* Pushover Priority to Urgent

Set Pushover Priority to urgent to ensure user sees the message.

* Updated to provide pushover preferences

Added preferences to allow user to configure pushover alerts' sound, priority, snooze, and only for options.

* Date error with MDT CGM (#845)

* Use proper date field in glucose-fresh for MDT CGM data

* Fix Typo ($ to &)

* In glucose-fresh Use display_time if present, otherwise use date

* Forgot the filename in bin/oref0-pump-loop change

* Format Autotune Output Profile (#900)

* Format autotune output when copying it to settings.

* Replaced json command calls with equivalent jq command calls.

* Placed autotune profile format in a better place.

* Added jq . -M back in for the grep for start command.

* Reverted the cat with a redirect back to a cp command.

* Removed unnecessary -M option to jq.

* Format new autotune profile with json-stable-stringify so it is
consistently arranged from one day to the next.

* Autotune Command Line Option to Classify UAM as Basal (#904)

* Added optional flag to oref0-autotune for manually telling
categorize to include all of the UAM periods as basals.
This is essentially telling autotune that the user
faithfully entered all of the carb intakes for the time
being processed.

* Handled variable arguments better.

* Prioritize categorize_uam_as_basal flag over the too many deviations categorizes as UAM check.

*  Offline monitoring page to show in mmol (#891)

* Offline monitoring page to show in mmol

* tabs to spaces

* Fixed time zone problem. (#910)

* Opened lsgaps time window from 5 to 6 to account for small variations (#915)

greater than 5 minutes with G5 and xdrip-js.

* print enact/smb-suggested.json if deliverAt check fails (#895)

* Pushover glances (#856)

* Adding watch complications - glances to pushover

Pushover has a new powerful glances API that sends complications to an apple watch or small bits of data to a smart watch face. More information at the following web page: https://pushover.net/api/glances

This change enhances the pushover notification script to optionally send information to the pushover glances API for watch face updates once every 10 minutes. It works well for apple watch complications. It has not yet been tested for android wear watchface updates yet.

Note that apple limits the daily total number of complication updates to save watch battery, so we cannot update this glance data more often than every 10 minutes today.

* Update oref0-pushover.sh

* refactor for simplicity performance plus ifttt

Refactored for simplicity and performance to just read from enact/smb-suggested.json

Also, added another optional notification that will send an ifttt maker event "carbs-required" if additional carbs are required and if environment variable "MAKER_KEY" is set. This is the ifttt webhooks Maker key https://ifttt.com/maker_webhooks
The "carbs-required" event can then be used with a ifttt recipe to perform an action based on carbs required. A good use case is to use the ifttt phone action to get a phone 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

* fix cut-n-paste error

* fix bug with delta & tick to remove +

* only use suggested.json - not smb-suggested.json

* fixed problem with delta comparisons

* fix delta comparisons

* Language tweaks

* exit if enact > 5 mins for safety and mult rigs

* refactored to use glucose.json trend values

* cut-n-paste error fixes

I don't think cut-n-paste works in the github editor. Somehow it put 4 copies of my one code change throughout the file. I cleaned that up.

* removed quotes from lastDirection value

* fix syntax error

* carbs-required repeat changed from 15 to 60 min

Changed the carbs-required repeat check to send this maker notification no more than once per every 60 minutes. By that time, the user should have eaten and logged some carbs. IFTTT limits phone call triggers to 100 per month.

* set positive deviations to zero if BG is below 80 (#902)

* set positive deviations to zero if BG is below 80 (#903)

* Fix iob calculation error (#878)

* Fixed the calculation error where different DIAs are used when
user has pump set to a value lower than 5 hours.

* Fixed to use adjusted dia value instead of original profile setting.

* Reordered calcIOB arguments.

* Added explanatory comment.

* Added unit test to ensure 5 hour minimum DIA is being
correctly enforced for rapid acting insulin.

* Fixed logic to move IOB test after profile DIA.

* Enable IOB calc to recognize suspends (#879)

* Added initial code to collect suspend and resume events.

* Initial implementation of treating suspends as zero basals.

* Added duration assignments back.

* Declared splitEvents variable and removed some debug.

* Used a similar structure to split suspends as with basals.

* Made some whitespace match previous version.

* Fixed call to splitAroundSuspends that was missing an argument.

* Added profile setting to enable new feature.

* Fixed incorrect comment description

* Fixed logic error for when there were no suspends or resumes in the history.

* Added test for iobcalc accounting for pump suspends.

* Added a couple of new tests for pump suspend interaction.
Split the test into multiple "it should.." test.

* Added a note for an additional test that needs to be written

* Modified code to add zero temps while pump is suspended.
Modified test to account for corrected logic of zero temping
while pump is suspended. Added remaining test.

* Cleaned up some comments.

* Clarified a comment.

* Updated a comment.

* #884: default remainingCATime to remainingCATimeMin if meal_data.carbs == 0 (#916)

* Fix suspend zeros iob preference (#918)

* Fixed suspend_zeros_iob preference.

* Fixed preference name.

* remove old commented code and corresponding usage entry

* Fix a href (#926)

* Changed suspend_zeros_iob default to true. (#922)

* Fix handling of dates so that we are not comparing the time the pump-… (#924)

* Fix handling of dates so that we are not comparing the time the pump-clock *was* set to, to the time it is when the test executes. Also, fix set-device-clocks so that it doesn't try and set the 'clock' on xdrip CGM.

Reset author on new device.

* Update oref0-pump-loop.sh

* Update oref0-pump-loop.sh

* Consistent use of `$HOME` instead of `~`. Make it possible to install oref0 in another directory than `myopenaps`  and make it possible to start it from any directory (#886)

* oref0-setup.sh installed myopenaps in the current directory instead of using $HOME/myopenaps
also found missing instance where hardcoded ~/myopenaps was still used

* use $HOME/ instead of ~/

* syntax fixes

* Revert "syntax fixes"

This reverts commit 3ff3b6c99efadff71b55c83aedf700e9cc1164c0.

* Revert "Fix handling of dates so that we are not comparing the time the pump-… (#924)"

This reverts commit 254757b7614cf977539594722ddba0d0e2b24db9.

* Update oref0-setup.sh for the edgecase of failed wget (#909)

* Update oref0-setup.sh

remove existing `bluez-5.48.tar.gz` in case of failed wget so subsequent commands run.

* Update oref0-setup.sh

* Update oref0-setup.sh

* Generate settings/bg_targets.json for x12 models (#920)

settings/bg_targets.json is generated from settings/bg_targets_raw.json, adding the user-preferred units, and pulls no data from the pump.

* Update offline monitoring page (#923)

* Offline monitoring page to show in mmol

* tabs to spaces

* offline monitoring page

* Read BG data till out of date range for chart

* center data in BG pill

* various fixes, move to all ajax calls

* refactor calculate.js (#931)

* remove error function (never used) from code

* parallel coefficient order and precision

* remove variable that is never used

* remove references to biobContrib

* remove incorrect comment

* remove timeRef variable

* remove unnecessary comment

* parallel results syntax

* improve readability of bilinear formulas

* line spacing

* round time since bolus for bilinear, similar to exponential calcs

* rename vars, add comments

* move function

* remove unnecessary condition in iobCalcBilinear

* create iobCalcExponential function

* delete some blank lines

* more line spacing tweaks

* change td to end in exponential function

* change tp to peak in exponential function

* reverse logic for using custom peak time

* calc minutes since bolus outside bilinear and exponential functions

* reverse activityContrib and iobContrib vars

* change 60*3 to end in bilinear function

* flip logic for treatment.insulin condition

* whoops. left a return statment in there.

* reverse order of functions in file

* set default dia, peak, and end as constants; add comments

* comments and source for exponential formula

* another comment

* iobCalcBiLinear to iobCalcBilinear

* delete line break in comment

* parentheses for clarity

* peak then end

* Comments

* comment tweaks

* comments and more intuitive calcs for activityContrib in iobCalcBilinear function

* narrow variable scope in iobCalcExponential

* 35 and 120, inclusive

* revert let back to var

* Fix date routine, corrected/operational (#933)

* Fix handling of dates so that we are not comparing the time the pump-clock *was* set to, to the time it is when the test executes. Also, fix set-device-clocks so that it doesn't try and set the 'clock' on xdrip CGM.

Reset author on new device.

* Update oref0-pump-loop.sh

* Update oref0-pump-loop.sh

* Update oref0-pump-loop.sh

* Update oref0-pump-loop.sh

* Fix syntax errors & unhandled errors in prior date-routine fix

* Update oref0-pump-loop.sh

* Update oref0-pump-loop.sh

* only kill bluetoothd on edison

* Revert "Fix date routine, corrected/operational (#933)"

This reverts commit 5f29a885265d51fd2f6e17855dab84d5eff40090.

* Don't loop on "stuck" CGM data (#942)

* don't loop on 'stuck' CGM data

* add reason field; fix var

* make sure at least one avgdelta is non-zero

* offline monitor - use xdrip bg data if more recent than monitor (#947)

* Slightly refactor oref0 meal to read all the data before (#954)

* Slightly refactor oref0 meal to read all the data before
trying to match bolus wizard entries to corresponding
bolus entries.

This allows out of order bolus and bolus wizard entries to
still work correctly.

Before this change, when the bolus entry was after the bolusWizard
entry, the carb was being skipped because no corresponding
bolus was seen.

* BolusWizard with matching bolus entry following it should not bet skipped.

* eleborate "skipping bolus wizard entry" information

(cherry picked from commit f628f49c11954d3672d7846e12b392b96cf1fd56)

* remove extra spaces

(cherry picked from commit eff86b5f55900bce428ee8b54480331e5cbca670)

* one more space removed

(cherry picked from commit fbcd8f23d65e071fb39c27671d19d7e6c7f94264)

* Fix log rotate for those who don't use boostrap

* Fix log rotate (dev PR) (#963)

* Fix a href (#926)

* Fix log rotate for those who don't use boostrap

* rigs start at weekly by default

* Change comment

* backport carelink support by supressing mmtune execution (#964)

* Support for x12 models in main() (#948)

* Initial commit for x12 support in main()

Deprecates old_main() and old functions that use it. Adds support for x12 pumps in smb loop (without using SMBs). ***Not tested.***

* Allow x12 models to use SMB loop

* Remove redundant check and quiet grep

* Readability

Adds parentheses to x12 SMB warning.

* Log clarity

Changes based on comments in #948

* Fix log rotate for those who don't use boostrap (#962)

* Change nano to vi for edit-wifi shortcut

* Remove update_config=1 from bootstrap script

* re-apply 7051259fc2fdb2fc3434f8c3a5d19130c01f8fba

* avoid filling logs with DIA warning, since we override to 5h now anyway (#976)

* Try three times to get a Bluetooth IP address

When my phone is in and out of service several times in as many minutes (between subway stations, for example) it doesn't assign an IP address to the device when it tries to connect via Bluetooth. Once back in a more stable environment it takes a while before it tries to get on the Internet via Bluetooth again. This change, tested over several weeks, significantly reduces the time offline during and after using the subway.

* Fix typo in filename of /tmp/autosens-completed (#990)

Fix a typo that would cause completed_recently in oref0-autosens-loop.sh to always be false. This effectively disabled a feature that was supposed to make autosens recalculation happen less frequently when under high load.

* Revert change (#991)

Revert the outcome of this test to its original behavior.

* don't error when HAT file doesn't exist

* autoconfirm apt-get

Add -y flags to the rest of the apt-get commands to bypass y/n prompts.

* Don't error when HAT file doesn't exist (#993)

Same issue as last, different location.

* fix improper revert

* if targets are < 20, assume for safety that they're intended to be mmol/L (#995)

* make maxUAMSMBBasalMinutes a preference (#974)

* Change invalid-IOB-curve behavor to match message (#1003)

* 0.6.1

* tabs to spaces

* add sgv.json?count=# route (#1001)

* add sgv.json?count=# route

support similar to xdrip+, for offline use with watchfaces, etc.

* add units_hint to sgv.json

* Trying to update the 'clock' on xdripaps causes an un-needed loop fail (#1002)

Stop trying to set-device-clocks for CGM on xdripaps installs.
When this command is executed, it results in a loop failure due to 'failure' to set the pump clock.

Fixed by looking for the xdrip.ini file & skipping the CGM clock update if it is found.

* Removing old to-do that's been taken care of

* Remove seemingly unused comments

* Add radio_type=carelink in pump.ini for carelink installs

* Update index.js (#1012)

* Update index.js

Fix to warning message indicating Xdrip+ version is handling noisy data appropriately.

* clarify

* Fixed currentRate calculation when using autosens. (#1019)

* fix syntax error (#1023)

I was getting syntax errors running `openaps-setup` and I putting this `fi` back fixed it: https://github.com/openaps/oref0/commit/f92a01ead0e5186270920b27d61d2282d178569c#diff-704a2fd9a43fd79bf52037b1668c146d

* adding duty cycle feature for carelink + mdt users (#1025)

* adding duty cycle feature for carelink + mdt users

* replace tab with 4 space

* minor tweaks, mostly for clarity

* update xDrip+ enableSMB warnings (#1017)

* Update index.js

Fix to warning message indicating Xdrip+ version is handling noisy data appropriately.

* clarify

* remove trailing spaces

* remove trailing spaces

* remove trailing spaces

* Revert "Removing old to-do that's been taken care of"

This reverts commit f92a01ead0e5186270920b27d61d2282d178569c.

Conflicts:
	bin/oref0-setup.sh

* only check_duty_cycle if "$DUTY_CYCLE" -gt "0"

* xdrip.ini always exists: check for xdrip/ dir instead

* Install MRAA on all kernel versions if it is needed. (#1015)

* 0.6.2-dev

* Adding links to documentation, and creating drop-down for readability

* Fixing link to modern docs, and recommending others ways to contribute

* Re-run apt-get update after dist-upgrade (#1034)

Fixes an issue where openaps-install.sh cannot find packages on the pi after running a dist-upgrade.

* rework release-master.sh

* 0.6.2

* Update openaps-packages.sh (#1054)

The latest node-js for raspbian deprecates the use of nodejs-legacy, which breaks this script on new pi installs. This will make it so that nodejs-legacy is only installed on the edison.

* Update issue templates

* Update issue templates

* Update issue templates

* Update issue templates

* Update issue templates

* Remove duplicate

* Remove duplicate

* Remove duplicate

* Update --individual-troubleshooting-help.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants