Closed RansomTime closed 10 months ago
Hi, thank you for giving Glucoscape a shot! It's so nice to hear from someone who also uses mmol/l 😄
May I ask what version of Nightscout you're running? I'm on 14.2.6, am also using mmol/l units, and my Nightscout returns the target range in mmol/l 🤔 I did think that that was strange because the actual CGM values are always in mg/dl...
Just to be sure, I've now checked whether I set my target range correctly in NS. The Profile Editor screenshot I'm attaching is a bit ambiguous: it says Target BG range [mg/dL,mmol/L]
. But I actually set my target range with environment variables BG_TARGET_BOTTOM
and BG_TARGET_TOP
, and those are supposed to be in the same units as the chosen display unit: https://nightscout.github.io/nightscout/setup_variables/#alarms
So I set them in mmol/l. Is it possible that you set your target range in NS in mg/dl? Or perhaps there's some difference between NS versions...
Wow that's super weird.
My first debug step was updating from 14.2.something to 15.0.2 (I'm using docker for nightscout so just refreshed the image) but in both circumstances it returned mgdl
Removing these and only having one range for a day is also gives mg/dl
I also commented out the below from my docker config (they were in mmol) to see if that helped, didn't change anything though.
# BG_LOW: 3.8
# ALARM_LOW: off
# BG_HIGH: 15.0
# BG_TARGET_TOP: 10.0
# BG_TARGET_BOTTOM: 3.8
Not sure if this is a bug in NS, and the best way of fixing this for glucoscape (heuristically determining the units of the target range?)
It's 100% getting those values from the environment variables, as commenting those out/changing them changes the display on glucoscape.
Above commit looks to see if bgTargetTop is greater than 30, if it is then it's an mg/dl value (for comparason, the maximum values of CGMs are in the low 20s, so it's extremely unlikely that 30 is anything but an mg/dl value.
Does that work on your NS?
Thank you for this fix. If you don't mind, I've implemented it slightly differently: the target range is always kept in mg/dl (however much I despise that unit) and only converted to mmol/l when displayed. I prefer it this way because all CGM values are also kept in mg/dl so it's all consistent.
Hope this works for you. I've tested it with my NS and also with the instance whose details you've provided (very helpful, thanks for that!) https://github.com/vitawasalreadytaken/glucoscape/pull/6
Some fixes for mmol/l display
Nightscout's API returns mg/dl for target range, even if nightscout's display is set to mmol so this doesn't need multiplying in app.ts (this was causing all reading to be out of range)
{targetRange} when converted to mmol should be fixed to 1 decimal place, otherwise it displays large amounts of digits due to floating point division (i.e. a target high of 180 mg/dl reads 9.99000000000999)
Both of these can be tested with my nightscout instance. Running on nightscout.ransomti.me with token reporter-eedc563cda3d55b7