Skip to content

Commit 8c6e1b8

Browse files
committed
Merge branch 'dev' of github.com:openaps/docs into dev
Merge further conflicts between master and dev.
2 parents 4b2e94a + 4f4f7e9 commit 8c6e1b8

File tree

9 files changed

+396
-103
lines changed

9 files changed

+396
-103
lines changed

docs/docs/walkthrough/phase-0/loops-in-progress.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,4 @@ List of people who are working on closed loops:
4040
- Keith Burns - for Heather (Richmond, VA)
4141
- Kim St. Dennis (Los Angeles, CA)
4242
- Gabriel and Gideon Arom (Chicago, IL / Los Angeles, CA)
43+
- Arlene Samowich (Nashville, TN)
Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
11
# Analyze your existing data
22

3-
At this point, it would be helpful to analyze your existing data. Use whichever tools you prefer, but it would be helpful to see if your basal rates are somewhere in the ballpark of being correct; same for ISF and DIA. Consider using Nightscout reports, Dexcom Studio/Clarity, or your tool of choice.
3+
At this point, it would be helpful to analyze your existing data. Use
4+
whichever tools you prefer, but it would be helpful to see if your basal
5+
rates are somewhere in the ballpark of being correct; same for ISF and
6+
DIA. Consider using Nightscout reports, Dexcom Studio/Clarity, or your
7+
tool of choice.
8+
9+

docs/docs/walkthrough/phase-1/index.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Phase 1: Logging, Cleaning, and Analyzing Your Data
1+
Phase 1: Monitoring and Visualization
22
---------------------------------------------------
33

44
.. toctree::
@@ -7,6 +7,8 @@ Phase 1: Logging, Cleaning, and Analyzing Your Data
77

88
log-clean-analyze
99
analyze-existing-data
10+
using-openaps-tools
11+
1012
visualization
1113

1214

docs/docs/walkthrough/phase-2/using-openaps-tools.md renamed to docs/docs/walkthrough/phase-1/using-openaps-tools.md

Lines changed: 206 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -66,40 +66,130 @@ That `openaps.ini` file is the configuration file for this particular instance o
6666

6767
Didn't return much, did it? By the way, that `cat` command will be very useful as you go through these configuration steps to quickly check the contents of files (any files, not just `openaps.ini`). Similarly, if you see a command that you are unfamiliar with, such as `cat` or `cd`, Google it to understand what it does. The same goes for error messages—you are likely not the first one to encounter whatever error is holding you back.
6868

69+
### Add openaps-contrib
70+
This provides us with timezone support:
71+
72+
```
73+
openaps vendor add openapscontrib.timezones
74+
openaps device add tz timezones
75+
```
76+
77+
## Get Pump data
6978
### Add pump as device
7079

71-
In order to communicate with the pump and cgm receiver, they must first be added as devices to the openaps configuration. To do this for the pump:
80+
`$ openaps device add <my_pump_name> medtronic`
81+
82+
In order to communicate with the pump and cgm receiver, they must first be
83+
added as devices to the openaps configuration. To do this for a device we'll
84+
call `pump`:
85+
86+
`$ openaps device add pump medtronic`
87+
88+
89+
Then to configure the new `pump` device with its serial number:
90+
`openaps use pump config --serial 123456`
91+
92+
Create bunch of reports:
93+
`oref0 template mint reports medtronic-pump | openaps import`
94+
95+
Here, `<my_pump_name>` can be whatever you like, but `<my_serial_number>` must
96+
be the 6-digit serial number of your pump. You can find this either on the back
97+
of the pump or near the bottom of the pump's status screen, accessed by hitting
98+
the ESC key.
99+
100+
**Important:** Be careful when choosing to share your 6-digit pump serial
101+
number or posting it online. If someone had access to this number, and was in
102+
radio reach of your pump, this could be used to communicate with your pump
103+
without your knowledge. While this is a feature when you want to build an
104+
OpenAPS, it is a flaw and a security issue if someone else can do this to you.
105+
106+
## Get CGM Data
107+
### From Dexcom CGM receiver via usb cable
108+
109+
Now you will do this for the Dexcom CGM receiver using a usb cable:
110+
111+
`$ openaps device add cgm dexcom`
72112

73-
`$ openaps device add <my_pump_name> medtronic <my_serial_number>`
113+
Note this step is not required if you are using a Medtronic CGM. The pump
114+
serves as the receiver and all of the pumping and glucose functionality are
115+
contained in the same openaps device.
74116

75-
Here, `<my_pump_name>` can be whatever you like, but `<my_serial_number>` must be the 6-digit serial number of your pump. You can find this either on the back of the pump or near the bottom of the pump's status screen, accessed by hitting the ESC key.
117+
#### G5 support
118+
Support for G5 receiver is offered through the usb cable and configuring the
119+
`cgm` device with: `openaps use cgm config --G5`.
76120

77-
**Important:** Never share your 6-digit pump serial number and never post it online. If someone had access to this number, and was in radio reach of your pump, this could be used to communicate with your pump without your knowledge. While this is a feature when you want to build an OpenAPS, it is a flaw and a security issue if someone else can do this to you.
121+
### G4 with Share
122+
Install BLE helpers:
123+
```
124+
sudo pip install git+git://github.com/bewest/Adafruit_Python_BluefruitLE.git'#wip/bewest/custom-gatt-profile'
125+
sudo pip install git+git://github.com/bewest/openxshareble.git
126+
# adds openxshareble as vendor
127+
openaps vendor add openxshareble
128+
```
129+
130+
Then set up cgm device this way:
131+
```
132+
openaps device add cgm openxshareble
133+
```
134+
135+
### Glucose Data
136+
Test ability to get data.
137+
```
138+
openaps use cgm oref0_glucose --hours 2.0
78139
79-
### Add Dexcom CGM receiver as device
140+
# for G5 consider this instead:
141+
openaps use cgm oref0_glucose --no-raw --hours 2.0
80142
143+
<<<<<<< HEAD:docs/docs/walkthrough/phase-2/using-openaps-tools.md
81144
(Note this step is not required if you are using a Medtronic CGM. The pump serves as the receiver and all of the pumping and glucose functionality are contained in the same openaps device.)
82145
83146
For all Dexcom CGM systems:
147+
=======
148+
```
149+
>>>>>>> 4f4f7e95e6641fab56ac7aa0abfb4c6e057a7bee:docs/docs/walkthrough/phase-1/using-openaps-tools.md
84150
85-
`$ openaps device add <my_dexcom_name> dexcom`
151+
Add as report:
152+
```
153+
openaps report add raw-cgm/glucose-raw.json JSON cgm oref0_glucose --hours 2.0
154+
# For G5:
155+
openaps report add raw-cgm/glucose-raw.json JSON cgm oref0_glucose --no-raw --hours 2.0
86156
157+
<<<<<<< HEAD:docs/docs/walkthrough/phase-2/using-openaps-tools.md
87158
For a Dexcom G5 system, you need to configure openaps specifically for the G5:
88159
89160
`openaps use <my_dexcom_name> config --G5`
90161
91162
NB: The above command can also be used to change from a G4 to G5 system in an already functioning loop. If that doesn't work, update openaps.
163+
=======
164+
```
165+
>>>>>>> 4f4f7e95e6641fab56ac7aa0abfb4c6e057a7bee:docs/docs/walkthrough/phase-1/using-openaps-tools.md
92166
93-
### Check that the devices are all added properly
167+
Ensure that the data is zoned correcty:
168+
```
169+
openaps use tz rezone --date dateString --date display_time raw-cgm/glucose-raw.json
170+
openaps tz rezone --date dateString --date display_time raw-cgm/glucose-raw.json
171+
```
172+
173+
Save an alias to fetch CGM data:
174+
```
175+
openaps alias add monitor-cgm "report invoke raw-cgm/glucose-raw.json monitor/glucose.json"
176+
```
177+
178+
Now, `openaps monitor-cgm` is available to pull in fresh CGM data from Dexcom.
179+
180+
181+
182+
## Check that the devices are all added properly
94183

95184
`$ openaps device show`
96185

97186
should return something like:
98187

99188
```
100189
medtronic://pump
101-
dexcom://cgms
190+
dexcom://cgm
102191
```
192+
103193
Here, `pump` was used for `<my_pump_name>` and `cgms` was used for
104194
`<my_dexcom_name>`. The names you selected should appear in their place.
105195

@@ -121,7 +211,12 @@ extra = cgms.ini
121211

122212
Again, `pump` was used for `<my_pump_name>` and `cgms` was used for `<my_dexcom_name>`. Your pump model should also match your pump.
123213

124-
Because your pump's serial number also serves as its security key, that information is now stored in a separate ini file (here noted as `pump.ini`) that was created when you created the pump device. This makes it easier for sharing the `openaps.ini` file and also for keeping `pump.ini` and `cgms.ini` more secure. Be careful with these files. Open the pump's ini file now (use the name reported to you in the line labeled `extra` in the `openaps.ini` file).
214+
Because your pump's serial number also serves as its security key, that
215+
information is now stored in a separate ini file (here noted as `pump.ini`)
216+
that was created when you created the pump device. This makes it easier for
217+
sharing the `openaps.ini` file and also for keeping `pump.ini` and `cgms.ini`
218+
more secure. Be careful with these files. Open the pump's ini file now (use the
219+
name reported to you in the line labeled `extra` in the `openaps.ini` file).
125220

126221
`$ cat pump.ini`
127222

@@ -134,7 +229,9 @@ serial = 123456
134229

135230
The serial number should match that of your pump.
136231

137-
If you made a mistake while adding your devices or simply don't like the name you used, you can go back and remove the devices as well. For example, to remove the pump:
232+
If you made a mistake while adding your devices or simply don't like the name
233+
you used, you can go back and remove the devices as well. For example, to
234+
remove the pump:
138235

139236
`$ openaps device remove <my_pump_name>`
140237

@@ -217,28 +314,113 @@ optional arguments:
217314

218315
### Pulling blood glucose levels from Nightscout
219316

220-
Some people have found it more beneficial to pull blood glucose values from Nightscout rather than directly from the Dexcom receiver. In order to do that, two steps are needed:
317+
Some people have found it more beneficial to pull blood glucose values from
318+
Nightscout rather than directly from the Dexcom receiver.
319+
320+
Many people will actually setup both ways to pull the blood glucose level and
321+
switch between the different devices depending on their needs. If you are
322+
going to pull it directly from Nightscout then you will have to have internet
323+
access for the Raspberry Pi.
221324

222-
1) Similar like above, we need to create a device that talks to Nightscout. Add this device called "curl" to your list of devices in your openaps.ini file: <br>
223325

326+
The `autoconfigure-device-crud` feature will allow us to create an easy to use `ns` device:
327+
328+
```
329+
$ nightscout autoconfigure-device-crud https://my.nightscout.host averylongplainsecret
330+
added process://ns/nightscout/ns NIGHTSCOUT_HOST API_SECRET
331+
process://ns/nightscout/ns https://my.nightscout.host e6fc892e8e88235a476d197de3dfbef3f2db53d0
332+
333+
```
334+
It added a new `ns` device to our uses menu:
224335
```
225-
[device "curl"]
226-
fields =
227-
cmd = bash
228-
vendor = openaps.vendors.process
229-
args = -c "curl -s https://yourwebsite.azurewebsites.net/api/v1/entries.json | json -e 'this.glucose = this.sgv'"
336+
openaps use ns shell get entries.json 'count=10'
337+
openaps use ns shell upload treatments.json recently/combined-treatments.json
230338
```
339+
So we now have various uses for `ns`: **get**, **upload**,
340+
**latest-treatment-time**, **format-recent-history-treatments**,
341+
**upload-non-empty-treatments**.
342+
#### nightscout tools in openaps
231343

