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

8th
Nov 2015
Jason Calabrese
@jasoncalabrese
Nov 08 2015 02:23
anyone know how to get an empty object if you an empty array? for example echo '[]' | json 0 prints nothing, I want {}, so it would treated like [{}]
maybe some option to the json tool?
Jason Calabrese
@jasoncalabrese
Nov 08 2015 02:30
or maybe some other way to avoid ValueError: No JSON object could be decoded when trying to invoke a json report that returns an empty result
Scott Leibrand
@scottleibrand
Nov 08 2015 02:50
Which one commonly does that? I think we ran into that and fixed it by telling it to expect text instead of json.
Jason Calabrese
@jasoncalabrese
Nov 08 2015 02:52
the latest treatments from NS
right now for my testing the site I pull from has it's db wiped out every 5 mins
with a copy from my production
let me see is text works
yeah, that works, then just need to test it
Jason Calabrese
@jasoncalabrese
Nov 08 2015 02:59
need to figure out a better test environment, maybe need 1 more site
yeah this isn't going to work, both crons running every five mins...
Jason Calabrese
@jasoncalabrese
Nov 08 2015 09:00
really close to having it all work, missing something about creating the treatments to upload
@bewest are you around?
Jason Calabrese
@jasoncalabrese
Nov 08 2015 09:15
think that's fixed, now it's just not uploading since there isn't a recommendation to enact or upload
should have taken him out for pizza so this would be easier to test
Jason Calabrese
@jasoncalabrese
Nov 08 2015 09:53
wasn't finding the treatment to upload since time on the pump was wrong
maybe will pick it up next cycle?
Jason Calabrese
@jasoncalabrese
Nov 08 2015 10:06
nope, something with timezones
Tim Howard
@tghoward
Nov 08 2015 14:04
My problem ( :point_up: November 7, 2015 5:40 PM ) was that I had not enabled careportal on the server (!!). A good 'gotcha' for brand new nightscout setups. Glad I'm over that hump. ["Cannot POST" adding here to help future searches]
Jason Calabrese
@jasoncalabrese
Nov 08 2015 16:25
Shouldn't need to enable careportal to post, but if careportal is enabled auth for treatments gets turned off
So your api secret used on the pi must not be right
Jason Calabrese
@jasoncalabrese
Nov 08 2015 18:30
my loop is trying to upload now, but getting an error, think my ns-upload.ini isn't right or I'm not calling it right
$ cat ns-upload.ini
[device "ns-upload"]
fields = type report
cmd = ns-upload
args = http://ns-dev1.cbrese.com abc123acb123 treatments.json 01.monitor/upload-treatments.json
nevermind, just had to talk out loud
Screen Shot 2015-11-08 at 10.34.15 AM.png
Jason Calabrese
@jasoncalabrese
Nov 08 2015 18:45
now to figure out my it's saying max_iob: 0
Peter Miller
@ochenmiller
Nov 08 2015 18:48
@jasoncalabrese not near my openaps imp but, I think determine basal can take an argument of max_basal.json . that includes a json record like: {
"max_iob": <yourvaluehere>
}
sorry, max_iob.json
Jason Calabrese
@jasoncalabrese
Nov 08 2015 18:51
yeah, seems like some new fields have been added since I set it up before
carb-ratios.json is getting passed as max_iob.json
Peter Miller
@ochenmiller
Nov 08 2015 18:52
I'm still using the old old codebase
circa Sept
Jason Calabrese
@jasoncalabrese
Nov 08 2015 18:56
I was passing carb ratios, but it wasn't needed
now to see what needs to be fixed next
Scott Leibrand
@scottleibrand
Nov 08 2015 19:02
Yeah, I did a poor job of making that carb removal stuff backwards compatible, sorry.
Glad you're making good progress though! :-)
Jason Calabrese
@jasoncalabrese
Nov 08 2015 19:03
think it's mostly functional, just need to figure out how I'm going to test it
think I'll do some double entry and start adding boluses on the 522
to get them to match up
Scott Leibrand
@scottleibrand
Nov 08 2015 19:06
That works pretty well. Even without boluses, if you let it run on a test pump it should converge pump IOB with ideal using temps.
Jason Calabrese
@jasoncalabrese
Nov 08 2015 19:09
Screen Shot 2015-11-08 at 11.08.47 AM.png
that was last night at about 3am
you don't see my carb correction there since it's using a different treatment collection
maybe I would have been able to keep working instead of to go upstairs to give some juice if it was plugged in
Scott Leibrand
@scottleibrand
Nov 08 2015 19:13
Not sure the timescale, but if the drop was slow enough, yeah.
Jason Calabrese
@jasoncalabrese
Nov 08 2015 19:14
hasn't high temped yet, since I just fixed the max iob
eyim
@eyim
Nov 08 2015 19:18
okay looks like i got the loop to run manually. now I need to set up the crontab job. I've figured out crontab and how to call a file to run every 5 min but need some help on what the file should say. My openaps alias to run the loop is called "everything" so is it just a file that reads "openaps everything"? I assume somehow I need to make this a bash command?
Scott Leibrand
@scottleibrand
Nov 08 2015 19:20
Whatever you type on
Silly gitter mobile app.
Whatevet you type on the command line to run that everything alias is what will go into cron.
Plus some PATH and schedule stuff, and some environment variables once you get to the point of uploading to NS.
Is the manual run setting the temps you'd expect?
Dana Lewis
@danamlewis
Nov 08 2015 19:22
(Congrats on awesome progress @eyim !)
Scott Leibrand
@scottleibrand
Nov 08 2015 19:22
:+1:
One of the fastest we've seen so far. :-)
Dana Lewis
@danamlewis
Nov 08 2015 19:26
Will love to hear your take on the time for different phases, vs my guesses!
eyim
@eyim
Nov 08 2015 19:26
Thank you - worked hard on it last night. Your get together on Friday night really was an ahh ha moment for me. It is returning what I would expect but that isn't saying much. My son is away so I only have old bg data from a spare dexcom receiver and as expected it says the data is too old to make a recommendation. He gets home tonight so can test on more live data then. I see some people download bg data from nightscout which he has going right now but I am not sure how to make that work either.
Jason Calabrese
@jasoncalabrese
Nov 08 2015 19:27
thats the way I have it setup
planning for my first real setup to only work with network
I have a little curl script that pulls in bg from NS
eyim
@eyim
Nov 08 2015 19:28

