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

Enable SMB when BG greater than specified value #1365

Merged
merged 13 commits into from
Dec 18, 2021

Conversation

stevebell117
Copy link
Contributor

This is the result of Issue #1353, and would love to see this implemented as it gives a bit more configuration to users who may want SMBs to be enabled over a certain threshold value. I have been running this on AndroidAPS for nearly 6 months now, and think it would be beneficial for some users. If this is approved, I can also work on updating the documentation to explain what this feature does.

Feature: Enable SMB when a BG is greater than a specified value (high_bg). Let's say a user wants SMBs when their sugars exceed 150mg, with this toggle they can enable SMBs (while obeying the Temp Targeting rules already in place) automatically without having to manually intervene themselves. If a user is sitting below 150mg, then basals would be the only way insulin would be delivered, unless some other SMB rule is satisfied.

Please let me know any concerns/ feedback and I'll do my best to address them!

Fix profile variable name for high bg target
@PieterGit
Copy link
Contributor

Similar discussions are now in the Loop community, see LoopKit/Loop#1283 . Hope we find the best way that works for all T1D. Not using oref0 at this moment, so can't participate in the oref0 testing.

@Foxy7
Copy link
Contributor

Foxy7 commented Jun 27, 2020

Thanks @stevebell117 looks good to me.

I've tried this code out today, since I'd like to limit SMB to be active only when high and this seems to do the trick.

I set enableSMB_high_bg = true at 14:30 this afternoon, this is the first time it's been activated. Going forward i'll be using it at a higher threshold, but nice to have the option.

