Skip to content

Conversation

@bjorkert
Copy link
Contributor

@bjorkert bjorkert commented Oct 4, 2025

Trio Remote Control: Recommended Bolus on Bolus Screen

This PR adds a flow for using the Recommended Bolus in the Trio Remote Control bolus view.

What’s included

  • Shows a Recommended Bolus chip when a fresh recommendation is available.
  • Hides the chip if the value is negative/zero/tiny (<0.05U) or older than ~12 minutes.
  • Color cue for freshness:
    • Yellow when recently calculated.
    • Red warning if ~5–12 minutes old.
  • Tapping the chip:
    • Applies directly when fresh.
    • Prompts a caution dialog if older than ~5 minutes.

Why

Make it quick to use a safe, recent recommendation—and avoid nudging users toward stale or invalid values.

@bjorkert
Copy link
Contributor Author

bjorkert commented Oct 4, 2025

image

@State private var statusMessage: String? = nil

private let pushNotificationManager = PushNotificationManager()
private let minDeliverableU: Double = 0.05 // hides negative/zero/tiny recs
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could be renamed to minDeliverableUnit for improved readability

@dnzxy
Copy link
Collaborator

dnzxy commented Oct 4, 2025

It does not really make sense to display a bolus value that the pump cannot administer (0.96 U in your example for what I presume is a pod user on Trio). The overall bolus seems to have 3 decimals; bolus dosages are usually rounded up to 2 decimals in allowed increments.

Where is this recommended value coming from on the Trio side?

@bjorkert
Copy link
Contributor Author

bjorkert commented Oct 4, 2025

LoopFollow currently does not know what pump is used, and therefore not what increments used. I plan to introduce a setting for it. I believe it can be fetched from Loop.

@bjorkert bjorkert marked this pull request as draft October 6, 2025 16:14
@bjorkert bjorkert marked this pull request as ready for review October 31, 2025 12:48
@salguccio
Copy link

I wanted to thank you for making this extension available to all of us. I assure you, many parents use it. I hope it'll be added to the official versions of Trio and LoopFollow so that when an update is released by the developers, it can be downloaded without having to wait for "bjorkert" to make the appropriate changes.
THANK YOU...!!! THANK YOU FOR MAKING ALL PARENTS AVAILABLE TO HAVE THE BOLO TIP DIRECTLY IN THE FOLLOW APP... YOU'RE GREAT...!!! THANK YOU...

@marionbarker
Copy link
Collaborator

Test

This test was not successful.

  • When bolus increment of 0.1 U is set, a requested bolus that included a 0.05 U increment was accepted
  • LoopFollow displayed it rounded down but sent it to Trio as rounded up

Configuration

Trio phone is an SE 2nd gen phone running iOS 18.7.2

  • Trio version is 0.6.0.16, commit 3080f0429
  • Medtronic 523 pump is connected to the Trio phone
  • Feature, Remote Control is enabled

LoopFollow phone is an iPhone 15 running iOS 18.7.2

  • branch recommended-bolus-trio, commit 5444599
  • configured LF for Trio Remote Control
  • new line in the Debug/Info section
    • Bolus Increment 0.100 U

Remote Bolus

The bolus increment is not being honored

  • A bolus of 0.05 U was accepted when entered in the LoopFollow remote control bolus field
  • LF asked confirm bolus of 0.0 U - I confirmed
  • The Trio phone, accepted a bolus of 0.1 U

Repeat the test with same result

Try a larger bolus so I have time to watch it be delivered on Trio and on pump itself

  • A bolus of 0.85 U was accepted
  • LF asked to confirm bolus of 0.8 U - I confirmed
  • The Trio phone, accepted a bolus of 0.9 U
  • A bolus of 0.725 was accepted - in this case LF rounded down and Trio bolused the rounded down amount of 0.7 U

Recommended Bolus

  • Delete the history of the 4 remote boluses from Trio phone so a bolus will be recommended
  • Wait for next cycle, started temp basal of 2.4 U/hr and started a bolus - canceled it part way / resumed delivery
    • (With a Medtronic pump, canceling delivery means pump gets suspended and must manually resume)
  • Rec bolus is now 2.8 U
  • Tap on remote bolus and 2.8 U is recommended - but there is an old calculation warning, send it anyway
    • automatically reduced to 1 U because that's the max configured for this LF phone
    • cancel bolus on Trio phone once it started
  • Modify LF configuration to enable a 5 U bolus to be sent
  • Rec Bolus is 2.05
    • tap on remote bolus, suggests 2.0 U but says it was calculated 10 minutes ago - but I checked and the 2.05 U agrees with what the Trio phone is recommending.
    • The Trio phone (and the pump) showed a 2.0 U bolus starting - cancel it once it started
  • Come back later and now the rec bolus does say calculated 1 min ago, so maybe it is updating properly:
    • 2.2 U rec at LF screen
    • 2.25 U rec on the Trio screen

