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

GarmingPlugin local server at /sgv.json endpoint returns constant tbr:0 #3745

Open
suside opened this issue Jan 15, 2025 · 0 comments
Open

Comments

@suside
Copy link

suside commented Jan 15, 2025

Just like in the title, tested on Android Pixel+Spirit Combo and emulator+virtual pump, latest version of AAPS 3.3.1.0

Whatever the temp basal actually is, the endpoint will always return 0.

Current behavior, given basal rate 90:

GET http://127.0.0.1:28891/sgv.json?brief_mode=true&count=1
[
  {
    "tbr": 0
    // other fields irrelevant
  }
]

Expected behavior, given basal rate 90:

GET http://127.0.0.1:28891/sgv.json?brief_mode=true&count=1
[
  {
    "tbr": 90
    // other fields irrelevant
  }
]

Simple POC fix I did is just a copy & paste from XDrip plugin like so:

--- a/plugins/sync/src/main/kotlin/app/aaps/plugins/sync/garmin/LoopHubImpl.kt
+++ b/plugins/sync/src/main/kotlin/app/aaps/plugins/sync/garmin/LoopHubImpl.kt
@@ -89,8 +91,8 @@ class LoopHubImpl @Inject constructor(
     /** Returns the factor by which the basal rate is currently raised (> 1) or lowered (< 1). */
     override val temporaryBasal: Double
         get() {
-            val apsResult = loop.lastRun?.constraintsProcessed
-            return if (apsResult == null) Double.NaN else apsResult.percent / 100.0
+            val tbr = processedTbrEbData.getTempBasalIncludingConvertedExtended(System.currentTimeMillis())?.rate
+            return if (tbr == null) Double.NaN else tbr / 100.0
         }

     override val lowGlucoseMark get() = profileUtil.convertToMgdl(

Unit tests didn't catch that because they are mocked at higher level.

Should I create PR? Please advise, have a nice day 🙂

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

No branches or pull requests

1 participant