Jun 27 16:32:44 MealsDev2 pump-loop.log SMB disabled (no enableSMB preferences active or no condition satisfied)
..
Jun 27 16:32:45 MealsDev2 pump-loop.log enact/smb-suggested.json: {"temp":"absolute","bg":108,"tick":"+9","eventualBG":117,"insulinReq":0.11,"reservoir":"74.2\n","deliverAt":"2020-06-27T15:32:44.641Z","sensitivityRatio":1,"COB":0,"IOB":0.433,"BGI":-4.9,"deviation":"3.9","ISF":"8.0","CR":10,"target_bg":"4.5","duration":30,"rate":0.5}
..
Jun 27 16:32:49 MealsDev2 pump-loop.log enact/smb-enacted.json: "Rate: 0.5 Duration: 30"
Jun 27 16:32:50 MealsDev2 pump-loop.log Checking pump status (suspended/bolusing): {"status":"normal","bolusing":false,"suspended":false}
Jun 27 16:32:52 MealsDev2 pump-loop.log Temp refreshed: monitor/temp_basal.json: {"duration":30,"temp":"absolute","rate":0.5}
Jun 27 16:32:53 MealsDev2 pump-loop.log No bolus needed. jq: error: Could not open file monitor/edison-battery.json: No such file or directory
..
Jun 27 16:36:00 MealsDev2 pump-loop.log currenttemp: { duration: 28, temp: 'absolute', rate: 0.5 } lastTempAge: 4 m tempModulus: 2 m
Jun 27 16:36:00 MealsDev2 pump-loop.log Checking BG to see if High for SMB enablement.
Jun 27 16:36:00 MealsDev2 pump-loop.log Current BG 118  | High BG  110
Jun 27 16:36:00 MealsDev2 pump-loop.log High BG detected. Enabling SMB.
Jun 27 16:36:00 MealsDev2 pump-loop.log profile.sens: 144 sens: 144 CSF: 14.4
Jun 27 16:36:00 MealsDev2 pump-loop.log Last carbs 35 minutes ago; remainingCATime: 3.9 hours; 100% carbs absorbed
Jun 27 16:36:00 MealsDev2 pump-loop.log Carb Impact: 13.9 mg/dL per 5m; CI Duration: 0 hours; remaining CI ( 3.9  peak): 0 mg/dL per 5m
Jun 27 16:36:00 MealsDev2 pump-loop.log UAM Impact: 13.9 mg/dL per 5m; UAM Duration: 1.1 hours
Jun 27 16:36:00 MealsDev2 pump-loop.log minPredBG: 133 minIOBPredBG: 133 minZTGuardBG: 82 minUAMPredBG: 134 avgPredBG: 133 COB: 0 / 50
Jun 27 16:36:00 MealsDev2 pump-loop.log BG projected to remain above 4.5 for 240 minutes
Jun 27 16:36:00 MealsDev2 pump-loop.log naive_eventualBG: 58 bgUndershoot: 2.5 zeroTempDuration: 240 zeroTempEffect: 173 carbsReq: -12
Jun 27 16:36:00 MealsDev2 pump-loop.log IOB 0.414 > COB 0; mealInsulinReq = 0
Jun 27 16:36:00 MealsDev2 pump-loop.log profile.maxUAMSMBBasalMinutes: 30 profile.current_basal: 0.3
Jun 27 16:36:00 MealsDev2 pump-loop.log naive_eventualBG 58, 0m 0U/h temp needed; last bolus 34.6m ago; maxBolus: 0.2
Jun 27 16:36:00 MealsDev2 pump-loop.log 2020-06-27T15:36:00.374Z
Jun 27 16:36:00 MealsDev2 pump-loop.log Checking deliverAt: 2020-06-27T15:36:00.374Z is within 1m of current time: Sat Jun 27 16:36:00 BST 2020
Jun 27 16:36:00 MealsDev2 pump-loop.log and that smb-suggested.json is less than 1m old
Jun 27 16:36:01 MealsDev2 pump-loop.log enact/smb-suggested.json: {"temp":"absolute","bg":118,"tick":"+10","eventualBG":142,"insulinReq":0.36,"reservoir":"74.2\n","deliverAt":"2020-06-27T15:36:00.374Z","sensitivityRatio":1,"COB":0,"IOB":0.414,"BGI":-4.75,"deviation":"4.7","ISF":"8.0","CR":10,"target_bg":"4.5","units":0.1,"duration":30,"rate":1}
Jun 27 16:36:01 MealsDev2 pump-loop.log "minPredBG 7.4, minGuardBG 7.0, IOBpredBG 7.4, UAMpredBG 7.4; Eventual BG 7.9 >= 4.5,  insulinReq 0.36. Microbolusing 0.1U. temp 0.5<1U/hr. "
Jun 27 16:36:01 MealsDev2 pump-loop.log UAM: [118,126,133,139,145,149,153,155,157,158,158,157,155,153,152,150,149,147,146,145,144,143,143,142,141,141,140,139,139,138,138,137,137,137,136,136,136,135,135,135,135,134]
Jun 27 16:36:01 MealsDev2 pump-loop.log IOB: [118,126,133,139,145,149,153,155,157,157,157,156,154,152,150,149,147,146,145,144,143,142,142,141,140,139,139,138,138,137,137,136,136,135,135,135,134,134,134,134,133]
Jun 27 16:36:01 MealsDev2 pump-loop.log ZT:  [118,113,109,105,101,97,94,92,89,87,86,84,83,83,82,82,83,83]
Jun 27 16:36:03 MealsDev2 pump-loop.log Temp refreshed: monitor/temp_basal.json: {"duration":28,"temp":"absolute","rate":0.5}
Jun 27 16:36:05 MealsDev2 pump-loop.log enact/smb-enacted.json: "Rate: 1 Duration: 30"
Jun 27 16:36:07 MealsDev2 pump-loop.log Checking pump status (suspended/bolusing): {"status":"normal","bolusing":false,"suspended":false}
Jun 27 16:36:08 MealsDev2 pump-loop.log Temp refreshed: monitor/temp_basal.json: {"duration":30,"temp":"absolute","rate":1}
Jun 27 16:36:09 MealsDev2 pump-loop.log 2020-06-27T15:36:00.374Z
Jun 27 16:36:09 MealsDev2 pump-loop.log Checking deliverAt: 2020-06-27T15:36:00.374Z is within 1m of current time: Sat Jun 27 16:36:09 BST 2020
Jun 27 16:36:09 MealsDev2 pump-loop.log and that smb-suggested.json is less than 1m old
Jun 27 16:36:11 MealsDev2 pump-loop.log Listening for 1s: .No interfering pump comms detected from other rigs (this is a good thing!)
Jun 27 16:36:11 MealsDev2 pump-loop.log Continuing oref0-pump-loop at Sat Jun 27 16:36:11 BST 2020
Jun 27 16:36:13 MealsDev2 pump-loop.log Checking reservoir: reservoir level before: 74.2, suggested: 74.2 and after: 74.2
Jun 27 16:36:15 MealsDev2 pump-loop.log Checking pump status (suspended/bolusing): {"status":"normal","bolusing":false,"suspended":false}
Jun 27 16:36:20 MealsDev2 pump-loop.log Sending ESC ESC, ESC ESC ESC ESC to exit any open menus before SMBing and bolusing 0.1 units
Jun 27 16:36:24 MealsDev2 pump-loop.log Checking pump status (suspended/bolusing): {"status":"normal","bolusing":true,"suspended":false}

image

@Foxy7
Copy link
Contributor

Foxy7 commented Jul 7, 2020

Update. I've been using this for the past 10 days and has worked well, no issues that I've found. From a few minutes ago following lunch, High BG enables SMB before minGuardBG disabled it.

Jul 07 13:51:46 MealsDev2 pump-loop.log Checking BG to see if High for SMB enablement.
Jul 07 13:51:46 MealsDev2 pump-loop.log High BG detected. Enabling SMB.
Jul 07 13:51:46 MealsDev2 pump-loop.log minGuardBG 3.9 projected below 4.4 - disabling SMB

Copy link
Contributor

@scottleibrand scottleibrand left a comment

Choose a reason for hiding this comment

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

Tested successfully with and without the new preference, and above and below current bg.

@scottleibrand scottleibrand merged commit d15d8d4 into openaps:dev Dec 18, 2021
@inventor96
Copy link

Just to double check before I volunteer to help with documentation, has the documentation been added for this? I checked these two pages, but didn't see anything related to the new options in this PR.

https://openaps.readthedocs.io/en/latest/docs/While%20You%20Wait%20For%20Gear/preferences-and-safety-settings.html

https://openaps.readthedocs.io/en/latest/docs/Customize-Iterate/oref1.html

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.

5 participants