openaps / docs

Documentation for setting up OpenAPS
http://OpenAPS.org
MIT License
229 stars 727 forks source link

use templates to ease setup: #132

Closed bewest closed 7 years ago

bewest commented 8 years ago

Please see:

oref0 template

$ oref0 template -h
/usr/local/bin/oref0-template <cmd> <type> [args]

Commands:
  mint <type>  generate template for import
  completion   generate bash completion script

Options:
  -h, --help  Show help                          [boolean]
$ oref0 template mint
/usr/local/bin/oref0-template mint <type>

Commands:
  device <type>    generate devices
  reports <shape>  generate reports

Options:
  -h, --help  Show help                          [boolean]

This can add the needed oref0 devices:

$ oref0 template mint device oref0
[{"extra":{"fields":"","cmd":"oref0","args":""},"type":"device","name":"oref0","oref0":{"vendor":"openaps.vendors.process","extra":"oref0.ini"}},{"extra":{"fields":"settings bg-targets insulin-sensitivities basal-profile max-iob","cmd":"oref0","args":"get-profile"},"type":"device","name":"get-profile","get-profile":{"vendor":"openaps.vendors.process","extra":"get-profile.ini"}},{"type":"device","calculate-iob":{"vendor":"openaps.vendors.process","extra":"calculate-iob.ini"},"name":"calculate-iob","extra":{"fields":"pump-history oref0-profile clock","cmd":"oref0","args":"calculate-iob"}},{"determine-basal":{"vendor":"openaps.vendors.process","extra":"determine-basal.ini"},"type":"device","name":"determine-basal","extra":{"fields":"oref0-iob temp-basal glucose oref0-profile","cmd":"oref0","args":"determine-basal"}}]

# to import the devices:
$ oref0 template mint device oref0 | openaps import

To manage common reports:

oref0 template mint reports medtronic-pump

Generates all the needed pump handling reports.

oref0 template mint reports oref0-inputs

Setup needed oref0 reports

bewest commented 8 years ago

new style walk through:

