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

Issues when using Nightscout as BG source #797

Closed rustymonkey closed 2 years ago

rustymonkey commented 2 years ago

I'm trying to test AAPS 3 using AAPS 2 settings (which were configured to use a Local Profile) using Nightscout as the data source, but am unable to activate a profile with this config.

With this setup, I'm experiencing various problems/bugs: 1) I initially set up AAPS by installing it, running the Wizard, and importing settings from 2.8.1 (which includes a Nightscout profile). I then set NSClient BG as the data sourec, and disabled all NSClient Sync settings except for 'Receive/Backfill CGM Data', but I guess that some data from Nightscout (e.g. Profile data) had presumably synced as soon as I imported my old settings (though it didn't appear in the UI). This resulted in the following issues:

a) When I attempted to activate the local profile, an error appears ">>Profile low target<< 4.8 is out of hard limits", despite the fact that the Locale Profile was set to targets of 5/5. I think that what was happening is that the initially synced nightscout profile was somehow overriding the local profile. This was really strange because the nightscout profile didn't display anywhere in the UI--I was trying to enable a Local Profile with valid targets and no other profile was listed!

b) When I press the '-' to adjust the BG Target values down 6, AAPS changed the value 80. Again, this is presumably because the nightscout profile was somehow incorrectly converted and was using mg/dl settings (note: my AAPS environment is configured to use mmol). Curiously, clicking 'reset' to reset the targets, reset them to 5/5 ?!

2) There was no obvious fix to the above problems, so I uninstalled AAPS, disabled WiFi so that it wouldn't be able to connect to Nightscout, and then installed it, ran the Wizard, and imported settings from 2.8.1, configured NSClient BG as the data source, disabled all NSClient Sync settings except for 'Receive/Backfill CGM Data', and only then did I re-enable WiFi.

After going through the above steps, there were no longer a '>>Profile low target<<' error, however: a) The 'NSclient BG' tab shows nightscout BG data, but the Overview doesn't (neither at the top of the screen nor the graph)! b) When I 'Activate Profile' , the 'Profile Switch' confirmation dialog appears and I press 'OK', but upon returning to the Overview tab, it indicates in red 'NO PROFILE SET'!

Details

rustymonkey commented 2 years ago

Re. issue 2.a, I switched the BG source to XDRIP+ and the outcome is the same. i.e. the XDRIP+ tab displays BG data, but the Overview screen doesn't. Issue 2.b. remains.

MilosKozak commented 2 years ago

re 2b .... check release notes. Profile switches changed behavior

MilosKozak commented 2 years ago

there were profile sync issues in beta1. try beta2

rustymonkey commented 2 years ago

The issues occur identically in Beta 2. I dm'd a video and associated logs over discord.

rustymonkey commented 2 years ago

It turns out that issue 2 is unrelated to nightscout and is related to error-handling of out-of-range profile values. Documented this at https://github.com/nightscout/AndroidAPS/issues/819

StephenBrown2 commented 2 years ago

re 2b .... check release notes. Profile switches changed behavior

Where are the release notes for beta releases?

Edit: Hidden in the WIki under "Installating": https://androidaps.readthedocs.io/en/latest/Installing-AndroidAPS/Releasenotes.html

rustymonkey commented 2 years ago

Retested in 3.0 Beta 3, and almost all of the issues are fixed (or covered elsewhere) except for: 2b) When the BG data source is set up, the BG data should appear on the Overview page--even if other aspects of the loop aren't configured. Otherwise, users are given the impression that there's a problem with the configuration/functionality of their BG source.

I'm going to close this issue since there's a lot of unrelated cruft, and open a new one to track this minor problem.

rustymonkey commented 2 years ago

It turns out that I closed this prematurely. There are no issues when AAPS is prevented from syncing with nightscout, but if, during the initial setup, AAPS is briefly allowed to sync with Nightscout, then AAPS gets into a state in which the imported local profile doesn't activate (even if it's edited) though a newly created profile does.

To replicate 1 Clean install of AAPS 2 Import settings from 2.8 (which includes just a single local profile) 3 Change BG source from Dexcom to Nightscout (since it contains live data from another AAPS that's in use) 4 Disable nightscout uploads / profile sync 5 Change at least 1 value for each profile parameter and then 'Save' the profile 6 Activate Profile 7 Trigger 'Refresh' on the Medtronic tab in order to work around issue #843 and trigger pump comms/profile update --> Profile fails to update (as seen on the Overview screen) 8 Create a new profile, and Save and Activate it --> Profile updates

IMPORTANT: if I disable WiFi prior to step 2 in order to prevent all communications with Nightscout and then re-enable Wifi after step 4 (i.e. once NS Client uploads have been disabled), then the bug doesn't occur.

I guess that what is happening is that prior to step 4, profile data from nightscout is 'synced' (even though there don't appear to be any changes in the local profile). And then, even after I edit the local profile at step 5, for some reason some data previously synced from nightscout interferes with it. What's confusing is that I'd have expected the more recently edited local profile to take precedence over whatever other data was synced.

Tested with 3.0 Beta 3 Logs provided offline after the steps above were carried out

MilosKozak commented 2 years ago

try with beta5

rustymonkey commented 2 years ago

Tested beta 5 and it's mostly working--at step 7, the edited settings in the Local Profile are now activated as would be expected. However, I'm still not sure whether some aspects of the current behavior are functioning as intended. i.e.

When NS Profile connects, the Overview screen displays a red error notification bar at the top indicating: "Invalid profile default not accepted from NS [view]" Clicking [View] --> "Dialog showing "Profile DIA value 7.17 is out of hard limits; Profile low target 4.80 is out of hard limits"

One might say that this is expected, since the imported settings had the NS Client 'Receive profile store' setting enabled until I disabled it. But I think it might be a bug that this option was enabled in the first place! i.e. my imported AAPS 2.8.2 settings were set to use a Local Profile exclusively ("Upload local profile changes to NS" was enabled solely for reporting purposes). afaik, I did not have any options enabled to download configurations from NS to AAPS. So why does AAPS 3.0 change this and try to download my profile config from Nightscout (and warn me about out-of-range settings that I'd never configured in the first place)? And had the Profile Config values in NS been valid, would they have overridden the Local Profile values from my imported settings which I'd intended to use?

Summary: unless I'm misunderstanding things, if a user imports settings configured to use a Local Profile, then AAPS shouldn't automatically enable 'Receive profile store' NSClient setting.

MilosKozak commented 2 years ago

nsclient and profiles are completely new, sync work on different principles and settings are new as well if you import old settings, only these used in new version are re-used. New ones are defaulted such nuances you describe is impossible to process