Skip to content

Loop and Medtrum Pump Manager: Basal Delivery Accounting is Not Correct #77

Description

@marionbarker

Issue Summary

  • Loop expects events that are not finalized to have isMutable true.
  • Loop expects to have deliveredUnits provided for each finalized event, it should be nil when event is not finalized; although units (TBR U/hr or requested bolus) should be provided.
  • The MedtrumKit pump manager is not finalizing temp basal event and is not providing the deliveredUnits for each finalized temp basal event.

Overview

Examine cycle by cycle a few events looking at Pump Event Details and Apple Health. The issues are most obvious when running with Dosing Strategy using Temp Basal Mode only.

Summarize problems:

  • Each successive temp basal event overwrites the previous one when looking at Loop Pump Event history
  • Apple Health history appears to be reporting each temp basal as if it were the indicated duration but at the scheduled basal rate
  • Examine automatic, isMutable and deliveredUnits for the MedtrumKit pump manager when a Temp Basal Rate is in-progress
    • automatic is reported as nil when it should be true
    • isMutable: true is correct, but because each successive TBR overwrites the previous one in event history, we never see the finalized TBR result
    • deliveredUnits should be nil (and it is) until the event is finalized but we don't see the finalized event
  • Examine automatic, isMutable and deliveredUnits for the MedtrumKit pump manager for bolus events
    • automatic value is correct
    • isMutable value is correct
    • deliveredUnits should be nil until the event is finalized, but they are correct

Main Loop Screen

Only the currently running TBR appears on the Loop plot. All previous TBR records are overwritten by current one.

Image

Test Details

Delete Loop from phone to begin with a clean slate.

Configuration

  • SE 3rd gen phone running iOS 26.3
  • LoopWorkspace URL: https://github.com/marionbarker/LoopWorkspace
  • branch: feat/add_all_managers (includes 2 private repo: OmnipodKit and TandemKit)
  • MedtrumKit commit: f21d808
    • Realized part way through the test, there is a newer version in MedtrumKit, but it does not make a difference, same issues
  • modifications: add pretty-print pump events PR for Loop (PR 2403) and LoopKit (PR 586)
  • leave Apple Health alone (so loop will read in that information) but will start fresh for pump data
  • use default Loop settings, Scheduled Basal 1.2 U/hr, target 105-110, 15 g/U, 50 mg/dL/U

Narrative - examine Pump Event in real time

Dosing Strategy: Temp Basal Only

Date: 2026-02-12, PST (UTC -8)

  • add Nightscout as a Service
  • add CGM SImulator, sine wave 110 +/- 20 and upload to Nightscout
  • Add Medtrum:
    • attach pump base
    • start priming
    • activate
Time Action Comment
15:24 Patch is activated takes you to Nano screen on loop
15:24 Reservoir Level is 157 U Scheduled Basal is 1.2 U/hr
15:28 Loop is open Loop is green
15:28 20 g carbs indicated from Apple Health
15:35 Loop is closed
Dosing Strategy: Temp Basal Only
-
15:37 Pump Event, TBR 0.45 U/hr ❌ automatic: nil, should be true;
✅ isMutable: true;
✅ deliveredUnits: nil
15:42 Pump Event, TBR 0.5 U/hr ❌ the previous 0.45 U/hr event has disappeared
❌ automatic: nil, should be true;
✅ isMutable: true;
✅ deliveredUnits: nil
15:47 - with no change to TBR, no new event expected
15:52 Pump Event, TBR 0.6 U/hr ❌ all previous TBR events disappeared
❌ automatic: nil, should be true;
✅ isMutable: true;
✅ deliveredUnits: nil
15:57 Pump Event, TBR 0.45 U/hr ❌ all previous TBR events disappeared
❌ automatic: nil, should be true;
✅ isMutable: true;
✅ deliveredUnits: nil
16:12 Pump Event, TBR 0.75 U/hr ❌ all previous TBR events disappeared
❌ automatic: nil, should be true;
✅ isMutable: true;
✅ deliveredUnits: nil

That's enough for the Temp Basal Test.

  • share the text file and prepend the date time stamp to each filename - uploaded at end of this comment

I got part-way through this test and realized I do not have the latest commit for MedtrumKit.

Start over at 16:20 using Medtrum commit: 27b9b68

Restart Test

Do not bother starting with a fresh build on the phone, just build newest commit onto existing app.

First loop after building with latest MedtrumKit commit.
Leave Loop set to Temp Basal Only, Closed Loop enabled

Time Action Comment
16:23 build fresh yellow loop
16:28 TBR 0.8 U/hr same issue - new TBR overwrites previous Pump Event

Nightscout

Nightscout plots look fine because they go by the uploaded temp basal values.

Image

Apple Health

❌ Apple Health appears to be reporting a value equal to the scheduled basal rate for each duration. Not what is expected from the TBR values

(1.2 U/hr is 0.1 for 5 minutes, 0.2 for 10 minutes and 0.3 for 15 minutes).

Start Time EndTime Duration Rate product Apple Health
15:37 15:42 5 0.45 0.038 0.1
15:42 15:52 10 0.50 0.083 0.2
15:52 15:57 5 0.60 0.05 0.1
15:57 16:12 15 0.45 0.112 0.3
16:12 16:17 5 0.75 0.062 0.1
Image

Switch to Automatic Bolus

✅ All bolus pump events are correct with the exception that deliveredUnits should be nil when isMutable is true.

Time Action Comment
16:36 enable Automatic Bolus -
16:38 Scheduled basal restored
16:42 add carbs with 0 bolus -
16:44 in process bolus 1.2 U share pump event: 20260212_1643_Bolus_Pump Event.txt
deliveredUnits should be nil while isMutable: true
16:44 after bolus completed (1.2 U) share pump event 20260212_1643_Bolus_Pump Event 2.txt
16:48 after bolus completed (0.7 U) share pump event 20260212_1648_Bolus_Pump Event.txt

Pump Event text files

These Pump Event details text files were shared from the Loop phone. All Temp Basal files were in progress. The Bolus files are noted as in-progress or completed.

PumpEvent-txt-files.zip

Share one of these as a screenshot.

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions