These are chat archives for nightscout/intend-to-bolus

7th
Sep 2015
Ben West
@bewest
Sep 07 2015 00:00
sorry, OT
Nathan Racklyeft
@loudnate
Sep 07 2015 00:04
@ps2 Interesting. I've only seen X.XA firmware versions,
Scott Leibrand
@scottleibrand
Sep 07 2015 00:05
stupid easy_install. -U should be the default.
Nathan Racklyeft
@loudnate
Sep 07 2015 00:06
1.1 0B 0B is the suffix on all 3 of my pumps
@ps2 I'm curious as to why you'd ask though!
Ben West
@bewest
Sep 07 2015 00:07
VER 2.4A 1.1 0B 0B on my 522
Nathan Racklyeft
@loudnate
Sep 07 2015 00:07
(same)
Ben West
@bewest
Sep 07 2015 00:09
in theory showing those treatment circles with bg is great way for openaps to show impact of carb ratio, isf to some degree
doesn't help so much with basal stuff
Pete Schwamb
@ps2
Sep 07 2015 00:09
The 523G says 1.1F 1.1 0B 0B
That’s odd, I’d expect a higher version #, since that pump is newer.
Ben West
@bewest
Sep 07 2015 00:10
yeah, very interesting...
Pete Schwamb
@ps2
Sep 07 2015 00:10
Are the firmware versions per-pump?
model
Ben West
@bewest
Sep 07 2015 00:10
I don't think their version control is all that great
I think were just sharing directories and copy/pasting code between product lines for awhile
FDA cracked down on them several times
I mean, I think they had version control and all that
and it was so onerous that people were copy/pasting anyway just to get something done, poor engineers
so would make sense for some product manager to say, nope we're starting at $x internally
but, pure conjecture, hehehe
Pete Schwamb
@ps2
Sep 07 2015 00:13
Talking to the guy with that bluetooth -> rf device. Going to send him a cc1110 dev board and have him capture some packets.
Scott Leibrand
@scottleibrand
Sep 07 2015 00:14
nice
Ben West
@bewest
Sep 07 2015 00:14
which pump was he talking to?
Scott Leibrand
@scottleibrand
Sep 07 2015 00:14
@bewest: is there a fourth thing we need in addition to this?
  • append the local system timezone to the "timestamp": field
  • add a "date": field corresponding to the epoch time of the ISO datestring generated above
  • add a "type": "medtronic" field.
Ben West
@bewest
Sep 07 2015 00:14
hmm, well add type: "medtronic" sounds good
the iso string needs to be valid iso string, which can be any timezone
calling date.toISOString( ) in js does the right thing
Scott Leibrand
@scottleibrand
Sep 07 2015 00:15
I don't remember what "also needs a property with the name of the value of type" means
Ben West
@bewest
Sep 07 2015 00:16
once you've done that, we don't really care what date is, requiring it is purely a legacy rule
so example: { type: "sgv", sgv: 123 }
this satisifies the rule
whereas: { type: "foo", "value": "bar" } is invalid
fixed: { type: "foo", foo: "bar" } is valid
Scott Leibrand
@scottleibrand
Sep 07 2015 00:17
so do we want { type: "medtronic", medtronic: "Bolus" } then?
Ben West
@bewest
Sep 07 2015 00:17
yeah, I think that makes sense, to essentially renaming/copying _type to medtronic
can do both of these using json commandline tool I think
Scott Leibrand
@scottleibrand
Sep 07 2015 00:18
orly
Ben West
@bewest
Sep 07 2015 00:18
yeah, with combination -f, -I et atll should be something like...
cat pump-history.json | json  -e "this.medtronic = this._type;" | json -e "this.dateString = new Date(this.date).toISOString( )"
yup
Scott Leibrand
@scottleibrand
Sep 07 2015 00:20
what package does "json" come in?
Ben West
@bewest
Sep 07 2015 00:20
npm install -g json
Scott Leibrand
@scottleibrand
Sep 07 2015 00:20
thx
Ben West
@bewest
Sep 07 2015 00:21
sudo
simon says
Scott Leibrand
@scottleibrand
Sep 07 2015 00:21
make me a sandwitch
Ben West
@bewest
Sep 07 2015 00:21
hmm, why is it called simon says, why not susy says?
Scott Leibrand
@scottleibrand
Sep 07 2015 00:21
much more interesting than making a sandwich
Rachel Sandlain
@audiefile
Sep 07 2015 00:22
because it's a patriarchal society so why listen to susy?
Ben West
@bewest
Sep 07 2015 00:22
adding -f allows naming eg -f ./monitor/pump-history.json
that sends it to stdout
to edit IN PLACE, add -I
Scott Leibrand
@scottleibrand
Sep 07 2015 00:23
pi@rpi4 ~/openaps-dev $ cat pumphistory.json | json -e "this.medtronic = this._type;" | json -e "this.dateString = new Date(this.date).toISOString( )"
undefined:2
this.dateString = new Date(this.date).toISOString( )
^
RangeError: Invalid time value
starting with:
"timestamp": "2015-09-06T15:09:51",
Ben West
@bewest
Sep 07 2015 00:24
ah
interesitng
ok
edit:
-e "this.dateString = (new Date(Date.parse(this.timestamp))).toISOString( )"
hmmm
Scott Leibrand
@scottleibrand
Sep 07 2015 00:25
that assumes I'm in UTC
Ben West
@bewest
Sep 07 2015 00:25
yes it does
ok to just add current you can do similar
Scott Leibrand
@scottleibrand
Sep 07 2015 00:28
pi@rpi4 ~/openaps-dev $ grep timestamp pumphistory.json | sed "s/\",/date +%z\",/"
"timestamp": "2015-09-06T15:09:51-0700",
that's how to do it in bash. :)
Ben West
@bewest
Sep 07 2015 00:28
sure, or similar with json
Scott Leibrand
@scottleibrand
Sep 07 2015 00:29
not sure how to do it with json syntax
Ben West
@bewest
Sep 07 2015 00:29
json -e "this.timestamp += '$(date +%z)'"
Scott Leibrand
@scottleibrand
Sep 07 2015 00:29
does nightscout expect "dateString" rather than "timestamp"?
Ben West
@bewest
Sep 07 2015 00:29
hmmm
well simple answer is yes
there's a way to customize it per type, but it's not fully consistent yet
Scott Leibrand
@scottleibrand
Sep 07 2015 00:30
k, easy enough to copy it
Ben West
@bewest
Sep 07 2015 00:31
I like this
Scott Leibrand
@scottleibrand
Sep 07 2015 00:31
$ cat pumphistory.json | json -e "this.medtronic = this._type;" | json -e "this.dateString = .timestamp + '$(date +%z)'" | less
Ben West
@bewest
Sep 07 2015 00:31
cat pump-history.json | json -e "this.medtronic = this._type;" | json -e "this.dateString = (new Date(Date.parse(this.timestamp = this.timestamp + '$(date +%z)'))).toISOString( )"
that's cool
you can customize it by setting TZ=ZONE as env variable
bewest@hither:~/Documents/foo/monitor$ cat pump-history.json | json  -e "this.medtronic = this._type;" | json -e "this.dateString = (new Date(Date.parse(this.timestamp = this.timestamp + '$(date +%z)'))).toISOString( )" | tail -n 15
    "_byte[5]": 0,
    "date": 1434456358000,
    "unabsorbed_insulin_count": "??",
    "_byte[7]": 0,
    "_date": "7a8504100f",
    "bolus_estimate": 5.7,
    "unknown_byte[8]": 0,
    "carb_ratio": 13,
    "food_estimate": 5.7,
    "bg_target_low": 106,
    "sensitivity": 45,
    "medtronic": "BolusWizard",
    "dateString": "2015-06-16T11:05:58.000Z"
  }
]
Scott Leibrand
@scottleibrand
Sep 07 2015 00:33
I prefer leaving timestamp alone and using the -0700 format in dateString instead of Z, as long as NS won't care
so cat pumphistory.json | json -e "this.medtronic = this._type;" | json -e "this.dateString = this.timestamp + '$(date +%z)'" | json -e "this.type = 'medtronic'" | less
Ben West
@bewest
Sep 07 2015 00:34
sure, my version also modifies timestamp so you can see what happened
Scott Leibrand
@scottleibrand
Sep 07 2015 00:34
  {
    "programmed": 4,
    "_type": "Bolus",
    "type": "medtronic",
    "_description": "Bolus 2015-09-06T15:02:51 head[4], body[0] op[0x01]",
    "duration": 0,
    "timestamp": "2015-09-06T15:02:51",
    "_body": "",
    "_head": "01282800",
    "amount": 4,
    "_date": "b3424f060f",
    "medtronic": "Bolus",
    "dateString": "2015-09-06T15:02:51-0700"
  }
Ben West
@bewest
Sep 07 2015 00:35
sure, nice
that should work just fine
oh
yes
should work great
Scott Leibrand
@scottleibrand
Sep 07 2015 00:35
cool
Ben West
@bewest
Sep 07 2015 00:35
good catch
here's how to customize the timezone
in case it's needed:
before the date command preprend TZ=US/Eastern, eg you desired timezone
Scott Leibrand
@scottleibrand
Sep 07 2015 00:39
do you have example syntax offhand for POSTing to /api/v1/entries ?
reading curl man page. :(
Ben West
@bewest
Sep 07 2015 00:40
cat pump-history.json | json -e "this.medtronic = this._type;" | json -e "this.dateString = (new Date(Date.parse(this.timestamp = this.timestamp + '$(TZ='US/Eastern' date +%z)'))).toISOString( )" | tail -n 22
yes
so if you have the hashed api_secret in variable $api_secret
and say $addr is your nightscout address
it goes like this: curl -X POST --data-binary @./monitor/ns-entries.json -H "API-SECRET: $api_secret" -H "content-type: application/json" $addr/api/v1/entries.json
to pipe from stdin or to pipe from another curl fetching info from another NS, change --data-binary @-
that pipes from stdin
Scott Leibrand
@scottleibrand
Sep 07 2015 00:42
thx. is the api_secret specified by the user in azure etc. the same as this?
Ben West
@bewest
Sep 07 2015 00:42
no
it's the hashed version of that
Scott Leibrand
@scottleibrand
Sep 07 2015 00:42
| md5, or sha, or ?
Ben West
@bewest
Sep 07 2015 00:43
sha1
Scott Leibrand
@scottleibrand
Sep 07 2015 00:43
k
Ben West
@bewest
Sep 07 2015 00:43
when c-r-m starts up, it prints it for you
there's a nifty way to make openaps.ini track your timezone
Scott Leibrand
@scottleibrand
Sep 07 2015 00:49
hmm, nightscout is reporting <h2><em>400</em> Error: invalid json</h2>
jsonlint is fine with it
curl -X POST --data-binary ~./pumphistory.ns.json -H "API-SECRET: $API_SECRET" -H "content-type: application/json" $site/api/v1/entries.json
Ben West
@bewest
Sep 07 2015 00:50
ah, ~./ might not be right
Scott Leibrand
@scottleibrand
Sep 07 2015 00:50
yeah just noticed that
changing that ~ to @ fixed it
now to get it to actually use those. :)
how do I search /api/v1/entries/ to make sure it shows up there?
query strings of some sort i recall...
Ben West
@bewest
Sep 07 2015 00:54
for this, I would try: /api/v1/entries/medtronic
.json
Scott Leibrand
@scottleibrand
Sep 07 2015 00:55
ooh nice
(the docs. no results for that query)
Ben West
@bewest
Sep 07 2015 00:56
did server have any response when you posted?
it only respondes with rejects
Scott Leibrand
@scottleibrand
Sep 07 2015 00:57
oh, yes
pi@rpi4 ~/openaps-dev $ curl -X POST --data-binary @./pumphistory.ns.json -H "API-SECRET: $API_SECRET" -H "content-type: application/json" $site/api/v1/entries.json
[{"programmed":1,"_type":"Bolus","type":"medtronic","_description":"Bolus 2015-09-06T16:01:07 head[4], body[0] op[0x01]","duration":0,"timestamp":"2015-09-06T16:01:07","_body":"","_head":"010a0a00","amount":1,"_date":"874150060f","medtronic":"Bolus","dateString":"2015-09-06T16:01:07-0700"},{"_type":"TempBasalDuration","duration (min)":30,"_description":"TempBasalDuration 2015-09-06T16:00:53 head[2], body[0] op[0x16]","timestamp":"2015-09-06T16:00:53","_body":"","_head":"1601","_date":"b54010460f","medtronic":"TempBasalDuration","dateString":"2015-09-06T16:00:53-0700","type":"medtronic"},{"_type":"TempBasal","temp":"absolute","_description":"TempBasal 2015-09-06T16:00:53 head[2], body[1] op[0x33]","timestamp":"2015-09-06T16:00:53","_body":"00","_head":"3324","rate":0.9,"_date":"b54010460f","medtronic":"TempBasal","dateString":"2015-09-06T16:00:53-0700","type":"medtronic"}]pi@rpi4 ~/openaps-dev $
what are typical reasons for rejection?
Ben West
@bewest
Sep 07 2015 00:58
what happened to date field?
Scott Leibrand
@scottleibrand
Sep 07 2015 00:59
ah
Ben West
@bewest
Sep 07 2015 00:59
sorry, it's legacy api
unfortunately it's one of few rules actually checked
you might add device: medronic or decice: medtronic://m522 or similar
you'll be able to query against text fields as-is
regex works for prefix/patterns on the dateString field
because you're following good style, the api supports a regex on an optional field which should work nicely for you
Scott Leibrand
@scottleibrand
Sep 07 2015 01:01
hmm, I don't see where you ever added date in your json -e code
Ben West
@bewest
Sep 07 2015 01:01
my pump-history had a date
Jason Calabrese
@jasoncalabrese
Sep 07 2015 01:01
I like the uri format for device, and regex via the api
Scott Leibrand
@scottleibrand
Sep 07 2015 01:01
ah. I need to add mine based on the dateString
how did you get your openaps instance to add date?
Ben West
@bewest
Sep 07 2015 01:02
yeah, can use (new Date(Date.parse(this.dateString)).getTime( ) I believe
dunno, think my decocare did it?
Jason Calabrese
@jasoncalabrese
Sep 07 2015 01:02
would it make sense to use some kind of device id? maybe not the serial number, but something unique to the pump?
Ben West
@bewest
Sep 07 2015 01:02
I mean, I just ran my report
Scott Leibrand
@scottleibrand
Sep 07 2015 01:02
weird
Ben West
@bewest
Sep 07 2015 01:02
it's in my openaps-eample repo
I think that time slice regexp api pattern might allow you to regexp on other fields
Scott Leibrand
@scottleibrand
Sep 07 2015 01:06
there we go. adding date fixed it
Ben West
@bewest
Sep 07 2015 01:07
all apis are a little persnickety in their own way I guess
Scott Leibrand
@scottleibrand
Sep 07 2015 01:07
this one is just enforcing what you said it would. :)
Ben West
@bewest
Sep 07 2015 01:08
so that's pretty neat
you can do it conditionally with something like -e "this.date ? this.date : (/* ... */ )"
until we get down to difference behind why I have it and you don't
Scott Leibrand
@scottleibrand
Sep 07 2015 01:10
so cat pumphistory.json | json -e "this.medtronic = this._type;" | json -e "this.dateString = this.timestamp + '$(date +%z)'" | json -e "this.type = 'medtronic'" | json -e "this.date ? this.date : this.date = new Date(Date.parse(this.dateString)).getTime( )" > pumphistory.ns.json
Ben West
@bewest
Sep 07 2015 01:10
yeah, looks good
oh
no
sorry
hah
Scott Leibrand
@scottleibrand
Sep 07 2015 01:12
?
just updated to handle custom timezone as well

HISTORY=${1-pumphistory.json}
OUTPUT=${2-pumphistory.ns.json}
TZ=${3}

cat $HISTORY | \
  json -e "this.medtronic = this._type;" | \
  json -e "this.dateString = this.timestamp + '$(TZ=TZ date +%z)'" | \
  json -e "this.type = 'medtronic'" | \
  json -e "this.date = this.date ? this.date : this.date = new Date(Date.parse(this.dateString)).getTime( )" \
  > $OUTPUT
Scott Leibrand
@scottleibrand
Sep 07 2015 01:17
nice. tested and works.
Ben West
@bewest
Sep 07 2015 01:17
ok, one more change actually
yeah, it works
but...
updated, eliminated bad form redundancy in last bit json -e "this.date = this.date ? this.date : new Date(Date.parse(this.dateString)).getTime( )"
"if there's a date, fine and use it, if no date use this value"
Scott Leibrand
@scottleibrand
Sep 07 2015 01:20
k. I'll extend this to read a nightscout.json and actually do the curl bits
Ben West
@bewest
Sep 07 2015 01:20
would do that as it's own report, proc type
then do curl as one of the "enact" style, similar to bolus/basal
I'm keeping different phases in different subdirs to keep the similarly-named reports separate/clear
Scott Leibrand
@scottleibrand
Sep 07 2015 01:21
what's the point of wrapping all these shell scripts in openaps enact commands?
Ben West
@bewest
Sep 07 2015 01:21
you mean as device/use commands?
Scott Leibrand
@scottleibrand
Sep 07 2015 01:22
I get why "write this file" is useful to do as openaps report
but "upload something to nightscout" has no output to track in git
Ben West
@bewest
Sep 07 2015 01:22
because it makes the openaps loop a very consistent flow of creating reports and then invoking reports in the order
ah, well it could for example delete it's input file
so if they're in separate subdirs
Scott Leibrand
@scottleibrand
Sep 07 2015 01:23
seems like we're overloading too much stuff into this openaps report paradigm
Ben West
@bewest
Sep 07 2015 01:23
same way bolus might wright dumb report that it did it's thing and delete the recommendation
Scott Leibrand
@scottleibrand
Sep 07 2015 01:23
hmm
Ben West
@bewest
Sep 07 2015 01:23
the script is compatible as an openaps device and will work with the report system if you want
you can also alias it in openaps as an external thing
if only so all your loop commands are "inside" the openaps ecosystem
it's harder to share code and techniques with people with hardcoded stuff
Scott Leibrand
@scottleibrand
Sep 07 2015 01:25
there's so much more that has to be done (see openaps-js/bin/loop.sh)...
and putting stuff into openaps.ini hides it from the sharable source code
you can't share your openaps.ini without sharing your pump serial number
Ben West
@bewest
Sep 07 2015 01:25
if it's compatible, it doesn't matter
Scott Leibrand
@scottleibrand
Sep 07 2015 01:26
feels like that should be "user data", not "logic and code"
Ben West
@bewest
Sep 07 2015 01:26
maybe I'm confused what we're talking about
the repo that openaps.ini is in should not contain any code at all
Scott Leibrand
@scottleibrand
Sep 07 2015 01:26
suggest = report invoke profile.json iob.json requestedtemp.online.json requestedtemp.offline.json
that's logic that really belongs in code
Ben West
@bewest
Sep 07 2015 01:27
it should contain config and data, and that's it
Scott Leibrand
@scottleibrand
Sep 07 2015 01:27
not in openaps.ini
Ben West
@bewest
Sep 07 2015 01:27
so I can imagine additional helpers/tools to do things the diyps way
so that the resulting config has all the compatible recipes
did you see the configurable walkthrough guide?
it customizes the commands so you end up with same config
templating config stuff is easy, but those names are definitely config, not logic
Scott Leibrand
@scottleibrand
Sep 07 2015 01:28
never really looked at it. which URL?
Ben West
@bewest
Sep 07 2015 01:30
ok, kind of quirky, http://bl.ocks.org/bewest/raw/d5f0fc68c0b9ac49c146/#/openaps-worksheet, but it has section with inputs that changes the rest of the directions
similar, resin.io will actually flash your device
and sync it to their service
uses similar thing for their own instructions
we haven't yet leveraged all the tricks we can yet, either
stuff like curl -s https://gist.githubusercontent.com/bewest/d5f0fc68c0b9ac49c146/raw/32c42f51b9ee8baafe44d3248f7eb9dddca0f9d9/install_tools.sh | sudo bash for quick start
Scott Leibrand
@scottleibrand
Sep 07 2015 01:33
they have lots of white space at the top and scroll off the bottom of the screen
unless I reduce my font size
Ben West
@bewest
Sep 07 2015 01:33
it was a quick thing to try out concept
as experiment it has things that are nice and things that are not
but customizing the config stuff in template is pretty easy to do
doesn't change nature that's still config
https://gist.github.com/bewest/d5f0fc68c0b9ac49c146 it's based on @channemann 's gist
Scott Leibrand
@scottleibrand
Sep 07 2015 01:36
I think it is starting to make me uncomfortable that we have so many loop.sh's running around, some of which do lots of error checking, and some of which are more of a "execute-blindly" kind of thing
Ben West
@bewest
Sep 07 2015 01:36
might be worth looking into resin.io to standardize deploys
loop.sh should be it's own set of plugins with some tools for assisting in authoring the loop itself
so I'm thinking of tool to create basic loop, and then another tool to add reports/aliases to the loop
so you wouldn't need to write your own loop, even
but you would have to use commands to configure it
those commands can then be templatized/scripted
resin.io deploys an image with your own wifi ssid/passphrase burnt into it
similar approach
Scott Leibrand
@scottleibrand
Sep 07 2015 01:39
I really need to sit down with @channemann and @loudnate and figure out how we can consolidate their efforts and openaps-js
we're starting to splinter into too many incompatible code bases
Ben West
@bewest
Sep 07 2015 01:41
as long as your loop is only calling openaps commands, and not introducing outside logic
it should be all compatible
Ben West
@bewest
Sep 07 2015 01:42
right, I recommend using fuser
the stuff loudnate and channemann put together is completely inside openaps
Scott Leibrand
@scottleibrand
Sep 07 2015 01:43
I am definitely doing outside logic. mostly to handle error checking etc.
Ben West
@bewest
Sep 07 2015 01:44
right, so might think about making more plugins to bring that logic inside openaps
will make loop a lot simpler/more consistent
Jason Calabrese
@jasoncalabrese
Sep 07 2015 01:44
just skiming it, is ( openaps report invoke glucose.json.new || openaps report invoke glucose.json.new ) right?
Scott Leibrand
@scottleibrand
Sep 07 2015 01:44
yes
that makes it try to query glucose data a second time if the first try fails
Ben West
@bewest
Sep 07 2015 01:51
here's the one we came up with:
fuser $(python -m decocare.scan) && exit 1
cd /home/pi/$myopenaps
openaps update && \
openaps munge && \
openaps predict && \
openaps dose || (python -m decocare.stick $(python -m decocare.scan) > /dev/null && echo "Stick OK" 1>&2 || ~/fix-stick.sh 1>&2)
git push 2>&1
update, munge, predict, dose, [enact] are all openaps alias to do "phases"
fuser should be built into next gen of openaps by default
for all uses of stick
Scott Leibrand
@scottleibrand
Sep 07 2015 01:53
how do you handle conditional logic?
( ( openaps report invoke glucose.json.new || openaps report invoke glucose.json.new ) && grep -v '"glucose": 5' glucose.json.new | grep glucose ) || share2-bridge file glucose.json.new
Ben West
@bewest
Sep 07 2015 01:54
that's fine, you can make an openaps alias to do that
if alias line starts with ! it's an external shell command
Scott Leibrand
@scottleibrand
Sep 07 2015 01:54
now we're back to putting code in openaps.ini
Ben West
@bewest
Sep 07 2015 01:55
then write a plugin/use...
patch another use case to retry $x times
that's where code goes
Scott Leibrand
@scottleibrand
Sep 07 2015 01:55
it feels to me like we need an actual proper control loop with all the requisite logic
Dana Lewis
@danamlewis
Sep 07 2015 01:55
@bewest Related to convo a few days ago re: language of "invoke", munge is one that will likely need more commenting on for new users to understand
Scott Leibrand
@scottleibrand
Sep 07 2015 01:56
even my loop.sh stuff can't be very smart
Ben West
@bewest
Sep 07 2015 01:56
yeah, I think "prep foo" is better
and I think splitting this into phases will help a lot
Scott Leibrand
@scottleibrand
Sep 07 2015 01:56
we should be doing logic like checking whether X data is recent, and querying X until we get it, then moving on to Y
Ben West
@bewest
Sep 07 2015 01:56
first phase is monitoring step to gather all the data
yes, nate is implenting that as plugins
and data needs to make it through these phases
Scott Leibrand
@scottleibrand
Sep 07 2015 01:57
IMO running this sort of linear "collect everything every run" stuff is suboptimal, especially when connectivity is weak
Ben West
@bewest
Sep 07 2015 01:57
if no data makes it to basal recommendation, it's a no-op and everything just gets cleaned
Scott Leibrand
@scottleibrand
Sep 07 2015 01:57
from personal experience, that paradigm doesn't work well unless connectivity is perfect
Ben West
@bewest
Sep 07 2015 01:57
I'm not sure what you're asking for
Scott Leibrand
@scottleibrand
Sep 07 2015 01:58
I don't like hiding all this logic in discrete plugins
Ben West
@bewest
Sep 07 2015 01:58
there's a modular system that makes what you're asking for perfectly consistent
logic goes in code, right?
Scott Leibrand
@scottleibrand
Sep 07 2015 01:58
I like the fact that "get X" is a report that you call
let me start over more concretely
I'd like to be able to collect everything including pump history at startup, and after each treatment is enacted. then, I'd like to only query for updated CGM data, current temp basal, and insulin remaining in reservoir on a tight loop. when one of those changes in a way that would indicate we need to change the temp basal, re-query everything, enact a temp, and re-query pumphistory again
Ben West
@bewest
Sep 07 2015 02:01
right, sounds like you need to separate those things into different phases
Scott Leibrand
@scottleibrand
Sep 07 2015 02:01
that requires multiple loops, and looks like a state machine
Ben West
@bewest
Sep 07 2015 02:01
I suggest introducing different subdirectories you can keep track
Scott Leibrand
@scottleibrand
Sep 07 2015 02:02
afaict that is incompatible with this kind of linear execution of modules that you're pushing us toward
Ben West
@bewest
Sep 07 2015 02:02
my openaps-example shows how to use subdirectories and alis
and channemann just posted his write up
the retry logic goes in the dexcom vendor
Scott Leibrand
@scottleibrand
Sep 07 2015 02:03
I don't want to just block on new dexcom data
Ben West
@bewest
Sep 07 2015 02:03
you're asking for a configurable --force --retries 3 or something feature for dexcom use
ah ok, channemann and loudnate also setup several loops
Scott Leibrand
@scottleibrand
Sep 07 2015 02:03
I want to wait until new dex data, or new medtronic data, indicates we need to do something different
Ben West
@bewest
Sep 07 2015 02:03
there's one on reboot, one every-five
Scott Leibrand
@scottleibrand
Sep 07 2015 02:03
we're talking at totally different scales here
Ben West
@bewest
Sep 07 2015 02:04
no... I'm trying to explain how idiomatic use does what you want
Scott Leibrand
@scottleibrand
Sep 07 2015 02:04
I'm talking about a continuously running controller
Ben West
@bewest
Sep 07 2015 02:04
ah ok, a daemon that runs all the time instead of cron?
ok, that's interesting
loudnate is already running monitor.py
Scott Leibrand
@scottleibrand
Sep 07 2015 02:04
yeah, and refreshes everything on its own timescales...
re-running the "openaps suggest" stuff with each new bit of data
and collecting more data if that indicates action would be required
Ben West
@bewest
Sep 07 2015 02:05
but even that is running openaps plugin commands
that's how it shares so much code
Scott Leibrand
@scottleibrand
Sep 07 2015 02:05
sure, there are some components that belong as modules
Ben West
@bewest
Sep 07 2015 02:05
a daemon is interesting concept
Scott Leibrand
@scottleibrand
Sep 07 2015 02:05
I don't like the idea of trying to shoehorn higher and higher level complexity into more and more modules
Ben West
@bewest
Sep 07 2015 02:05
I've thought about setting up mqtt or similar
fair, but I'm also not convinced you're taking full advantage of what's there
Scott Leibrand
@scottleibrand
Sep 07 2015 02:06
yeah, probably not
Ben West
@bewest
Sep 07 2015 02:06
but proposing a daemon that does stuff is nifty idea
Scott Leibrand
@scottleibrand
Sep 07 2015 02:06
I miss coming to SF and talking this through in person
need to set up some hangouts or something to substitute
Ben West
@bewest
Sep 07 2015 02:06
yeah, you missed a few ;-)
something about trips...
Scott Leibrand
@scottleibrand
Sep 07 2015 02:07
well, I also changed jobs
so no more going to Twitter HQ
Ben West
@bewest
Sep 07 2015 02:07
oh yeah, what happened? where are you now?
weren't impressed by the ceo?
Scott Leibrand
@scottleibrand
Sep 07 2015 02:07
DLVR, a startup doing video streaming performance measurement and optimization
Ben West
@bewest
Sep 07 2015 02:07
nice
hmmmm
does tomer gil work there?
Scott Leibrand
@scottleibrand
Sep 07 2015 02:07
nope
just 12 of us so far. :)
I wasn't looking to leave Twitter, but this was too good an opportunity to pass up
Ben West
@bewest
Sep 07 2015 02:08
heh
loudnate came up with a webserver of sorts... so that works similar to git-web
it's a plugin, but it can ask as agent/server etc
act, even
Pete Schwamb
@ps2
Sep 07 2015 02:19
@bewest The model number of the pumps that Félix is using is mmt-754, which I guess is the UK version of the 530g?
Nathan Racklyeft
@loudnate
Sep 07 2015 02:23
Hey folks, sorry to miss a bit of chatter here.
Pete Schwamb
@ps2
Sep 07 2015 02:24
Would you expect that pump to be able to do remote temp-basal & bolus?
Nathan Racklyeft
@loudnate
Sep 07 2015 02:27
I think so, but @bewest should confirm
@scottleibrand I'm happy to help, I think, but it sounds like there's a larger philosophical discussion around how openaps is structured.
I like how openaps is structured, and I built my system around it. 75% of the code is public.
I think the advantage of the plugin system is that creating smaller, interoperable parts allows folks to focus on areas they want to tweak.
Nathan Racklyeft
@loudnate
Sep 07 2015 02:33
@channemann has a lot of drive around improving prediction. he's able to do his own dev just in that area and not have to worry about the cleaning and parsing of history and glucose, or the logic about choosing a dose based on the prediction output
me personally, I don't have any desire that my plugins be endorsed by the "org" or widely used. I'm happy to relinquish any names in the openapscontrib namespace.
Dana Lewis
@danamlewis
Sep 07 2015 02:37
@loudnate Would love to talk more this week on this topic
Ditto @channemann . Will email ya'll and see if there's a good time to do a hangout or phone
Scott Leibrand
@scottleibrand
Sep 07 2015 02:44
My main concern is that we get everyone's contributions incorporated into a coherent whole that works together. Right now openaps-js is incompatible with most of what you're doing, so I'm over here working in my own silo and not benefiting from any of your efforts, or vice versa.
+1 to Dana's suggestion of setting up a call to discuss who wants to do what and how we pull together around something common.
Rachel Sandlain
@audiefile
Sep 07 2015 03:54
I might be mistaken on some points but I like that the way things stand now allows for more flexibility. I have an older pump that doesn't have all of the commands so I've had to rework somethings to get around that. I will say that having a big picture game plan that allows people to work together but on components that interest them sounds like the way to go. Just my two cents
Ali Mazaheri
@amazaheri
Sep 07 2015 04:08
@scottleibrand and @danamlewis +1 on hangout, please include me as well.
Ben West
@bewest
Sep 07 2015 04:10
thanks, @audiefile
sounds good
Ali Mazaheri
@amazaheri
Sep 07 2015 04:11
@bewest when you get in for CWD? I wanna set a side some me so we can hack some stuff out
Dana Lewis
@danamlewis
Sep 07 2015 04:15
@audiefile Thanks for continuing to provide input! Ps - would love to know where your are in your implementation. Are you up and running yet, testing, or still building?
Ben West
@bewest
Sep 07 2015 04:15
crap i just realized it's like next week
oh man... I scheduled interview on friday
thought it was oct
Dana Lewis
@danamlewis
Sep 07 2015 04:16
Interview where?
Oh gotcha you were talking @amazaheri. (Ps @amazaheri , see email)
Ben West
@bewest
Sep 07 2015 04:17
some bio sensor company
it would be useful to do planning on next release
would love to get issues like retry logic into the use's
so it's not in loop
take stock of existing plugins and plan what plugins we'd like ideally
and whether to re-do/rename/augment...
also windows support, obvi ;-)
Dana Lewis
@danamlewis
Sep 07 2015 04:20
Yep see email @bewest :)
Ben West
@bewest
Sep 07 2015 04:27
nice
I'm less worried about the divergence, I think if we rip out the logic you want and put them into use's, all will be fine
you can configure multiple reports (in different subdirectories/phases) against same "use"
might need to re-org the plugins to make more sense
I'm thinking leaning more and more of the cooking/baking idiom is good
putting recipes into recipe book
getting tools
would be nice to take inventory of the munge uses, take inventory of ideal way it should work and merge it
idea for openaps design was just enable the building blocks and see what people would build/need next
now we have lots of plugins thanks to contribs, we can do that differential
Scott Leibrand
@scottleibrand
Sep 07 2015 04:31
yeah, I think I'm moving beyond that a bit, toward a bit more of a "here's how to do a basic, safe loop"
Ben West
@bewest
Sep 07 2015 04:31
not sure we're quite there
profile and other stuff needs to be calculated
Scott Leibrand
@scottleibrand
Sep 07 2015 04:31
?
agreed we're not quite there
not sure what you mean about profile though
Ben West
@bewest
Sep 07 2015 04:32
right now I think some bits are manually set, right?
Scott Leibrand
@scottleibrand
Sep 07 2015 04:32
nope
I removed the last hardcoded thing today: max_iob
Ben West
@bewest
Sep 07 2015 04:32
ah, ok, well I suppose everyone's a bit behind on something
Scott Leibrand
@scottleibrand
Sep 07 2015 04:33
now it defaults to zero ("safe mode") if you don't provide a max_iob.json
Ben West
@bewest
Sep 07 2015 04:33
I think the alias/report system will go long way once we start introducing subdirectories to represent phases, and re-org the important use's workflow
Scott Leibrand
@scottleibrand
Sep 07 2015 04:33
which basically turns openaps-js into a smart predictive low glucose suspend system
Ben West
@bewest
Sep 07 2015 04:33
once that's done, we can create another openaps-ctl or similar to help automatically maintain the loop[s] itself
or daemon... whatever
I think we're going to uncover a few different things, that different combos of hardware can do more easily
easiest is "monitoring" post everythign to NS for monitoring and old-school DIYPS
with maybe some notifications/suggestions
so makes sense to have some interactive guide, cross between resin.io and the channemann + revealjs mockup
then there's DIYPs reference "openaps reference"
then there's other things, loudnates stuff
my hardware won't work with loudnate's stuff
but intended for the plugins to support divergence for diverse hardware/use-cases... these algorithms are "controversial" to some degree, so ability to plug'n'play with isolated part is important
Dana Lewis
@danamlewis
Sep 07 2015 04:39
Yea..
Jason Calabrese
@jasoncalabrese
Sep 07 2015 05:58
email lists seem so dated
but a call sounds good
Dana Lewis
@danamlewis
Sep 07 2015 06:00
Heh. Hard to wrangle everyone into being up to speed when geographically scattered and with various levels of engagement, though, so aiming for all forms of comm from here to web to email to phone
Scott Leibrand
@scottleibrand
Sep 07 2015 10:07
so I rewrote openaps-js loop.sh (on the new-loop branch) as I was alluding to earlier. now it monitors glucose.json, currenttemp.json, and reservoir.json status on a tight loop (~15 seconds with good connectivity), and only runs the longer full loop when the reservoir changes by more than 0.2U (indicating a bolus) or when openaps suggest indicates a new temp is likely required (based on BG and currenttemp.json)
that should allow it to respond much more quickly (within 1-2 minutes instead of 3-5) when BG changes, and deal much more effectively with poor connectivity
Jason Calabrese
@jasoncalabrese
Sep 07 2015 10:10
geez your still up too
Scott Leibrand
@scottleibrand
Sep 07 2015 10:10
heh
Oliver Schumacher
@oschumac
Sep 07 2015 15:29
@scottleibrand Hi i upload enactedtemp.json to a new collection called APS_Threadments. And use a copy of the Nightscout site which shows only treadments given by openaps. Would be cool to combine that one day. It was a quick and dirty solution but it works. I'll send the Treadments with a fake BG. So the level of the dots don't show the BG Level they show the insulin level. I don't understand the Nightscout side enough, ti implement. My own data row. Which would be a nicer solution. Has anybody an better idea how to visualize temp basals?
Jay and pumphistorie script would be also nice i like to write one. Cause of it woud give us another layer of view whats happend and what will be we best next choice for openaps. Like oh BG always low today asuming sport activities and lower basal as a guess. Bevor the next low comes or somthing like that.
Lori
@LoriLori
Sep 07 2015 15:57
kind of thinking about setting up Tidepool blip https://twitter.com/hannemannemann/status/634397176727101441
think it is not realtime like nightscout
Jason Calabrese
@jasoncalabrese
Sep 07 2015 16:43
To run blip you need to start something like 20 processes, crazy
Lori
@LoriLori
Sep 07 2015 16:43
there is https://github.com/tidepool-org/tideline component to display tide pool chart from single json file
and that single json could be pointed to night sccout
which could translate data to tide pool json
its in example\data\device-data.json
timomer
@timomer
Sep 07 2015 17:12
@LorelaiL I am also interested in running Tidepool to view historical data, if you set an instance up would be good to hear
Lori
@LoriLori
Sep 07 2015 17:25
@timomer I think I will just use tideline
Ali Mazaheri
@amazaheri
Sep 07 2015 17:43
@bewest anything I need to work on my end for RileyLink to save our time when you are in town? really hoping to wrap it up and do a test run of OpenAPS at school :)
folks, not sure who is not using Dexcom these days but I have a minimed which I got as part of 723 pump I purchased (Brand new I guess with some supplies) if anyone need one I can send it your way. Let me know.
Oskar Pearson
@oskarpearson
Sep 07 2015 22:51
@scottleibrand I'm liking the changes on loop.sh - much cleaner. I was starting to do some of the same types of changes :)
I thought this idea might be useful to someone... based on the original every-five.sh
echo none > /sys/class/leds/led0/trigger
led_on() {
  echo 1 > /sys/class/leds/led0/brightness
}
led_off() {
  echo 0 > /sys/class/leds/led0/brightness
}

morse() {
   led_on
   sleep $1
   led_off
   sleep 0.1
}
dot() {
  morse 0.2
}
dash() {
  morse 0.75
}
send_s() {
  dash ; dash ; dash
  sleep 1
}
send_k() {
  dash ; dot ; dash
  sleep 1
}
send_o() {
  dot ; dot ; dot
  sleep 1
}

die() {
   sos
   led_off
}

sos() {
   send_s ; send_o ; send_s
}

finish() {
   echo 0 >/sys/class/leds/led0/brightness
}
trap finish EXIT

fuser $(python -m decocare.scan) && exit 1

cd /root/openaps-dev

led_on
openaps update 2>&1     | tee -a /var/log/openaps-stuff.log || die
openaps munge 2>&1     | tee -a /var/log/openaps-stuff.log  || die
openaps predict 2>&1     | tee -a /var/log/openaps-stuff.log || die
led_off

sleep 2
send_o ; send_k
Scott Leibrand
@scottleibrand
Sep 07 2015 22:53
Thanks. Still testing it: mostly to find bugs that can put it into an endless nonproductive loop. Until I've run it for a week or so I'll probably keep one Pi on master for overnight.
Oskar Pearson
@oskarpearson
Sep 07 2015 22:54
It flickers the LED on the pi with "OK" in morse on success, or "SOS" when something goes wrong
Dana Lewis
@danamlewis
Sep 07 2015 22:55
Nice
Scott Leibrand
@scottleibrand
Sep 07 2015 22:55
Nice. I would probably go with something simpler, like keeping the green LED on as long as it's looping well, and illuminating red for issues.
And turn off green if it hasn't successfully read in 10m or so.
Oskar Pearson
@oskarpearson
Sep 07 2015 22:56
@scottleibrand One thing I noticed in loop.sh - https://github.com/openaps/openaps-js/blob/master/bin/loop.sh#L43 refers to function finish ... which is nodejs... bash doesn't need the 'function'
I'm red-green colorblind ;)
Scott Leibrand
@scottleibrand
Sep 07 2015 22:56
Yeah, most of my functions do name() { }
the function name { } syntax doesn't require ()
just copied that from someone else's code. :-)
Oskar Pearson
@oskarpearson
Sep 07 2015 22:57
It means that the finish code never runs (the declaration of finish isn't valid, so the trap doesn't work...) Or at least, when I tested it
Scott Leibrand
@scottleibrand
Sep 07 2015 22:58
hmm, you sure?
guess it doesn't hurt to switch it to finish() for consistency either way.
Oskar Pearson
@oskarpearson
Sep 07 2015 22:58
I was working on getting this to work at the top of the script, which would mean that we'd need to explicitly handle every error case:
# It's absolute critical that an error does not lead to invalid actions on the
# pump. So, if we receive an error that's unexpected, we must exit.
set -x
set -o pipefail
set -e
Scott Leibrand
@scottleibrand
Sep 07 2015 22:58
are the two LEDs led0 and led1
oskarpearson @oskarpearson goes to double check
Oskar Pearson
@oskarpearson
Sep 07 2015 23:00
There are two LEDs - one is hard-wired to power, so you can't change it. The other normally reflects whenever there's disk-io, but you can change the mode
Scott Leibrand
@scottleibrand
Sep 07 2015 23:00
I wonder if you'll be able to catch all the random crap you get with poor connectivity.
Ah, that's dumb. :-(
still useful though I guess.
Green for looping successfully, off otherwise.
And flash for errors if you want.
The power one is the red one.
Oskar Pearson
@oskarpearson
Sep 07 2015 23:03
I found the problem with the function thing... It was because I was being a banana and running "/bin/sh loop.sh" instead of "bash loop.sh". The pi doesn't use bash as it's default shell.. it uses dash, which doesn't support the function syntax. So... ignore me
Scott Leibrand
@scottleibrand
Sep 07 2015 23:04
Ah. Well feel free to submit a PR to fix for consistency and compatibility.
And one for your LED stuff if you want. :-)
Oskar Pearson
@oskarpearson
Sep 07 2015 23:06
My intention with catching the errors was to try and fail-safe every run. And instead try and re-run things "from the top" if there was any doubt about reliability. I think you've taken a similar approach with trying to speed things up and do less overall.
I'm definitely going to submit PRs... but I'm still figuring my way around things. I'll definitely get there though!
Screen Shot 2015-09-08 at 00.09.14.png
Has anyone noticed weirdness in the graph when recalibrating the sensor?
It's like time goes backwards
Scott Leibrand
@scottleibrand
Sep 07 2015 23:16
What graph is that?
my approach to communication errors is to continue/retry, rather than start over. More importantly, I check that we have valid and recent data before proceeding.
Oskar Pearson
@oskarpearson
Sep 07 2015 23:17
It's the timeline graph from OpenAPS-monitor. I need to check the underlying data - but it should be reflecting the CGMS data from the Medtronic pump
Scott Leibrand
@scottleibrand
Sep 07 2015 23:17
ah, I'm not using monitor yet.
Oskar Pearson
@oskarpearson
Sep 07 2015 23:18
I think that something in the data clean scripts are getting confused. Or the pump updates recent values based on a sensor recalibration. I'm going to check the underlying data soon
Nathan Racklyeft
@loudnate
Sep 07 2015 23:29
@oskarpearson are you using a medtronic CGM?
The meter calibration entries are stored in sensor history, but they're not sorted by date.
Nathan Racklyeft
@loudnate
Sep 07 2015 23:35
re-sorting the entries by date can be done by https://github.com/loudnate/openaps-glucosetools
Oskar Pearson
@oskarpearson
Sep 07 2015 23:37
@loudnate I'm using this for the munge step: munge = report invoke clean_glucose.json clean_history.json reconcile_history.json resolve_history.json normalized_history.json - which is using openapscontrib.mmhistorytools
Nathan Racklyeft
@loudnate
Sep 07 2015 23:38
I'm assuming the clean_glucose.json is using the glucosetools vendor
and you're graphing clean_glucose.json and not recent_glucose.json?
Oskar Pearson
@oskarpearson
Sep 07 2015 23:43
I'm basically using https://gist.github.com/channemann/d29abfabffd365ed1735 - and openaps_reports.py refers to 'clean_glucose.json', yep
There were some minor buglets in that gist - so I did have to make some adjustments
[report "clean_glucose.json"]
device = munge
use = clean
infile = recent_glucose.json
reporter = JSON
Nathan Racklyeft
@loudnate
Sep 07 2015 23:45
that's interesting, what's your munge device?
I'm guessing munge is mmhistorytools
Oskar Pearson
@oskarpearson
Sep 07 2015 23:45
[device "munge"]
vendor = openapscontrib.mmhistorytools

[device "glucose"]
vendor = openapscontrib.glucosetools
Nathan Racklyeft
@loudnate
Sep 07 2015 23:45
you want to run glucosetools
right,
they both have clean commands
Oskar Pearson
@oskarpearson
Sep 07 2015 23:46
so device of clean_glucose should be, unsurprisingly... clean instead of munge?
Nathan Racklyeft
@loudnate
Sep 07 2015 23:46
glucose instead of munge
Oskar Pearson
@oskarpearson
Sep 07 2015 23:46
got it
Thanks!
Nathan Racklyeft
@loudnate
Sep 07 2015 23:46
openaps use munge clean -h should give you an overview of what it does and what its args are
same for openaps use glucose clean -h
Oskar Pearson
@oskarpearson
Sep 07 2015 23:51
Great - thanks as always for the help. I don't have a weird bounce on the current graph, so I'd have to see if it happens again :)
Nathan Racklyeft
@loudnate
Sep 07 2015 23:53
it'll also protect you from graphing 0's, which end up as glucose records during certain events,
unfortunately there's a lag when the page is full,
and you may have also noticed you only have even-numbered values :)
bg values are stored as 1 byte, shifted right
(no cleaning can bring back the 1 mg/dL resolution)
Oskar Pearson
@oskarpearson
Sep 07 2015 23:58
I hadn't noticed that, actually. But as I'm in the UK, we use mmol/L. So I've patched openaps-monitor to display mmol/L (not quite ready for a pull request). So my numbers are something like 7.2 or 6.6 or similar.