At first I wasn't sure why you were doing that but now I understand why. One less device hooked up to the pi

i saw that you were doing that and I know you sent me the script but wan't sure how to make it work. I'll try again now that I have more knowledge

Jason Calabrese
@jasoncalabrese
Nov 08 2015 19:29
stuck it in a device, but would be good to do something cleaner
[device "nssgv"]
fields = 
cmd = bash
vendor = openaps.vendors.process
args = -c "bgnow.sh"
$ cat ~/bin/bgnow.sh
#!/bin/bash

curl -s https://YOURSITE/api/v1/entries/sgv.json | json -e 'this.glucose = this.sgv'
eyim
@eyim
Nov 08 2015 19:30
ahhh
Jason Calabrese
@jasoncalabrese
Nov 08 2015 19:31
the have a report
[report "01.monitor/glucose.json"]
device = nssgv
use = shell
reporter = text
eyim
@eyim
Nov 08 2015 19:31
@danamlewis Dana - I probably spent 4 or 5 hours yesterday working on it and a couple of hours on Friday night. But most of that time was just trying to understand the parts and then how they fit together. Once the lightbulbs starting going off, it was pretty quick.
Scott Leibrand
@scottleibrand
Nov 08 2015 19:39
There is an oref0 script for getting data from NS I believe.
Rachel Sandlain
@audiefile
Nov 08 2015 19:39
Is there one for pushing pump history (boluses, carbs not temp basals)?
Jason Calabrese
@jasoncalabrese
Nov 08 2015 19:41
yeah, need to replace what I have with ns-get
Scott Leibrand
@scottleibrand
Nov 08 2015 19:41
nm, I have ns-glucose set up as a one-liner: openaps device add ns-glucose process 'bash -c "curl -s $NIGHTSCOUT_HOST/api/v1/entries/sgv.json | json -e \"this.glucose = this.sgv\""'
Maybe ns-get came about after I did that.
Jason Calabrese
@jasoncalabrese
Nov 08 2015 19:41
yeah, think it's new
then you can have the host and secret in an ini
I have that setup to post, but not to get yet
Scott Leibrand
@scottleibrand
Nov 08 2015 19:42
I much prefer having them in env vars
eyim
@eyim
Nov 08 2015 19:50

I tried it Jason's way and got an error that says can't find bgnow.sh To show you how dumb I am- I created a folder called bin in my openaps folder and then created the bgnow.sh file with the script and put it in there. Obviously not correct.

I am trying to do the oref0 script now but what do I need to change in the report for monitor/glucose.json to call the oref0 script?

Ben West
@bewest
Nov 08 2015 19:51
use ns-get
Jason Calabrese
@jasoncalabrese
Nov 08 2015 19:53
seems that new temps aren't uploaded till the next loop
they need to get read from the pump before they are sent
and still have a timezone issue
Scott Leibrand
@scottleibrand
Nov 08 2015 19:54
My loop does read-pump, upload, wait for next BG data point, suggest, enact.
Jason Calabrese
@jasoncalabrese
Nov 08 2015 19:55
but after enact, would be nice to upload what was enacted
Ben West
@bewest
Nov 08 2015 19:55
ns-get entries.json $NIGHTSCOUT_HOST $API_SECRET, you can put secret in env variable or in the extra ini
Scott Leibrand
@scottleibrand
Nov 08 2015 19:55
With each loop iteration starting <1m after the last finishes, do upload comes right after enact, and then it waits the rest of the 5m
Jason Calabrese
@jasoncalabrese
Nov 08 2015 19:57
maybe we add a wait option to ns-get?
what are you doing to have it wait
Ben West
@bewest
Nov 08 2015 19:57
ns-get supports using it a bunch of different ways
Scott Leibrand
@scottleibrand
Nov 08 2015 19:57
Mine is a copy glucose.json last-glucose.json, then until diff, do ns-get.
(Conceptually)
Ben West
@bewest
Nov 08 2015 19:58
ns-get doesn't need api-secret, sorry
Scott Leibrand
@scottleibrand
Nov 08 2015 19:58
openaps alias add wait-for-bg '! bash -c "cp monitor/glucose.json monitor/last-glucose.json; while(diff -q monitor/last-glucose.json monitor/glucose.json); do echo -n .; openaps get-bg >/dev/null; sleep 10; done"'
And if preflight fails, I skip the waiting and go straight through the loop.
I also have a killall -g --older-than 10m openaps in cron in case anything gets stuck.
Cron runs loop minutely if not running: ps aux | grep -v grep | grep -q 'openaps retry-loop' && echo OpenAPS already running || openaps retry-loop
Jason Calabrese
@jasoncalabrese
Nov 08 2015 20:04
retry-loop is your main alias?
Scott Leibrand
@scottleibrand
Nov 08 2015 20:05
Ya
One other important thing: make sure your data-gathering alias deletes old data before running, so you can't end up acting on stale data.
openaps alias add gather '! bash -c "rm monitor/*; ( openaps get-bg && openaps get-settings >/dev/null && openaps monitor-pump ) 2>/dev/null"'
that assumes you put all your frequently-refreshed data in monitor/
Jason Calabrese
@jasoncalabrese
Nov 08 2015 20:10
didn't know deletes were still a best practice, but makes sense
Ben West
@bewest
Nov 08 2015 20:10
or having checks to move to next phase or not
Jason Calabrese
@jasoncalabrese
Nov 08 2015 20:11
maybe a verify phase
Scott Leibrand
@scottleibrand
Nov 08 2015 20:11
Checks are easier to mess up.
I've had all my checks fail and acted on old data in unexpected situations. With delete, and bailing on missing inputs, you can't make that mistake.
Jason Calabrese
@jasoncalabrese
Nov 08 2015 20:16
should the pi be in local time? utc?
mine is in utc, and uploads are way off time wise
Ben West
@bewest
Nov 08 2015 20:16
local
pi is like your cell phone
Jason Calabrese
@jasoncalabrese
Nov 08 2015 20:17
tried setting it to local time last night, then started getting tons of stick errors
by editing /etc/timezone?
Scott Leibrand
@scottleibrand
Nov 08 2015 20:24
Use raspi-config to set timezone.
We may need to make that part of the instructions more prominent.
Jason Calabrese
@jasoncalabrese
Nov 08 2015 20:25
yeah, never looked at that tool
but haven't seen any recent instructions
probably making things way to hard on myself
Rachel Sandlain
@audiefile
Nov 08 2015 20:26
as much as it sucks, reading the manual can solve all kinds of problems :wink:
Jason Calabrese
@jasoncalabrese
Nov 08 2015 20:27
hard for me to read anything more than a paragraph or 2 without getting distracted and doing something else
Rachel Sandlain
@audiefile
Nov 08 2015 20:27
I speak from experience
Scott Leibrand
@scottleibrand
Nov 08 2015 20:30
(and keep updating it each time I do)
Jason Calabrese
@jasoncalabrese
Nov 08 2015 20:31
after changing the time zone I get the stick errors again
Nov 8 12:30:25 raspberrypi Stick transmit[TransmitPacket:ReadPumpModel:data:unknown] reader[ReadRadio:size:14] download_i[5] status[<LinkStatus:0x03:status:size=??LinkStatus:error:True:reason:[]:size(0)>] poll_size[0] poll_i[False] command[<LinkStatus:0x03:status:size=??LinkStatus:error:True:reason:[]:size(0)>]:download(attempts[5],expect[0],results[0]:data[0]):BAD AILING
rebooted unpluged stick, et
Scott Leibrand
@scottleibrand
Nov 08 2015 20:33
You need to delete your expires in your pump.ini
it's 7 hours in the future.
So it won't try to init until then.
Scary how well we know so many of these failure modes. :-)
Jason Calabrese
@jasoncalabrese
Nov 08 2015 20:35
that makes sense, was wondering how timezone would effect the stick
Screen Shot 2015-11-08 at 12.36.35 PM.png
nice
Jason Calabrese
@jasoncalabrese
Nov 08 2015 22:03
Really like watching OpenAPS in NS, think we need to expose some more info
Think we can start with an OpenAPS plugin for NS, could put almost anything in the tooltip
Scott Leibrand
@scottleibrand
Nov 08 2015 22:04
I'd like to start with getting IOB correct
Jason Calabrese
@jasoncalabrese
Nov 08 2015 22:05
Need time ago/battery too
Scott Leibrand
@scottleibrand
Nov 08 2015 22:05
yeah, with green/yellow/red color coding like we have for BG time ago
Jason Calabrese
@jasoncalabrese
Nov 08 2015 23:04
Not sure if you noticed, but in dev the basal pull now shows the current temp with a T: prefix and has duration, time left, etc
If like to see the predict message as a tooltip
There's some overlap with the pump status info that @mddub added for connect
Scott Leibrand
@scottleibrand
Nov 08 2015 23:07
cool
Jason Calabrese
@jasoncalabrese
Nov 08 2015 23:10
Think I need to have oref0 consider NS careportal boluses
Write that dedupe
With that it would be much easier to test, and also for the pump swaping
Scott Leibrand
@scottleibrand
Nov 08 2015 23:12
hmm, that is some interesting dependency injection
I guess if you only honor boluses, that will just cause bolus snooze to do nothing at first, then potentially low-temp as they decay
Jason Calabrese
@jasoncalabrese
Nov 08 2015 23:13
Worst case it would high temp less, or low temp
Scott Leibrand
@scottleibrand
Nov 08 2015 23:13
yeah
Jason Calabrese
@jasoncalabrese
Nov 08 2015 23:14
Will also let me mix NS sites
Pull from production push to test
Store the source treatment id then deduping will be easy