From scratch: install openaps (

sudo pip install -U openaps openaps-contrib
sudo pip install git+git://github.com/oskarpearson/mmeowlink.git

# and oref0
sudo npm install -g git://github.com/openaps/oref0.git'#dev'
openaps vendor add mmeowlink.vendors.mmeowlink
openaps vendor add openapscontrib.timezones

for 'share ble

sudo pip install git+git://github.com/bewest/Adafruit_Python_BluefruitLE.git'#wip/bewest/custom-gatt-profile'
sudo pip install git+git://github.com/bewest/openxshareble.git
openaps vendor add openxshareble

For pebble:

sudo pip install git+git://github.com/mddub/pancreabble.git
openaps vendor add pancreabble

See https://github.com/mddub/pancreabble for more details.

setup pump device:

Replace 123456 with your own pump's serial number.

carelink stick

openaps device add pump medtronic 123456

TI stick

The path, /dev/serial/by-id/usb-Nightscout_subg_rfspy_000002-if00 will change, depending on your own system. openaps device add pump mmeowlink subg_rfspy /dev/serial/by-id/usb-Nightscout_subg_rfspy_000002-if00 123456

setup glucose device

register oref0:

This creates several devices to manage oref0:

oref0 template mint device oref0 | openaps import

create lots of reports:

Create medtronic and oref0 reports, this handles timezones, units conversion, as well as detecting freshness of files.

oref0 template mint reports  medtronic-pump | openaps import
oref0 template mint reports  oref0-inputs | openaps import

add nightscout

Create ns device. Replace https://my.nightscout.host with your own Nightscout address, and averylongplainsecret with your own plain API_SECRET.

nightscout autoconfigure-device-crud https://my.nightscout.host averylongplainsecret

Make reports:

openaps report add nightscout/recent-treatments.json JSON ns shell  format-recent-history-treatments monitor/pump-history.json model.json
openaps report add nightscout/uploaded.json JSON  ns shell upload-non-empty-treatments  nightscout/recent-treatments.json

admire work:

TODO: Aliases to weave it all together. To review, there should be several devices:

$ openaps device show
process://oref0/oref0/
process://get-profile/oref0/get-profile
process://calculate-iob/oref0/calculate-iob
process://determine-basal/oref0/determine-basal
process://ns/nightscout/ns https://my.nightscout.host e6fc892e8e88235a476d197de3dfbef3f2db53d0
mmeowlink://pump

With quite a few reports:

$ openaps report show
get-profile://text/shell/oref0-monitor/profile.json
calculate-iob://text/shell/oref0-monitor/iob.json
determine-basal://text/shell/oref0-predict/oref0.json
pump://JSON/read_bg_targets/raw-pump/bg-targets-raw.json
units://JSON/bg_targets/settings/bg-targets.json
pump://JSON/read_insulin_sensitivities/raw-pump/insulin-sensitivities-raw.json
units://JSON/insulin_sensitivities/settings/insulin-sensitivities.json
pump://JSON/read_clock/raw-pump/clock-raw.json
tz://JSON/clock/monitor/clock.json
pump://JSON/read_temp_basal/monitor/temp-basal-status.json
pump://JSON/iter_pump_hours/raw-pump/pump-history-raw.json
tz://JSON/rezone/monitor/pump-history.json
pump://JSON/model/model.json
pump://JSON/reservoir/monitor/reservoir.json
pump://JSON/read_status/monitor/status.json
pump://JSON/read_battery_status/monitor/battery.json
pump://JSON/set_temp_basal/oref0-enacted/enacted-temp-basal.json
oref0://JSON/shell/settings/settings.json
pump://JSON/read_settings/raw-pump/settings.json
oref0://JSON/shell/settings/selected-basal-profile.json
pump://JSON/read_selected_basal_profile/raw-pump/selected-basal-profile.json
pump://JSON/read_temp_basal/raw-pump/temp-basal-status.json
pump://JSON/reservoir/raw-pump/reservoir.json
pump://JSON/read_status/raw-pump/status.json
pump://JSON/read_battery_status/raw-pump/battery.json
ns://JSON/shell/nightscout/recent-treatments.json
ns://JSON/shell/nightscout/uploaded.json

Now we can simply invoke most of them in the right order. Pro tip: Use openaps report show --cli to view the corresponding use commands for each of these reports.

Let's make a few directories so the tools don't get stuck the first time:

Here's some aliases @bewest is using successfully, these have been designed to be easy to mend and debug, as well as build upon.

$ openaps alias show
rm-warmup ! bash -c "rm -f model.json monitor/clock.json > /dev/null"
warmup report invoke model.json raw-pump/clock-raw.json monitor/clock.json
fail-warmup ! bash -c "echo PREFLIGHT FAIL; exit 1"
preflight ! bash -c "(openaps rm-warmup; echo PREFLIGHT ) && openaps warmup 2>&1 >/dev/null && grep -q T monitor/clock.json && echo PREFLIGHT OK || openaps fail-warmup"
monitor-cgm report invoke raw-cgm/glucose-raw.json monitor/glucose.json
monitor-pump-history report invoke raw-pump/pump-history-raw.json monitor/pump-history.json
get-basal-status report invoke monitor/temp-basal-status.json
get-pump-details report invoke monitor/reservoir.json monitor/status.json monitor/battery.json
get-settings report invoke raw-pump/bg-targets-raw.json settings/bg-targets.json raw-pump/insulin-sensitivities-raw.json settings/insulin-sensitivities.json raw-pump/selected-basal-profile.json raw-pump/settings.json settings/selected-basal-profile.json settings/settings.json
gather-pump-data ! bash -c "openaps get-basal-status; openaps get-pump-details; openaps monitor-pump-history;  openaps get-settings"
gather-clean-data ! bash -c "openaps monitor-cgm && openaps gather-pump-data"
do-oref0 report invoke oref0-monitor/profile.json oref0-monitor/iob.json oref0-predict/oref0.json
enact-oref0 report invoke oref0-enacted/enacted-temp-basal.json
do-everything ! bash -c "(openaps preflight && openaps gather-clean-data && openaps do-oref0 && openaps enact-oref0);  openaps report-nightscout"
ping ! echo PING
pong ! echo PONG
hello ! echo hello
okbar ! bash -c "echo $1" --
report-nightscout report invoke  nightscout/recent-treatments.json nightscout/uploaded.json

bewest commented 8 years ago

Aliases are now included:

bewest@bewest-MacBookPro:~/Documents/loop-new-style$ oref0 template mint alias -h
/usr/local/bin/oref0-template alias <type>

Commands:
  common  generate common aliases

Options:
  -h, --help  Show help                                                [boolean]
bewest@bewest-MacBookPro:~/Documents/loop-new-style$ oref0 template mint alias common | openaps import
rm-warmup ! bash -c "rm -f model.json monitor/clock.json > /dev/null"
warmup report invoke model.json raw-pump/clock-raw.json monitor/clock.json
fail-warmup ! bash -c "echo PREFLIGHT FAIL; exit 1"
preflight ! bash -c "(openaps rm-warmup; echo PREFLIGHT ) && openaps warmup 2>&1 >/dev/null && grep -q T monitor/clock.json && echo PREFLIGHT OK || openaps fail-warmup"
monitor-cgm report invoke monitor/glucose-raw.json monitor/glucose.json
monitor-pump-history report invoke monitor/pump-history-raw.json monitor/pump-history.json
get-basal-status report invoke monitor/temp-basal-status.json
get-pump-details report invoke monitor/reservoir.json monitor/status.json monitor/battery.json
get-settings report invoke settings/bg-targets-raw.json settings/bg-targets.json settings/insulin-sensitivities-raw.json settings/insulin-sensitivities.json settings/selected-basal-profile.json settings/settings.json
gather-pump-data ! bash -c "openaps get-basal-status; openaps get-pump-details; openaps monitor-pump-history;  openaps get-settings"
gather-clean-data ! bash -c "openaps monitor-cgm && openaps gather-pump-data"
do-oref0 report invoke oref0-monitor/profile.json oref0-monitor/iob.json oref0-predict/oref0.json
enact-oref0 report invoke oref0-enacted/enacted-temp-basal.json
do-everything ! bash -c "openaps preflight && openaps gather-clean-data && openaps do-oref0 && openaps enact-oref0"
bewest commented 8 years ago

Here are some additional templates for consideration: https://gist.github.com/bewest/d3db9ca1c144b845382c885138a8f66e

dm61 commented 8 years ago

Hi Ben, I've tried template mint reports and template mint aliases (you are making everything too easy!). I think there may be a few inconsistencies in the minted aliases wrt minted reports, basically around raw-pump related reports:

monitor-pump-history report invoke monitor/pump-history-raw.json monitor/pump-history.json should be: monitor-pump-history report invoke raw-pump/pump-history-raw.json monitor/pump-history.json

get-settings report invoke settings/bg-targets-raw.json settings/bg-targets.json settings/insulin-sensitivities-raw.json settings/insulin-sensitivities.json settings/selected-basal-profile.json settings/settings.json should be get-settings report invoke raw-pump/bg-targets-raw.json settings/bg-targets.json raw-pump/insulin-sensitivities-raw.json settings/insulin-sensitivities.json raw-pump/selected-basal-profile.json settings/selected-basal-profile.json raw-pump/settings.json settings/settings.json

bewest commented 8 years ago

@dm61 I added a patch to dev to tweak things, thanks to your feedback.

johnmales commented 8 years ago

Hi Ben unless I'm mistaken you need to add in a line to add in "tz" and "units" devices unless I’m mistaken openaps device add tz timezones and openaps device add units units Regards John