-
Notifications
You must be signed in to change notification settings - Fork 514
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
Nightscout CGM Import Settings fails with error #245
Comments
Does your selection of mg/dl vs mmol match your NS configuration? My hunch is perhaps your Trio preferences still has mmol set (default starting point) and your NS is using mg/dl. If this is the case, the fix is to set your preferences in Trio to match NS. It would also indicate that the error message in Trio isn’t clear enough. |
Very strange. I have trouble locating that particular or any similar Import error text string in the Trio code ("The data couldn't be read because it isn't in the correct format."). A screenshot of the Import error alert would be of great help for further troubleshooting so I can see the exact phrasing. And also, you wrote "Pump type: none yet, plan to use OmniPod Dash". Do you run a pump simulator? (The reason im asking is that there needs to be a pump simulator or actual pump set up for the import settings to work, since basal settings are written to the pump. If that fails, it should however show another import error message than the one you're getting.. EDIT: Thank you for providing the screenshot in your post above |
Yes, I am using the pump simulator. I just ran Trio in the Simulator on my Mac, and it is failing in the code above. |
Have you used this Nightscout URL with iAPS or Loop before? |
And one more thing. You do not need to delete nightscout to be able to do a new import. When it works as it should, the "import setting" can be run anytime you like (if you for instance make changes to the CR/ISF/Basals In nightscout, it can be imported by Trio). However very important to always double check that its imported as expected as stated in the alert |
Ok. I think Mike can answer this better, but the alert is a default alert for parsing errors (that's why I didn't find that specific string anywhere in the code). I see that now. And as stated in the alert and in the log it's a formatting mismatch (maybe because previously saved entries from loop doesn't fit 1:1 with formatting in Trio) |
It errors out right after it attempts to decode the JSON. Here is the parsingError from the above |
I guess that means I cannot import settings from Nightscout then? I just wanted you to know this was occurring and may impact others. Thank you so much for your help!!! |
We need to dig deeper in what could or could not be done to fix this. And as you say, if this affects all users coming from Loop to Trio it is very good to know (and communicate in onboarding documentation) that it's a known limitation with the import function. That you need to have made a first upload of settings to NS from Trio (or previously iAPS) for the import function to work correctly. But I don't know for sure. We need to look into this more. |
I downloaded the profile.json file from Nightscout and jsonlint.com shows that it is valid. There are several elements with "mills" and they are strings not integers or Decimal (as defined in RawFetchedProfile.swift below). Could this be the issue?
NightscoutConfigStateModel.swift uses: Defined in RawFetchedProfile.swift: In NightscoutStatus.swfit it is an Int: |
Ok, good catch. And as input to further investigations between devs in how to handle the user migration from loop->Trio scenarios in the best way going forward. https://chatgpt.com/share/99f6aaea-dce3-48d0-8a0b-d1e371a1d782 Hm. The link maybe dont work. I pasted the answer below. (The first entry is Loop profile, the second is Trio) GPT code analysis
Here are the differences in formatting of field values between the two database entries: General Structure
Date and Time
Units
Entered By
Loop Settings
Store Values
Additional Fields
Key Observations
These differences indicate variations in how the data is structured, stored, and possibly the schema version or application generating these entries. |
After I changed mills to a String in RawFetchedProfile.swift, "Import Settings" got further but errored out on: "carbs_hr" which is a String on Nightscout, but Int in FetchedNightscoutProfileStore, Swift.DecodingError.Context(codingPath: [_JSONKey(stringValue: "Index 0", intValue: 0), CodingKeys(stringValue: "store", intValue: nil), _JSONKey(stringValue: "Default", intValue: nil), CodingKeys(stringValue: "carbs_hr", intValue: nil)], debugDescription: "Expected to decode Int but found a string instead.", underlyingError: nil)) keyNotFound(CodingKeys(stringValue: "created_at", intValue: nil), Swift.DecodingError.Context(codingPath: [_JSONKey(stringValue: "Index 0", intValue: 0)], debugDescription: "No value associated with key CodingKeys(stringValue: "created_at", intValue: nil) ("created_at").", underlyingError: nil)) profile.json:
Changing these in RawFetchedProfile.swift and NightscoutConfigStateModel.swift to match Nightscout resolves the "Import Settings" issue for "enteredBy": "Loop" Nightscout profiles. |
That is a great idea to use chatGPT for the diff!! It matched basically what I found in testing. |
One idea could be to make a conditional check for enteredBy: Trio or Loop (or not Trio) when importing and adjust the formatting accordingly. Loop->Trio isn't however the only user migration case. The previous NS profile entries could of course have been made by AAPS or previous iAPS, and there maybe isn't possible to find a proper way to handle all scenarios. But this issue is registered and lives on this board, and some of our devs can look into this further as soon as the higher prioritized issues right now are resolved. (if you don't want to make a Pull request draft on this yourself that is?, it seems you have quickly identified the issue and possible solutions😊 ) |
Yes, and it could be an old version of Nightscout with totally different data, but this scenario probably isn't too likely. Perhaps we could just re-try the JSON decoder on catch with the Loop data types? I'm not sure what format AAPS uses but I think it may be the same as Loop? Yes, I can look into making a PR draft for this issue. |
That’s great @kskandis. You should be able to find users here with examples of both Loop and AAPS data in their NS databases. |
Describe the bug
I know Nightscout is not recommended for CGM but I thought I would test it. Trio connects fine to my Nightscout instance but Nightscout Config - Import Settings fails with the following error:
"The data couldn't be read because it isn't in the correct format."
To Reproduce
Steps to reproduce the behavior:
Expected behavior
Nightscout settings should be imported.
Screenshots
If applicable, add screenshots to help explain your problem.
Smartphone (please complete the following information):
iPhone SE 3rd Generation iOS 17.4.1
Setup Information (please complete the following information):
Additional context
Unable to provide screenshot as the Nightscout CGM cannot be deleted and re-added. Configuring Nightscout seems to be a one-time only process. It would be nice to have a Delete option to allow a re-configuration of Nightscout CGM.
The text was updated successfully, but these errors were encountered: