Skip to content

Conversation

@nl-ruud
Copy link

@nl-ruud nl-ruud commented Jan 3, 2026

Basal Drift Detection for Omnipod Dash

Issue

The insulin delivered by the Omnipod Dash drifts from the programmed basal rate (related to #4158). This PR adds tracking to quantify the drift for future correction (will be a separate PR).

⚠️ First PR for AndroidAPS and GitHub.

Description

Add basal drift tracking to the Omnipod Dash driver.

Changes

  • Separate basal and bolus delivery
    • Track bolus pulses separately
    • Calculate basal pulses: total pulses − bolus pulses
  • Expected basal delivery calculation
    • Integrates expected delivery over time
    • Accounts for hourly basal rate changes and temporary basals
  • Drift computation
    • basalDrift = actual − expected
    • Logged on each status update (DefaultStatusResponse and AlarmStatusResponse)

Example log

PUMP_BASAL act=8,10U (tot=33,25U bol=25,15U) exp=9,42U err=-1,32U dErr=-0,02U

Log fields:

Field Description
act Actual basal units delivered (totbol)
tot Total units delivered
bol Bolus units delivered
exp Expected basal units delivered
err Error / cumulative basal drift (act - exp)
dErr Delta of err on this pump status response

New State Fields

  • bolusPulsesDelivered: cumulative bolus pulses
  • basalExpected: running total of expected basal delivery

New Computed Properties

  • basalPulsesDelivered = total pulses − bolus pulses
  • basalDelivered = basal pulses delivered converted to insulin units
  • basalDrift = actual − expected insulin units (positive = over-delivery, negative = under-delivery)

Tests

  • Confirmed basalDrift matches manual calculations
  • Confirmed calculation on a temp basal change
  • Confirmed calculation on a basal program change
  • Validated calculations with Nightscout 'day to day' report: bolus insuline equals ΔbolusPulsesDelivered * 0.05, basal insuline is exactly ΔbasalDrift off from ΔbasalDelivered. Same difference between TDD and ΔtotalPulsesDelivered. QED.

@nl-ruud nl-ruud marked this pull request as draft January 3, 2026 23:10
@nl-ruud
Copy link
Author

nl-ruud commented Jan 7, 2026

There was quite some code duplication between updateFromDefaultStatusResponse and updateFromAlarmStatusResponse that would become even more extensive. I moved the common denominator to a new private method updatePodState.

@nl-ruud nl-ruud marked this pull request as ready for review January 7, 2026 20:26
@nl-ruud nl-ruud changed the title Drift detection for Omnipod Dash Omnipod Dash Drift detection Jan 8, 2026
@sonarqubecloud
Copy link

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.

2 participants