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

Closed
wants to merge 7 commits into from
@@ -2,7 +2,11 @@

Welcome to the [openaps](https://github.com/openaps/) documentation!

openaps is part of a set of [development tools](https://net.educause.edu/ir/library/pdf/ELI7088.pdf) to support a self-driven Do-It-Yourself (DIY) implementation of an artificial pancreas based on the [OpenAPS reference design](http://openaps.org/open-artificial-pancreas-system-openaps-reference-design/). ([Click here to view an image of the common physical components of an OpenAPS setup](./docs/IMG_1112.jpg).)
openaps is part of a set of [development tools](https://net.educause.edu/ir/library/pdf/ELI7088.pdf) to support a self-driven Do-It-Yourself (DIY) implementation of an artificial pancreas based on the [OpenAPS reference design](http://openaps.org/open-artificial-pancreas-system-openaps-reference-design/).

Here are two visuals to show you what the physical hardware components of an OpenAPS setup look like - [version A](./docs/IMG_1112.jpg) is without labels; [version B](docs/Images/piSetup.jpg) contains labels to describe the parts.



By proceeding to use these tools or any piece within, you agree to the copyright (see LICENSE.txt for more information) and release any contributors from liability.

@@ -68,11 +72,11 @@ At the beginning of each phase, an outline summarizes:
* [Configuring and Learning to Use openaps Tools](docs/Log-clean-analyze-with-openaps-tools/using.md)
* [Phase 2: Build a Manual System](docs/Build-manual-system/considerations.md)
* [Using oref0 Tools](docs/Build-manual-system/Using-oref0-tools.md)
* [Understanding oref0-determine-basal recommendations] (docs/Build-manual-system/Understand-determine-basal.md)
* [Understanding oref0-determine-basal recommendations](docs/Build-manual-system/Understand-determine-basal.md)
* [Creating a Loop and Retry Logic](docs/Build-manual-system/loop-and-retry-logic.md)
* [Phase 3: Automate Your System](docs/Automate-system/considerations.md)
* [Creating a Schedule](docs/Automate-system/create-schedule.md)
* [Visualization and Monitoring](docs/Automate-system/vizualization.md)
* [Visualization and Monitoring via Nightscout](docs/Automate-system/vizualization.md)
* [Validating and Testing](docs/Automate-system/validate-output.md)
* [Keeping Up To Date](docs/Automate-system/keeping-up-to-date.md)
* [Phase 4: Iterate and Improve](docs/Iterate-improve/improvement-projects.md)
@@ -2,31 +2,41 @@

## Nightscout Integration

This assumes you have a [Nightscout website](http://www.nightscout.info/) to help visualize and alert a T1D's blood sugar levels. If you aren't running a Nightscout website, stop what you are doing and set one up!

Integrating Openaps with Nightscout is a very helpul way to understand what Openaps is doing in a visual way and can be accessed through a web browser rather than logging into the Raspberry Pi and looking at the logs.

There are a few changes to your Nightscout Implementation:
### There are a few changes to your Nightscout Implementation:

1) You must install the dev version of Nightscout which can be found here:
https://github.com/nightscout/cgm-remote-monitor/tree/dev
(or you can use the master branch from version 0.8.3 and above but it will only show you basal adjustments...not IOB or OpenAPS pill).

Note: Currently there is a bug in the dev version that doesn't allow you to set up a new profile using the profile editor. So if you are starting a fresh install of Nightscout, it is necessary first to launch the master (live) version of the code. Then create the profile with information on basal rates, etc. Then after that install the dev version.

If you have an existing version of Nightscout, then create a profile before moving to the dev version.

2) Two configuration changes must be made to the Nightscout implementation:

For Azure users, you must add "openaps" (without the quotes) to the list of plugins enabled and add DEVICESTATUS_ADVANCED="true"
For Azure users, you should add "careportal iob basal profile bwp cage sage openaps rawbg" (without the quotes) to the list of plugins enabled and add DEVICESTATUS_ADVANCED="true"

Here is what it will look like:

https://files.gitter.im/eyim/lw6x/blob

3) On your Nightscout website, go to the settings (3 vertical lines) in the upper right corner. Near the bottom is a list of Plugins available. OpenAPS should show up. Click the check box to enable. You should now see the OpenAPS pill box on the left side near the time.
You should restart your NS website at this point.

Note: Currently there is a bug in the dev version that doesn't allow you to set up a new profile using the profile editor. So if you are starting a fresh install of Nightscout, it is necessary first to launch the master (live) version of the code. Then create the profile with information on basal rates, etc. Then after that install the dev version.

If you have an existing version of Nightscout, then create a basal profile before moving to the dev version.

To turn on the Basal Profile editor [do this](../Images/basal_profile.png) and then actually [create a Basal Profile](../Images/profile_editor.png) that mirrors what is happening on your pump.


3) On your Nightscout website, go to the settings (3 vertical lines) in the upper right corner. Near the bottom is a list of Plugins available. OpenAPS should show up. Click the check box to enable. Do the same for Basal Profile. You should now see the OpenAPS pill box on the left side near the time.

Example here:

https://files.gitter.im/eyim/J8OR/blob

Now we need to make a few changes to your OpenAPS implementation
### Now we need to make a few changes to your OpenAPS implementation

1) Add two devices, one called "ns-upload", via a command like `openaps device add fake process ns-upload https://YOURWEBSITE.azurewebsites.net 5baa61e4c9b93f3f0682250b6cf8331b7ee68fd8`, and one called "ns-status".

@@ -42,7 +52,7 @@ vendor = openaps.vendors.process <br>
cmd = ns-upload <br>
args = https://YOURWEBSITE.azurewebsites.net 5baa61e4c9b93f3f0682250b6cf8331b7ee68fd8 (this is the hashed version of your API_SECRET password) <br>

The last line args = should contain the URL of the Nightscout website. Note that for Azure it is important to include the https:// before the URL> What follows is the hashed version of your API_SECRET password. To get the hased version of the password, put your password into this website: http://www.sha1-online.com/
The last line args = should contain the URL of the Nightscout website. Note that for Azure it is important to include the https:// before the URL> What follows is the hashed version of your API_SECRET password. To get the hashed version of the password, put your password into this website: http://www.sha1-online.com/

For example, if your password is "password" (without quotes) it will return 5baa61e4c9b93f3f0682250b6cf8331b7ee68fd8

@@ -112,3 +122,20 @@ export API_SECRET=yourpassword (plain text seems to work fine)


Note: Currently extended bolus are not handled well and depending on the timing of the upload are either missed entirely or has incorrect information.

### Upload your pump history into NightScout

Order of operations is important!

After you enact a suggestion / temp basal, you will want to query the pump again for pump history as you just made a change to pump data. Once you have done this, you can run the following commands to have your data formatted and then upload into your Nightscout website. This is roughly what your commands should look like inside your loop:

````
openaps monitor-pump
openaps latest-ns-treatment-time
openaps format-latest-nightscout-treatments
openaps upload-recent-treatments
````

I've noticed it can take a couple of minutes after a successful load of data in NS for the data to show up in the interface so be patient!
![Basal Profile](../Images/nightscout.png)
@@ -1,4 +1,4 @@
#Using oref0 Tools
# Using oref0 Tools

## Add the oref0 Virtual Devices
In Phase 1, you added two physical medical devices to openaps—your pump and your cgm. This was done using the command `$ openaps device add` and then specifying the device name, type, and parameters. OpenAPS tools to gather system profile parameters such as pump settings, calculate the current insulin on board (IOB), and determine if the pump temp basal should be updated or not, are contained in the OpenAPS reference system oref0. Since there is no physical oref0 device, you are essentially adding it to the openaps environment as a virtual device or plugin.
@@ -1,5 +1,29 @@
#Creating a loop and retry logic
# Creating a loop and retry logic

To pull all of oref0 together, you could create a "loop" alias that looks something like `openaps alias add loop '! bash -c "openaps monitor-cgm 2>/dev/null && ( openaps preflight && openaps gather && openaps enact) || echo No CGM data."'`. If you want to also add some retry logic to try again if something failed, you could then do something like `openaps alias add retry-loop '! bash -c "until( ! mm-stick warmup || openaps loop); do sleep 5; done"'`.

Once all that is working and tested, you will have a command that can be run manually or on a schedule to collect data from the pump and cgm, calculate IOB and a temp basal suggestion, and then enact that on the pump.

## A barebones loop

- Make sure all dirs that have new files generated are cleaned out
- Get CGM data
- Get pump data
- Get Basal Suggestions
- Check if you need to put suggestions in place and if you do, then run them

## A more advanced loop
**Pull pump settings once an hour**

**Log everything!**
- Make sure only one loop runs at a time
- Verify you can talk to the pump, you can't reset the USB carelink connection
- Make sure all dirs that have new files generated are cleaned out
- Get CGM data
- Get pump data
- Get Basal Suggestions
- Check if you need to put suggestions in place and if you do, then run them
- Pull pump settings again since you just modified the pump
- get latest ns treatment time
- format latest nightscout treatments
- upload recent treatments
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN +243 KB docs/piSetup.jpg
Binary file not shown.
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.