232-
In addition, you need to alter your monitor/glucose.json report to use this device rather than the cgms device you setup above. The report will look like this in your openaps.ini file:
233-
344+
openaps use ns shell get entries.json 'count=10'
345+
openaps use ns shell upload treatments.json recently/combined-treatments.json
234346
```
235-
[report "monitor/glucose.json"]
236-
device = curl
237-
use = shell
238-
reporter = text
347+
-h This message.
348+
get type args Get records of type from
349+
Nightscout matching args.
350+
351+
upload endpoint file Upload a file to the Nightscout endpoint.
352+
latest-treatment-time - get latest treatment time from Nightscout
353+
format-recent-history-treatments history model - Formats medtronic pump
354+
history and model into
355+
Nightscout compatible
356+
treatments.
357+
358+
format-recent-type ZONE type file - Selects elements from the
359+
file where the elements would
360+
satisfy a gap in the last 1000
361+
Nightscout records.
362+
363+
upload-non-empty-treatments file - Upload a non empty treatments
364+
file to Nightscout.
365+
lsgaps tz entries - Re-use openaps timezone device
366+
to find gaps in a type (entries)
367+
by default.
368+
upload-non-empty-type type file
369+
status - Retrieve status
370+
preflight - NS preflight
239371
```
372+
## Nightscout Endpoints
373+
374+
* `entries.json` - Glucose values, mbgs, sensor data.
375+
* `treatments.json` - Pump history, bolus, treatments, temp basals.
376+
* `devicestatus.json` - Battery levels, reservoir.
377+
* `profile.json` - Planned rates/settings/ratios/sensitivities.
378+
* `status.json` - Server status.
379+
380+
## Examples
381+
382+
383+
### Get records from Nightscout
384+
385+
Use the get feature which takes two arguments: the name of the endpoint
386+
(entries, devicestatus, treatments, profiles) and any query arguments to append
387+
to the argument string. 'count=10' is a reasonable debugging value.
388+
The query-params can be used to generate any query Nightscout can respond to.
389+
390+
openaps use ns shell get $endpoint $query-params
391+
392+
### Unifying pump treatments in Nightscout
393+
394+
To upload treatments data to Nightscout, prepare you zoned glucose, and pump
395+
model reports, and use the following two reports:
396+
397+
openaps report add nightscout/recent-treatments.json JSON ns shell format-recent-history-treatments monitor/pump-history.json model.json
398+
openaps report add nightscout/uploaded.json JSON ns shell upload-non-empty-treatments nightscout/recent-treatments.json
399+
400+
Here are the equivalent uses:
401+
402+
openaps use ns shell format-recent-history-treatments monitor/pump-history.json model.json
403+
openaps use ns shell upload-non-empty-treatments nightscout/recent-treatments.json
404+
405+
The first report runs the format-recent-history-treatments use, which fetches
406+
data from Nightscout and determines which of the latest deltas from openaps
407+
need to be sent. The second one uses the upload-non-empty-treatments use to
408+
upload treatments to Nightscout, if there is any data to upload.
409+
410+
### Uploading glucose values to Nightscout
411+
412+
Format potential entries (glucose values) for Nightscout.
413+
414+
openaps use ns shell format-recent-type tz entries monitor/glucose.json | json -a dateString | wc -l
415+
# Add it as a report
416+
openaps report add nightscout/recent-missing-entries.json JSON ns shell format-recent-type tz entries monitor/glucose.json
417+
# fetch data for first time
418+
openaps report invoke nightscout/recent-missing-entries.json
240419

241-
Many people will actually setup both ways to pull the blood glucose level and switch between the different devices depending on their needs. If you are going to pull it directly from Nightscout then you will have to have internet access for the Raspberry Pi.
420+
# add report for uploading to NS
421+
openaps report add nightscout/uploaded-entries.json JSON ns shell upload entries.json nightscout/recent-missing-entries.json
422+
# upload for fist time.
423+
openaps report invoke nightscout/uploaded-entries.json
242424

243425

244426
<br>

0 commit comments

Comments
 (0)