nightscout / AndroidAPS

Opensource automated insulin delivery system (closed loop)
https://wiki.aaps.app
GNU Affero General Public License v3.0
694 stars 1.7k forks source link

NormalTarget's inconsistency #3071

Open justmara opened 10 months ago

justmara commented 10 months ago

There is a concept of 'normalTarget' widely used in AAPS: for high/low temptargets (target value is compared with normalTarget); dynISF uses normalTarget as a base to scale up/down ISF with BG level...

However there are some problems with it:

  1. var normalTarget = 100; - this is hardcoded value used in oref1 js files. But the value of 100 is impossible to be used on devices with mmol units. Because 100 is 5.(5) - you cannon set up the tempTarget of 5.55555555... in AAPS, nor you can not set this value for profile. So is always lower or higher than normalTarget. The mgdl users does not suffer from this problem.

  2. Even documentation lies (hypo and activity sections) :) It states that TT of 100 (or 5.5) or higher is considered as High Temp-Target

    image image

But the code uses strict comparision with 100: else if (! profile.allowSMB_with_high_temptarget && profile.temptargetSet && target_bg > 100). So setting 100 with mgdl-units system witll not trigger 'high temp' despite doc says that. But setting 5.5 on mmol system will be treated as 'low TT`, while doc says it is high value :)

Looks like AAPS requires new global constant of normalTarget (=99) to be reused when needed.

justmara commented 10 months ago

Another buggy scenario. Assume enabled settings:

  1. high TT raises sens
  2. low TT lowers sens
  3. disable SMB with TT

Using mgdl you can set TT for 100 so SMBs are disabled, but ISF is not altered. Using mmol you cannot set such TT because 5.5 (*18=99) would be 'low TT' (lower than 100) and thus ISF would be lowered. While 5.6 on the other hand is high TT (5.6*18=100.8 which is higher than 100) so ISF would be lowered.

So definitely normalTarget must be 99. Or, maybe, it must be the average of profile target (since it is specified as bg range)?

justmara commented 10 months ago

Also ExtendedBolusExtension.kt uses 100 as normalTarget in fun ExtendedBolus.iobCalc