guard stepU > 0 else { return value }

let stepped = (value / stepU).rounded(.up) * stepU
let stepped = (value / stepU).rounded(.down) * stepU
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested formula:

let stepped = (0.5 + value / stepU).rounded(.down) * stepU

The avoids the situation where the float expression of (value/stepU) = 29.99999 gets round down to 29

@marionbarker
Copy link
Collaborator

marionbarker commented Dec 8, 2025

Test Summary

I think the rounding down should be with respect to the increment.

In this test, the increment is 0.05 U. I think if the requested bolus is an integer multiple of the increment, it should be accepted.

I found the relevant line and suggested a fix for it.

Test Configuration

Trio phone:

  • SE 2nd gen running iOS 18.7.2
  • connected to MDT 523 pump
  • using Nightscout as a CGM
  • uploading pump data to same Nightscout site
  • Trio dev branch, 0.6.0.26 version
  • enable remote control on Trio phone

LoopFollow phone

  • LoopFollow commit 54259ce (rounding down)
  • iPhone 8 running iOS 16
  • configure for Trio Remote Control using the same Nightscout site as Trio phone
  • configure notifications for persistent banners so they can be viewed one at a time

Ensure TRC works and values shown in LoopFollow are appropriate

  • ✅ Remote Settings DEBUG / INFO section on Loop Follow phone says 0.05 U
    • This is correct for the MDT 523 pump and confirm it works directly on the Trio side
    • For MDT <= 522, the value is 0.1 U
  • confirm ✅ meal, ✅ bolus, ✅ temp target and ✅ override remote commands work as expected
    • ✅ include at least one 0.05 U remote bolus

Use the Rec. Bolus feature

The tests above (that included carb entries) did not provide sufficient bolus to cover those entries:
Main LF screen shows 1.95 U recommended.

  • tap on remote bolus
    • ✅ confirm the screen indicates 1.95 U
    • ✅ confirm the time-ago for when that calculation was made is correct
    • ✅ accept the recommendation and bolus remotely

Trio phone is recommending 0.575 U
LoopFollow main display says Rec. Bolus 0.58 U
Turn the Trio phone to Open Loop
wait 10 minutes

  • Trio main screen + indicates 0.725 U
  • LF Rec. Bolus says 0.72
  • do a remote bolus - accept the recommendation
    • ❓ this seems to have rounded down twice - once to 0.70 U, then it wants me to confirm to 0.65 U, accept that and it was successfully sent

wait another 5 minutes

  • log carbs on Trio phone with no bolus, rec goes up to 1.15 on LF phone
  • this time, enter a remote bolus manually (1.15 U) - do not tap to transfer the recommendation
  • ❌ Pretty sure this is wrong. The Confirm bolus screen rounded down again to 1.10 U.

I found the relevant line and suggested a fix for it.

@marionbarker
Copy link
Collaborator

marionbarker commented Dec 11, 2025

Test

Successful test except ❌ LoopFollow should not continue when bolus <= bolus increment

  • LoopFollow rounds down to 0 and then proceeds to confirm and send bolus request for 0 U
  • Error message back from Trio is deceptive Command rejected: boluses totaling more than 20% of the requested amount have been delivered since the command was sent.

Test List

The Trio phone is running version 0.6.0.26.
The LoopFollow phone is running commit 29ad622.

  • ✅ test with MDT 523 and note the rounding issues reported in prior comment were fixed.
  • ✅ spot check for MDT 515. (increment is 0.1 - takes Trio a while to update)
  • ✅ spot check for Omnipod DASH using an rPi simulator. (increment is 0.05, but did not wait for increment to update)
  • ✅ spot check for DanaKit using an rPi simulator.

Any issues (except for the 0 U remote bolus request) appear to be issues with Trio (not with LoopFollow) and were reported to the devs.

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.

6 participants