fix: clamp over-limit temp basal instead of rejecting with invalidSetting#84
Draft
Sjoerd-Bo3 wants to merge 1 commit into
Draft
Conversation
…ting enactTempBasal rejected any rate above state.maxBasalRateUnitsPerHour with .configuration(invalidSetting), aborting the whole loop cycle before the SMB could be enacted — so a single above-limit request stopped all automated delivery. Clamp to the configured limit instead, so basal is delivered at the cap and the loop proceeds to the SMB. Also add the logging that was missing for diagnosis: - log when a temp basal is clamped (requested rate vs stored limit) - log the value written by syncDeliveryLimits The underlying trigger is a settings mismatch (Trio Max Basal Rate delivery limit below oref's profile-derived maxSafeBasal); these changes make it non-fatal and diagnosable rather than fixing the mismatch itself. Refs loopandlearn#83
6f9cf59 to
3ffd409
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refs #83
Context (root cause is upstream of this change)
Field reports trace every
configuration(OmniPumpManagerError.invalidSetting)loop failure to one guard inenactTempBasal:Analysis of two users' logs:
state.maxBasalRateUnitsPerHourwas a stable 2.0 U/hr, while oref's profile-derivedmaxSafeBasalwas 3.0 (= 3× scheduled basal), so every request of 2.05–3.0 U/hr was rejected. The rejection aborts the whole loop cycle before the SMB, so a single above-limit request stops all automated delivery (one user: ~6.5h overnight, no insulin). On a fresh OmnipodKit PM the limit starts at thePod.maximumBasalUnitsPerHour = 30default (high rates succeed) until the firstsyncDeliveryLimitswrites the user's lower Trio Max Basal Rate — after which it's enforced.The real cause is a Trio-side settings mismatch (the Max Basal Rate delivery limit synced to the pump is below oref's
maxSafeBasal), which was harmless under OmniBLE/OmniKit because neither enforced the limit inenactTempBasal. That belongs on the Trio side (bind/validate the two, and re-sync) — see nightscout/Trio#1216. This PR only makes the driver non-fatal and diagnosable.Changes
min(unitsPerHour, state.maxBasalRateUnitsPerHour)→ basal is delivered at the configured cap and the loop proceeds to the SMB, instead of aborting.syncDeliveryLimits— the value written (and the reject path). This was the missing trace: the limit is enforced but was never logged, so there was no record of when/what set it.Open question for maintainers
If the guard is intended as a hard safety limit, the alternative is to keep it but (a) not let it abort the loop / block the SMB, and (b) fix the Trio-side mismatch so oref never requests above the synced limit. Happy to adjust to whichever direction the driver/Trio teams prefer.
Testing
syncDeliveryLimitslogs the written limit