Skip to content

Conversation

@philipgo
Copy link
Contributor

@philipgo philipgo commented Jul 17, 2018

This change lets Autotune recognize Nightscout AndroidAPS Temp Basal records. It also addresses the way AndroidAPS cancels Temp Basals (by creating a record without duration and rate).

I have tested the changes with OpenAPS data (no change) and AndroidAPS data.

It does not address the following issues:

  • Some pumps used with AndroidAPS create Temp Basal entries on a percentage basis instead of absolute values
  • Autotune does not use AndroidAPS profile switches but makes its recommendations based on the profile used by OpenAPS

AndroidAPS Temp Basal entry (with Combo pump)

{ 
    "_id" : ObjectId("123456"), 
    "eventType" : "Temp Basal", 
    "duration" : NumberInt(15), 
    "absolute" : 0.48400000000000004, 
    "created_at" : "2018-01-20T02:33:56Z", 
    "enteredBy" : "openaps://AndroidAPS", 
    "NSCLIENT_ID" : 12345678.0
}

AndroidAPS Cancel TBR record

{ 
    "_id" : ObjectId("123457"), 
    "eventType" : "Temp Basal", 
    "created_at" : "2018-06-04T04:03:18Z", 
    "enteredBy" : "openaps://AndroidAPS", 
    "NSCLIENT_ID" : 12345678.0
}

- Recognize AndroidAPS Temp Basal records
- Delete AndroidAPS "Cancel Temp Basal" records
for (var i=0; i+1 < tempHistory.length; i++) {
if (tempHistory[i].date + tempHistory[i].duration*60*1000 > tempHistory[i+1].date) {
tempHistory[i].duration = (tempHistory[i+1].date - tempHistory[i].date)/60/1000;
// Delete AndroidAPS "Cancel TBR records" in which duration is not populated
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure I follow the comment / logic here. can you explain how this part works?

Copy link
Contributor Author

@philipgo philipgo Jul 17, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AndroidAPS cancels TBRs in Nightscout by creating a subsequent TBR entry in which rate and duration fields do not exist. My idea of the logic here was to use the AndroidAPS "Cancel TBR" records to adjust the duration of the previously running TBR. Afterwards these "Cancel TBR" records are not needed anymore and can be deleted. However, not deleting them does not seem to affect Autotune results, it only causes a lot of empty array elements when running Autotune on AAPS data.

@scottleibrand
Copy link
Contributor

Anyone want to test this further before I merge it to dev?

@scottleibrand scottleibrand changed the base branch from dev to 0.7.0-dev July 18, 2018 04:02
@scottleibrand
Copy link
Contributor

Merging to 0.7.0-dev.

@scottleibrand scottleibrand merged commit cb754de into openaps:0.7.0-dev Jul 18, 2018
@jotomo
Copy link

jotomo commented Jul 25, 2018

@philipgo

Some pumps used with AndroidAPS create Temp Basal entries on a percentage basis instead of absolute values

So, in order to work with those, AndroidAPS would need to upload the absolute rate, yes?
Your Combo output already contains an absolute field - is that a local patch?

@jotomo
Copy link

jotomo commented Jul 25, 2018

My bad, I overlooked the option to upload the absolute rate, sorry for the noise.

@philipgo
Copy link
Contributor Author

@jotomo Can you confirm that an absolute rate is uploaded for all pumps as long as the option is selected? Would there be any disadvantage to simply always uploading an absolute rate?

@jotomo
Copy link

jotomo commented Jul 27, 2018

@philipgo Yes, the option is pump-agnostic (code: https://github.com/MilosKozak/AndroidAPS/blob/dev/app/src/main/java/info/nightscout/utils/NSUpload.java#L79).
The disadvantage is that temp basals are displayed as absolute in NS, which not everybody might like given their pump and AAPS still shows percent.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants