Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Manually stopping insulin shows as regular basal rate in nightscout #17

Closed
vonstein2002 opened this issue Oct 27, 2021 · 5 comments
Closed
Labels
bug Something isn't working

Comments

@vonstein2002
Copy link

vonstein2002 commented Oct 27, 2021

Highlighted area on tconnect shows 0u/hr. in Nightscout it shows regular basal rate. tconnectsync version 0.4.1

tconnect

nightscout

@JMPZ11
Copy link

JMPZ11 commented Oct 27, 2021

Does it show correctly in t:connect?

If you power off the pump, t:connect does something similar, assuming it delivered insulin at the basal rate till you power it back on...

@vonstein2002
Copy link
Author

vonstein2002 commented Oct 27, 2021

Yes, tconnect shows it correctly. There are no treatments entered in to nightscout for the manual stop or the manual restart but all treatments either side of the stop show up in nightscout.

@JMPZ11
Copy link

JMPZ11 commented Oct 27, 2021 via email

@jwoglom
Copy link
Owner

jwoglom commented Oct 28, 2021

Thanks for noticing and reporting this -- this is a perfect example of the sort of edge case that's easy to miss without either a lot of real-world use or very good test cases.

I've been looking into the data that tconnect returns from its API to pinpoint exactly how to detect when this situation occurs. Given the following data:

image

I was able to validate that the "0 u/hr Basal" basal events are properly being processed, as they show up in api.controliq.therapy_timeline with a 0.0 basal. There is also an associated suspensionDeliveryEvent with the same timestamp:

{
  'basal': {
    'algorithmDeliveryEvents': [
      ...
      {'y': 0.0, 'duration': 897, 'x': 1635195156}, # 1:52 PM
      ...
    ]
  },
  'suspensionDeliveryEvents': [
    ...
    {'continuation': None, 'suspendReason': 'control-iq', 'x': 1635195156}, # 1:52 PM
    ...
  ]
}

But, like you mentioned, "Manual/Alarm" basal events are not currently working.
I discovered this is because a suspensionDeliveryEvent exists for it, but there is no associated delivery happening at that time:

{
  'suspensionDeliveryEvents': [
    {'continuation': None, 'suspendReason': 'manual', 'x': 1635188855} # 12:07 PM
  ]
}

I've added some code to catch this case and add a manual basal event for 0u/hr at the time of the manual suspension, with a duration lasting until the next basal event detected by the pump.
The event should appear in the nightscout API (at /api/v1/treatments) with reason "manual suspension".

@jwoglom jwoglom added the bug Something isn't working label Oct 28, 2021
@vonstein2002
Copy link
Author

Thanks for your work on this project! Allows me to use openaps autotune again :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants